Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
test: add repeatable H3 scene continuity diagnostics (#8867)
[._.]/ Adam Eivy123199557b91
diff --git a/docs/README.md b/docs/README.mdindex 1d92819cff..027c8a3fb3 100644--- a/docs/README.md+++ b/docs/README.md@@ -66,7 +66,7 @@ Comms & voice: [beeper](./features/beeper.md) · [openclaw-operator-chat](./feat- **[plans/](./plans/README.md)** — dated design plans (`YYYY-MM-DD-<slug>.md`), archived on approval before implementation. Historical records, not living docs. See [provider connections and harnesses](./plans/2026-09-06-provider-connections-and-harnesses.md) for stable executable routes, migration and management flows.- **decisions/** — ADRs (`YYYY-MM-DD-<slug>.md`), e.g. the [Postgres-as-primary-datastore decision](./decisions/2026-06-07-postgres-as-primary-datastore.md) and what may cross the federation layer ([user-controlled federation](./decisions/2026-09-19-user-controlled-federation.md), [Privacy Center storage](./decisions/2026-08-08-privacy-records-machine-local.md), [federated visual prompts](./decisions/2026-08-20-federated-visual-prompts.md), [conditioning crosses to an allowlisted peer](./decisions/2026-08-22-federated-media-input-assets.md), [AI usage metrics federate on by default](./decisions/2026-09-01-federated-usage-metrics.md), [Eidoverse guest chat](./decisions/2026-09-05-eidoverse-guest-chat.md), [numeric PortOS quality federation](./decisions/2026-09-10-portos-quality-federation.md), [federated Eidoverse foundations](./decisions/2026-09-18-federated-eidoverse-foundations.md)), why H3 [ships the draft-decode gates without an asset](./decisions/2026-08-30-h3-draft-decoder-asset.md), and why closed-set decisions run on a [local entailment model that abstains](./decisions/2026-09-18-local-jev-decision-service.md).-- **research/** — dated investigation and incident write-ups (e.g. the [mflux GPU-watchdog panic](./research/2026-06-13-mflux-training-watchdog-panic.md) and the [local LLM performance audit](./research/2026-08-22-local-llm-performance-audit.md)).+- **research/** — investigation tools and incident write-ups (e.g. the [H3 scene-continuity comparison](./research/minimax-h3-continuity.md), [mflux GPU-watchdog panic](./research/2026-06-13-mflux-training-watchdog-panic.md) and [local LLM performance audit](./research/2026-08-22-local-llm-performance-audit.md)).- **superpowers/** — plan/spec pairs from superpowers-driven builds: `specs/<date>-<slug>-design.md` (design) + `plans/<date>-<slug>.md` (implementation plan).## Otherdiff --git a/docs/research/minimax-h3-continuity.md b/docs/research/minimax-h3-continuity.mdnew file mode 100644index 0000000000..2aa686ca8e--- /dev/null+++ b/docs/research/minimax-h3-continuity.md@@ -0,0 +1,71 @@+# MiniMax H3 scene-continuity comparison++Issue #8867 remains an investigation. Native image-mode canvas selection landed+in commits `95b864cd1` and `1aba4b504`. It removes a confounding factor; it does+not establish that conditioning is correct or that scene continuity is fixed.++## Controlled H3 runs++`scripts/diagnose_minimax_h3.py` creates a synthetic colored room with a doorway,+cube and ball, then compares three fixed-seed, stock-encoder, no-LoRA requests:++| Case | Canvas | Prompt |+| --- | --- | --- |+| small-motion | 576×1024 | Camera moves forward; objects remain stationary |+| native-motion | 768×1344 | Same motion-only prompt |+| native-conflict | 768×1344 | Camera moves through a snowy forest |++All use 124 frames, 24 fps, seed 42 and 9 sigma entries. The script pins the+runtime and checkpoints used by the original report so registry updates do not+silently change the experiment. It calls the production adapter, including its+vision-weight, image-processor and vision-embedding corrections. It never pastes+the source over generated frames or changes conditioning tensors.++Use a **new directory outside the checkout** for each invocation. Planning needs+only Python's standard library and does not import MLX or load models:++```sh+python3 scripts/diagnose_minimax_h3.py --output-dir /tmp/h3-continuity-plan+```++Inspect `source.ppm` and `plan.json`. To render, ensure no other GPU work is+running, then use the already installed H3 interpreter and another new directory:++```sh+~/.portos/minimax-h3-mlx/.venv/bin/python3 scripts/diagnose_minimax_h3.py \+ --output-dir /tmp/h3-continuity-render --run+```++This command is expensive: the pinned runtime reports approximately 8.8 minutes+per native five-second diffusion step on its reference hardware. Three runs can+take several hours. Each render uses a separate process, runs sequentially and+stops the comparison on failure. The script does not coordinate with PortOS's+live GPU queue; run it only while that queue and other GPU applications are idle.+Weights must already be cached; child processes enforce Hugging Face offline+mode. No model download, substitute encoder or preview decoder is requested.++Each case contains the video, frames 0/1/12/60/123, a local runtime log and+`report.json`. The report separates setup, conditioning/inference, video decode,+audio decode and mux wall time. It observes the patched text encoder's embedding+shape/tags, VAE conditioning rows and first DiT call's packed shapes/tags/index+counts. These are **structural observations, not numerical parity assertions**.+Lazy work may be charged to the boundary that materializes it. Failed worker+runs retain a failed report and log; never interpret partial outputs as success.+Logs may contain local paths; redact them before publishing evidence.++## What remains to establish++No real render results accompany this harness. `continuity: not_assessed` stays+explicit even after rendering: inspect the sampled frames and full clip, looking+for the colored room and objects beyond frame 12. Record whether a scene change+occurs and when; first-frame resemblance alone cannot pass the comparison.++Compare VAE normalization/posterior sampling, vision features, token tags and+rotary positions against the pinned FL2VA reference before changing the adapter.+Matching shapes cannot prove those numerical contracts. Repeat the synthetic+source and motion prompt on an installed image-capable LTX model, with its native+canvas, frame grid and stock encoder; record that model's pins and separate phase+timings. The H3 script intentionally does not imply that an LTX run occurred.+Only the resulting evidence can distinguish model/prompt limitations from an+integration defect and justify either a runtime correction or a user-facing+limitation.diff --git a/scripts/diagnose_minimax_h3.py b/scripts/diagnose_minimax_h3.pynew file mode 100644index 0000000000..a0af1d36d1--- /dev/null+++ b/scripts/diagnose_minimax_h3.py@@ -0,0 +1,218 @@+#!/usr/bin/env python3+"""Reproduce #8867 without private inputs. Planning never loads a model.++Run with the installed H3 Python. --run performs three expensive sequential+renders; see docs/research/minimax-h3-continuity.md for limits and interpretation.+"""++import argparse+from collections import Counter+import json+import os+from pathlib import Path+import subprocess+import sys+import time+++# These pins define this experiment, independently of later registry updates.+RUNTIME_REVISION = "fcd9e9b79a1d6018d91ac477c0968de1fa067e49"+MODEL_REVISION = "3ac52081470b0488921c3ec3ba84a39097bf2361"+CHECKPOINT_REVISION = "6818f6c32d12b210915e44ad56a4228c2608f160"+MOTION_PROMPT = "The camera slowly moves forward. Objects remain stationary."+CONFLICT_PROMPT = "The camera slowly moves forward through a snowy pine forest at night."+SAMPLES = [0, 1, 12, 60, 123]+++def write_source(path):+ """Stdlib-only PPM: colored room, red doorway, yellow cube, green ball."""+ width, height = 768, 1344+ pixels = bytearray()+ for y in range(height):+ for x in range(width):+ color = (60, 180, 220) if y < 900 else (120, 60, 160)+ if 70 < x < 300 and 200 < y < 900:+ color = (210, 40, 50)+ if 390 < x < 610 and 730 < y < 950:+ color = (240, 200, 30)+ if (x - 250) ** 2 + (y - 1080) ** 2 < 100 ** 2:+ color = (40, 210, 70)+ pixels.extend(color)+ path.write_bytes(f"P6\n{width} {height}\n255\n".encode() + pixels)+++def experiment_cases():+ return [+ dict(id="small-motion", width=576, height=1024, prompt=MOTION_PROMPT),+ dict(id="native-motion", width=768, height=1344, prompt=MOTION_PROMPT),+ dict(id="native-conflict", width=768, height=1344, prompt=CONFLICT_PROMPT),+ ]+++def runner_arguments(case, directory, runtime):+ return [+ "--runtime-dir", str(runtime), "--runtime-revision", RUNTIME_REVISION,+ "--model-repo", "pipenetwork/MiniMax-H3-MLX-8bit", "--model-revision", MODEL_REVISION,+ "--checkpoint-repo", "MiniMaxAI/MiniMax-H3", "--checkpoint-revision", CHECKPOINT_REVISION,+ "--checkpoint-file", "FL2VA/model_index.json",+ "--prompt", case["prompt"], "--width", str(case["width"]), "--height", str(case["height"]),+ "--num-frames", "124", "--fps", "24", "--steps", "9", "--seed", "42",+ "--image", str(directory / "source.ppm"), "--anchor", "first",+ "--min-system-memory-gb", "128", "--memory-headroom-gb", "16",+ "--output", str(directory / case["id"] / "video.mp4"),+ ]+++def instrument(pipe, report, clock=time.perf_counter):+ """Observe the actual patched encoder and pinned pipeline, without changing tensors."""+ encode = pipe.text_encoder.encode+ keyframes = pipe._encode_keyframes+ dit = pipe.dit++ def encode_observed(*args, **kwargs):+ result = encode(*args, **kwargs)+ features, tags = result+ report["vision_conditioning"] = {+ "embedding_shape": list(features.shape),+ "token_tag_counts": dict(Counter(str(tag) for tag in tags.tolist())),+ }+ return result++ def keyframes_observed(*args, **kwargs):+ rows = keyframes(*args, **kwargs)+ report["vae_conditioning_shape"] = list(rows.shape)+ return rows++ # The pinned pipeline invokes DiT positionally. Keep its module attributes+ # visible for preview/packing access while observing only the first call.+ class ObservedDiT:+ def __getattr__(self, name):+ return getattr(dit, name)++ def __call__(self, *args, **kwargs):+ if "packed_conditioning" not in report:+ report["packed_conditioning"] = {+ "video_shape": list(args[0].shape),+ "audio_shape": list(args[1].shape),+ "position_shape": list(args[6].shape),+ "token_tag_counts": dict(Counter(str(tag) for tag in args[5].tolist())),+ "video_indices": int(args[7].size),+ "audio_indices": int(args[8].size),+ "text_indices": int(args[9].size),+ }+ return dit(*args, **kwargs)++ pipe.text_encoder.encode = encode_observed+ pipe._encode_keyframes = keyframes_observed+ pipe.dit = ObservedDiT()+ originals = {}+ for name in ("_decode_video", "_decode_audio"):+ original = getattr(pipe, name)+ originals[name] = original++ def timed_decode(*args, _original=original, _name=name, **kwargs):+ started = clock()+ try:+ return _original(*args, **kwargs)+ finally:+ report["timings"][_name.removeprefix("_") + "_seconds"] = clock() - started++ setattr(pipe, name, timed_decode)++ def restore():+ pipe.text_encoder.encode = encode+ pipe._encode_keyframes = keyframes+ pipe.dit = dit+ for name, original in originals.items():+ setattr(pipe, name, original)++ return restore+++def run_worker(case, directory, runtime):+ import generate_minimax_h3 as runner++ started = time.perf_counter()+ report = {"case": case, "status": "failed", "continuity": "not_assessed", "timings": {}}+ original = runner.render_outputs++ def observed(pipe, args, images, save_mp4, batch_seeds=None):+ report["timings"]["setup_seconds"] = time.perf_counter() - started+ restore = instrument(pipe, report)+ render_started = time.perf_counter()+ mux_seconds = 0++ def timed_save(*save_args):+ nonlocal mux_seconds+ mux_started = time.perf_counter()+ try:+ return save_mp4(*save_args)+ finally:+ mux_seconds += time.perf_counter() - mux_started++ try:+ return original(pipe, args, images, timed_save, batch_seeds)+ finally:+ timings = report["timings"]+ timings["mux_seconds"] = mux_seconds+ timings["inference_and_conditioning_seconds"] = (+ time.perf_counter() - render_started - mux_seconds+ - timings.get("decode_video_seconds", 0) - timings.get("decode_audio_seconds", 0)+ )+ restore()++ runner.render_outputs = observed+ sys.argv = [str(Path(runner.__file__))] + runner_arguments(case, directory, runtime)+ try:+ runner.main()+ report["status"] = "rendered"+ finally:+ runner.render_outputs = original+ report["timings"]["total_seconds"] = time.perf_counter() - started+ (directory / case["id"] / "report.json").write_text(json.dumps(report, indent=2) + "\n")+++def run_cases(directory, runtime, cases, run=subprocess.run):+ """Fresh processes release all weights between cases; stop at the first failure."""+ for case in cases:+ target = directory / case["id"]+ target.mkdir()+ with (target / "runtime.log").open("w") as log:+ run([sys.executable, str(Path(__file__).resolve()), "--output-dir", str(directory),+ "--runtime-dir", str(runtime), "--worker", case["id"]],+ stdout=log, stderr=subprocess.STDOUT, check=True,+ env={**os.environ, "HF_HUB_OFFLINE": "1", "TRANSFORMERS_OFFLINE": "1"})+ for frame in SAMPLES:+ run(["ffmpeg", "-v", "error", "-i", str(target / "video.mp4"),+ "-vf", f"select=eq(n\\,{frame})", "-frames:v", "1",+ str(target / f"frame-{frame:03d}.png")], check=True)+ if not (target / f"frame-{frame:03d}.png").is_file():+ raise RuntimeError(f"Missing sampled frame {frame} for {case['id']}")+++def main():+ parser = argparse.ArgumentParser(description=__doc__)+ parser.add_argument("--output-dir", required=True, type=Path, help="new scratch directory outside the repository")+ parser.add_argument("--runtime-dir", type=Path, default=Path.home() / ".portos/minimax-h3-mlx")+ parser.add_argument("--run", action="store_true", help="perform all three multi-hour comparisons sequentially")+ parser.add_argument("--worker", choices=[case["id"] for case in experiment_cases()], help=argparse.SUPPRESS)+ args = parser.parse_args()+ directory = args.output_dir.resolve()+ cases = experiment_cases()+ if args.worker:+ return run_worker(next(case for case in cases if case["id"] == args.worker), directory, args.runtime_dir)+ directory.mkdir(parents=True, exist_ok=False)+ write_source(directory / "source.ppm")+ (directory / "plan.json").write_text(json.dumps({+ "cases": cases, "seed": 42, "frames": 124, "fps": 24, "steps": 9,+ "sample_frames": SAMPLES, "runtime_revision": RUNTIME_REVISION,+ "model_revision": MODEL_REVISION, "checkpoint_revision": CHECKPOINT_REVISION,+ "continuity": "not_assessed", "ltx_comparison": "pending",+ }, indent=2) + "\n")+ if args.run:+ run_cases(directory, args.runtime_dir, cases)+ print("Comparison rendered; inspect sampled frames." if args.run else "Plan and synthetic source written; no models loaded.")+++if __name__ == "__main__":+ main()diff --git a/scripts/diagnose_minimax_h3.test.js b/scripts/diagnose_minimax_h3.test.jsnew file mode 100644index 0000000000..52b841c0e3--- /dev/null+++ b/scripts/diagnose_minimax_h3.test.js@@ -0,0 +1,102 @@+import { execFileSync } from 'node:child_process';+import { fileURLToPath } from 'node:url';+import { describe, expect, it } from 'vitest';+import { resolveTestPython } from '../server/lib/testHelper.js';++const python = resolveTestPython();+const script = fileURLToPath(new URL('./diagnose_minimax_h3.py', import.meta.url));+const run = (source) => execFileSync(python, ['-c', source, script], { encoding: 'utf8' });+const load = `+import importlib.util, sys, tempfile, json+from pathlib import Path+from types import SimpleNamespace+spec = importlib.util.spec_from_file_location('diagnostic', sys.argv[1])+d = importlib.util.module_from_spec(spec)+spec.loader.exec_module(d)+`;++describe.skipIf(!python)('H3 continuity diagnostic', () => {+ it('writes a reproducible synthetic plan without launching a process or accepting existing output', () => {+ expect(run(`${load}+def forbidden(*args, **kwargs):+ raise AssertionError('planning launched a process')+d.subprocess.run = forbidden+with tempfile.TemporaryDirectory() as root:+ output = Path(root) / 'comparison'+ sys.argv = [str(d.__file__), '--output-dir', str(output)]+ d.main()+ plan = json.loads((output / 'plan.json').read_text())+ assert plan['continuity'] == 'not_assessed'+ assert plan['sample_frames'] == [0, 1, 12, 60, 123]+ assert len(plan['cases']) == 3+ assert plan['cases'][0]['prompt'] == plan['cases'][1]['prompt']+ assert plan['cases'][1]['prompt'] != plan['cases'][2]['prompt']+ assert (output / 'source.ppm').read_bytes().startswith(b'P6\\n768 1344\\n255\\n')+ try:+ d.main()+ except FileExistsError:+ pass+ else:+ raise AssertionError('existing evidence was overwritten')+print('ok')+`)).toContain('ok');+ });++ it('observes real pipeline boundaries without replacing tensors and restores hooks after decode failure', () => {+ expect(run(`${load}+features = SimpleNamespace(shape=(1, 20, 5120))+tags = SimpleNamespace(tolist=lambda: [0, 1, 1])+rows = SimpleNamespace(shape=(576, 96))+encode_result = (features, tags)+def fail_decode(*args):+ raise ValueError('decode failed')+def dit(*args, **kwargs):+ return rows+pipe = SimpleNamespace(text_encoder=SimpleNamespace(encode=lambda *a: encode_result),+ _encode_keyframes=lambda *a: rows, dit=dit,+ _decode_video=fail_decode, _decode_audio=lambda *a: rows)+report = {'timings': {}}+ticks = iter([10, 13])+restore = d.instrument(pipe, report, clock=lambda: next(ticks))+assert pipe.text_encoder.encode('motion', [object()]) is encode_result+assert pipe._encode_keyframes([object()], 1024, 576) is rows+video = SimpleNamespace(shape=(1, 1000, 96))+audio = SimpleNamespace(shape=(1, 414, 32))+positions = SimpleNamespace(shape=(1500, 3))+indices = SimpleNamespace(size=10)+assert pipe.dit(video, audio, features, None, None, tags, positions, indices, indices, indices) is rows+try:+ pipe._decode_video(rows)+except ValueError:+ pass+finally:+ restore()+assert pipe.dit is dit and pipe._decode_video is fail_decode+assert report['timings']['decode_video_seconds'] == 3+assert report['vae_conditioning_shape'] == [576, 96]+assert report['packed_conditioning']['position_shape'] == [1500, 3]+assert report['vision_conditioning']['token_tag_counts'] == {'0': 1, '1': 2}+print('ok')+`)).toContain('ok');+ });++ it('stops comparisons at a failed render and never starts the next GPU job', () => {+ expect(run(`${load}+calls = []+def fail(command, **kwargs):+ calls.append(command)+ assert kwargs['check'] is True+ assert kwargs['env']['HF_HUB_OFFLINE'] == '1'+ raise d.subprocess.CalledProcessError(1, command)+with tempfile.TemporaryDirectory() as root:+ try:+ d.run_cases(Path(root), Path('runtime'), d.experiment_cases(), run=fail)+ except d.subprocess.CalledProcessError:+ pass+ else:+ raise AssertionError('failure was swallowed')+assert len(calls) == 1+print('ok')+`)).toContain('ok');+ });+});