Skip to content

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

address review (gemini): guard storyboards extract-scenes against foreign provider/model pairing

[._.]/ Adam Eivyeec75e7c5fa4
diff --git a/PLAN.md b/PLAN.md
index 676eee2e0c..f491d57f88 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -225,5 +225,5 @@ The first slice shipped a working **seed-mode** conductor (`/story-builder`): cr
- **Workflow tab Phase 2** — drag-and-drop ordering of stages, custom user-defined stages, per-app workflow overrides.
- **Inspiration & Mood Board Canvas** — dedicated mood-board surface for collecting visual + textual references that feed into Universe Builder, Writers Room, and Creative Director (distinct from raw Media History). Items can be pinned from any media surface; canvas surfaces ref images when starting a new universe / scene / treatment. Documented as a Secondary Goal in GOALS.md but had no tracking.
- **Generative regen path for SynthID defeat (image cleaner) — research/backlog, hardware-gated.** Current `cleanImageBuffer` (`server/lib/imageClean.js`) only strips the C2PA `caBX` chunk + runs `median(3).sharpen()` — SynthID survives by design (verified 2026-05-20 against codex output: post-clean image reads as `C2PA removed, SynthID detected` on openai.com/synthid). The detector heatmap that OpenAI's verifier renders is a one-way correlation map `∫ image · template`, not the watermark template itself — so deterministic image-processing approaches (subtracting the heatmap, overlaying a second "PortOS SynthID," frequency-band cancellation) can't work without the secret key. The only honest defeat path is to round-trip pixels through a generative model: short-step img2img (low step count + low–moderate denoise, ~0.35–0.5) on a local FLUX runner so composition holds but the per-pixel watermark signal is overwritten by fresh sampling. **Scope narrowed (2026-05-20):** post-hoc, history-only. Surface as a second button next to "Clean (aggressive)" on the image-settings/lightbox modal — never auto-applied, never wired into the active gen flow, no per-render checkbox. Each run is ~5–15s on local mflux and GPU/unified-memory heavy; wants its own queue lane. Sidecar records `regenerated: true, regenSteps: N, regenStrength: 0.4, regenModelId: 'flux-v1'` so lineage stays honest. **Hardware-gated** — defer until the 128GB unified-memory machine arrives; current dev hardware can't comfortably host the local diffusion runner alongside the rest of PortOS. Pull in only after that hardware is online and the user wants to play with it. UX caveat: this is the only honest watermark-defeat path; the existing C2PA-strip-and-denoise will always be a no-op against SynthID and should never be relabeled as a watermark stripper.
-- [ ] [extract-scenes-provider-model-pairing] **Storyboards `extract-scenes` can pair an override provider with a stale series model.** `server/routes/pipeline.js:1466-1467` (the storyboards extract-scenes route) does `providerOverride: body.providerOverride || series.llm?.provider`, `modelOverride: body.modelOverride || series.llm?.model` — so a request that overrides the provider but omits the model inherits `series.llm.model`, which may belong to a different provider (a model id is provider-specific). Same class of bug fixed for the canon `extract-canon` route in the canon-extraction-failure-retry PR (only inherit the series model when the effective provider matches the series provider). Pre-existing; left out of that PR to keep it focused. Apply the same `providerMatchesSeries` guard here and add a route test. Surfaced by the codex reviewer during that PR (2026-05-30).
+- [ ] [season-continuity-extract-honors-series-llm] **Season-episodes continuity extract doesn't honor the series LLM (or a model override).** The continuity `extractCanonFromProse` call in `generateSeasonEpisodes` (`server/routes/pipeline.js`, the `if (body.commit)` block) passes only `providerOverride: body.providerOverride` — no `series.llm` fallback and no `modelOverride` — so it falls back to the global active provider instead of the series-pinned LLM the rest of the pipeline honors. Not a correctness bug (no foreign-model pairing), just an inconsistency. Add the same `providerMatchesSeries`-guarded provider/model resolution used by the extract-canon and extract-scenes routes (after confirming the season route schema carries `modelOverride`). Surfaced by the gemini reviewer during the canon-extraction-failure-retry PR (2026-05-30).
- [ ] [prune-orphan-subscriptions-for-deleted-records] **Sweep orphaned peer subscriptions left by tombstone prune.** `pruneTombstonedUniverses` / `pruneTombstonedSeries` rm the record dir but leave its rows in `data/peer_subscriptions.json`. After the 2026-05-23 leaked-fixture cleanup (22 universes force-pruned), the matching subs are now orphaned — on `peer:online`, `retryPendingPushesForPeer` walks them, `loadOne` returns null, and the push no-ops (harmless but inflates the "retrying N pending pushes" count — saw 141). Add an orphan-subscription sweep (drop subs whose `recordKind/recordId` no longer resolves to an on-disk record) to the tombstone GC path, or call it from the prune helpers. Low urgency; cosmetic + minor wasted work per sync cycle. Surfaced by /simplify efficiency review during the ai-fallback PR (2026-05-22). When a stuck provider has N simultaneous in-flight calls, each failure independently runs `pickFallbackProvider` → `getAllProviders()` → `loadProviders()` (which reads `providers.json` from disk every time — no in-memory cache) → `markUnavailable` (writing `provider-status.json`). Two fixes that compound: (a) add a tiny TTL cache (~1s) to `aiToolkit/providers.js#loadProviders` so the read cost is amortized; (b) coalesce per-provider failure handling in `promptRunner.js` with a `Map<providerId, Promise>` so subsequent failures for the same provider await the first's mark-and-pick result and skip the duplicate work. Together they cut N-way failure storms to one disk-write + one mark. Acceptance: under a simulated 10-concurrent-failure load, providers.json is read at most twice and provider-status.json is written once. <!-- NEEDS_INPUT -->
diff --git a/server/routes/pipeline.js b/server/routes/pipeline.js
index f7afece0b7..fb908a15f1 100644
--- a/server/routes/pipeline.js
+++ b/server/routes/pipeline.js
@@ -1454,6 +1454,13 @@ router.post('/issues/:id/stages/storyboards/extract-scenes', asyncHandler(async
// with empty canon — extractScenes can still produce scenes from the
// source text alone, just without character/place/object grounding.
const canon = await getSeriesCanon(series);
+ // A model id is provider-specific, so only inherit the series model when the
+ // effective provider is still the series provider — otherwise an override
+ // provider would be paired with a foreign model id and fail (same guard as
+ // the extract-canon route). When the override switches providers without
+ // naming a model, leave it blank so the new provider's default resolves.
+ const sceneProviderMatchesSeries = !body.providerOverride
+ || body.providerOverride === (series.llm?.provider || '');
const result = await extractScenes({
source,
sourceKind,
@@ -1464,7 +1471,9 @@ router.post('/issues/:id/stages/storyboards/extract-scenes', asyncHandler(async
series: { name: series.name, styleNotes: series.styleNotes },
issue: { number: issue.number, title: issue.title },
providerOverride: body.providerOverride || series.llm?.provider || undefined,
- modelOverride: body.modelOverride || series.llm?.model || undefined,
+ modelOverride: body.modelOverride
+ || (sceneProviderMatchesSeries ? series.llm?.model : undefined)
+ || undefined,
tag: `pipeline-storyboards-extract-${sourceKind}`,
});
diff --git a/server/routes/pipeline.test.js b/server/routes/pipeline.test.js
index e658e5d729..b70f04db96 100644
--- a/server/routes/pipeline.test.js
+++ b/server/routes/pipeline.test.js
@@ -897,6 +897,30 @@ describe('pipeline routes', () => {
spy.mockRestore();
});
+ it('POST /issues/:id/stages/storyboards/extract-scenes does NOT pair a new providerOverride with the stale series model', async () => {
+ const extractor = await import('../lib/sceneExtractor.js');
+ const spy = vi.spyOn(extractor, 'extractScenes').mockResolvedValue({
+ extracted: { title: 'T', logline: 'L', scenes: [] },
+ runId: 'r', providerId: 'mock', model: 'mock-model',
+ });
+ const app = makeApp();
+ const uni = await universeSvc.createUniverse({ name: 'U' });
+ const ser = await request(app).post('/api/pipeline/series')
+ .send({ name: 'S', universeId: uni.id, llm: { provider: 'codex', model: 'gpt-5-codex' } });
+ const iss = await request(app).post(`/api/pipeline/series/${ser.body.id}/issues`).send({ title: 'I' });
+ await request(app).patch(`/api/pipeline/issues/${iss.body.id}`).send({
+ stages: { teleplay: { status: 'ready', output: '## TEASER\n\n**INT. VAULT — NIGHT**\n\nThey break in.' } },
+ });
+ const r = await request(app)
+ .post(`/api/pipeline/issues/${iss.body.id}/stages/storyboards/extract-scenes`)
+ .send({ from: 'teleplay', providerOverride: 'anthropic' });
+ expect(r.status).toBe(200);
+ // Provider switched to anthropic — the codex model must NOT ride along.
+ expect(spy.mock.calls[0][0].providerOverride).toBe('anthropic');
+ expect(spy.mock.calls[0][0].modelOverride).toBeUndefined();
+ spy.mockRestore();
+ });
+
it('POST /issues/:id/stages/storyboards/extract-scenes with from=prose routes to the prose stage output', async () => {
const extractor = await import('../lib/sceneExtractor.js');
const spy = vi.spyOn(extractor, 'extractScenes').mockResolvedValue({