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
fix([flux2-multi-reference-python-runner]): address gemini review
[._.]/ Adam Eivy5514bc19952e
diff --git a/PLAN.md b/PLAN.mdindex 6d160418ea..078bdd93e8 100644--- a/PLAN.md+++ b/PLAN.md@@ -226,6 +226,8 @@ The first slice shipped a working **seed-mode** conductor (`/story-builder`): cr- [ ] [memory-mgmt-new-endpoint-tests] **Add tests for the 5 new memory-management routes.** `/api/local-llm/loaded`, `/api/local-llm/unload`, `/api/voice/whisper`, `/api/voice/tts/status`, `/api/voice/tts/unload` have no test coverage. The PR description claims "8062/8062 tests passing" — true for the existing suite, but no asserts pin the new wire contracts (response shapes, residency precondition, validation rejection). Add focused happy-path + validation-rejection tests so future regressions in the schema-parity fixes (or the `unloadModel` residency check) surface as test failures. Surfaced by /do:review of PR #516 (2026-05-28).- [ ] [qwen-image-edit-init-image-required] **Qwen-Image-Edit dispatches without its required init image.** `qwen-image-edit` (registry `mediaModels.js:202`) loads `QwenImageEditPipeline` which requires an `image` arg; the entry is exposed in the normal image-gen model picker which permits text-only submission. Today the user picks the model, submits a text prompt, and the runner crashes deep inside the diffusers pipeline after loading the 20B-param model from disk. Options: (a) add an `editOnly: true` flag to the model + validate at `routes/imageGen.js` POST; (b) filter the model from the picker when no source image is uploaded; (c) reroute through a future `/api/image-gen/edit` endpoint. Touches the image route schema + UI gating — defer to a focused PR. Surfaced by codex review of PR #516 (2026-05-28).- [ ] [hidream-requires-hf-token-fail-fast] **Probe HF token upfront for HiDream gated-encoder downloads.** `data.reference/media-models.json`'s HiDream entries carry `requiresHfToken: true` + a `licenseUrl` pointing at `meta-llama/Meta-Llama-3.1-8B-Instruct`, but `scripts/z_image_turbo.py` `load_external_text_encoder()` does NOT call `probe_hf_auth()` the way `flux2_macos.py:265` does for the base FLUX repo. A user without a valid HF token currently sees a multi-GB download attempt that fails with a 401 deep inside transformers instead of a clean upfront error. Mirror the FLUX.2 probe before invoking `transformers.from_pretrained()` on the gated encoder repo. Surfaced by /do:review of PR #516 (2026-05-28).+- [ ] [flux2-bf16-kv-multi-reference-support] **Lift the multi-reference gate on `flux2-klein-9b-bf16`.** `scripts/flux2_macos.py` (~line 280) refuses `--reference-images` on `quantization='none'` because the bf16 entry's `repo` is `black-forest-labs/FLUX.2-klein-9B` (the base 9B, not kv) — `Flux2KleinKVPipeline` would load fine (component init signatures match) but run K/V-cached reference attention against a transformer not tuned for the reference-editing task, producing off-task output. Either swap the bf16 entry's `repo` to `black-forest-labs/FLUX.2-klein-9B-kv` (which carries `flux-2-klein-9b-kv.safetensors` for the reference-tuned transformer) and ship a migration for existing installs, or thread an explicit `kvRepo` field through the runner so single-image and multi-reference renders can pull from different repos for the same logical model. Quality validation requires a 64+ GB machine to host the bf16 weights. Surfaced by gemini review of `[flux2-multi-reference-python-runner]` PR #524 (2026-05-28).+- [ ] [flux2-runner-sidecar-tests] **Test coverage for `generateImage`'s sidecar `meta` payload.** `server/services/imageGen/local.test.js` exercises `buildArgs` (CLI emission) but never asserts on the sidecar `meta` object built inside `generateImage` — including the new `referenceImageFilenames` + `referenceImageStrengthsRequested` fields added by `[flux2-multi-reference-python-runner]`. A focused test would need to either factor the meta-builder out of `generateImage` so it's callable without spawning Python, or stub the spawn + assert on the persisted sidecar JSON. Surfaced by gemini review of PR #524 (2026-05-28).- [ ] [reference-watch-default-prompt-version-bump-check] **Re-audit `DEFAULT_TASK_INTERVALS['reference-watch'].taskMetadata` whenever `PROMPT_VERSIONS['reference-watch']` changes.** The schedule default was flipped from `readOnly: true` → `false` on 2026-05-28 because the v2 prompt instructs the agent to append `[ref-watch-…]` items to PLAN.md and commit them — the read-only guard silently defeated that on every weekly cron firing (the on-commit `triggerReferenceAnalysis` path was already correct). A future v3 of the prompt that returns to a propose-only flow would need to flip the default back. Pin: `server/services/taskSchedule.js#DEFAULT_TASK_INTERVALS` reference-watch entry must stay in sync with the prompt's behavior; tests in `taskSchedule.test.js` and `referenceRepos.test.js` pin the current contract.## Future Ideasdiff --git a/scripts/flux2_macos.py b/scripts/flux2_macos.pyindex 0d4316890e..2340cc87f6 100755--- a/scripts/flux2_macos.py+++ b/scripts/flux2_macos.py@@ -276,17 +276,20 @@ def main() -> None:dtype = torch.bfloat16 if device in ("mps", "cuda") else torch.float32use_kv = bool(args.reference_images)- # The int8 path attaches a quanto-rehydrated transformer to the pipeline- # directly; the KV pipeline's reference-token attention hooks aren't- # guaranteed to fire correctly through that wrapper. Refuse early with a- # clear message rather than crash mid-inference. No shipped int8 model- # surfaces multi-ref via the UI today, but a curl caller could hit this.- if use_kv and args.quantization == "int8":+ # Multi-reference editing is gated to the SDNQ Disty0 quantization today.+ # The int8 path attaches a quanto-rehydrated transformer directly and the+ # KV pipeline's reference-token attention hooks don't compose through that+ # wrapper. The bf16 path loads from the gated base 9B repo (not the kv+ # variant) whose transformer wasn't tuned for the reference-editing task,+ # so the KV pipeline would run but produce off-task output. Both paths+ # should refuse early with a clear message rather than mislead. Lift this+ # gate per quantization once the corresponding KV pipeline is validated.+ if use_kv and args.quantization in ("int8", "none"):print(- "❌ Multi-reference editing (--reference-images) is not supported on "- "int8 quantization — Flux2KleinKVPipeline's reference-attention path "- "doesn't compose with the requantize'd transformer. Use the sdnq or "- "bf16 variant for multi-reference renders.",+ f"❌ Multi-reference editing (--reference-images) is not supported on "+ f"{args.quantization} quantization yet. Use the SDNQ variant "+ f"(flux2-klein-9b / flux2-klein-4b) for multi-reference renders; "+ f"PLAN tracks the bf16 + KV pin as a follow-up.",file=sys.stderr,)sys.exit(64)@@ -338,9 +341,17 @@ def main() -> None:seed = args.seed if args.seed is not None else int(torch.randint(0, 2**31 - 1, (1,)).item())generator = make_generator(device, seed)+ # `formats=` pins PIL's decoder dispatch to the route layer's allowed-mime+ # set — defense in depth against a Ghostscript-pipeline invocation via a+ # spoofed EPS/PDF magic in a file the upload filter validated only by+ # browser-supplied mimetype. The route already enforces .png/.jpg/.webp+ # extensions and copies bytes through, so a malformed file just fails the+ # decode cleanly here instead of routing into another format handler.+ PIL_FORMATS_ALLOWED = ["PNG", "JPEG", "WEBP"]+init_image = Noneif args.image_path and not use_kv:- init_image = Image.open(args.image_path).convert("RGB").resize(+ init_image = Image.open(args.image_path, formats=PIL_FORMATS_ALLOWED).convert("RGB").resize((int(args.width), int(args.height)), Image.LANCZOS)@@ -351,7 +362,7 @@ def main() -> None:reference_pils = Noneif use_kv:reference_pils = [- Image.open(p).convert("RGB").resize(+ Image.open(p, formats=PIL_FORMATS_ALLOWED).convert("RGB").resize((int(args.width), int(args.height)), Image.LANCZOS)for p in args.reference_images