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

docs([pipeline-audio-phase-4c-2-4c-3-4d-2-local-oss]): remove from PLAN.md and log to changelog

[._.]/ Adam Eivyebf8f43375fa
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index dfcc43679e..844d0eef90 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -2,6 +2,8 @@
## Added
+- **[pipeline-audio-phase-4c-2-4c-3-4d-2-local-oss] The pipeline audio stage can now generate background music locally, and voice-over lines are mixed into the final episode.** Background Music gains a "Generate (MusicGen)" option that renders a text-prompted track on-device via MusicGen on Apple Silicon — pick a model tier (Small / Medium / Large) and a clip length, and the result lands in your music library attached to the issue, no upload or API key needed (one-time setup: `INSTALL_MUSICGEN=1 bash scripts/setup-image-video.sh`; until then the panel shows an install hint). Each voice-over line also gets a "Start (s)" field that places it on the episode timeline, and when the final cut is stitched those rendered lines are now mixed in at their offsets — with any background music automatically ducked beneath the dialogue so speech stays clear. (Commercial music engines like Suno are intentionally not wired up yet.)
+
- **[conflict-journal-media-collections] Media collection name/description/cover edits are now protected when two machines change the same collection.** If a peer's edit to a collection's name, description, or cover image would overwrite a change you made independently, your version is archived to Sharing → Conflicts so you can review and restore it — the same safety net universes and series already had. Images filed into the collection were never at risk (both sides' images are always kept); only the collection's text/cover fields could silently lose an edit, and now they don't.
- **[local-llm-large-narrative-models] Local LLM install picker now suggests a large narrative / long-context tier.** Added Mistral Large 2 123B, Command R+ 104B, Llama 3.3 70B, Qwen3 30B-A3B, and Google Gemma 4 (31B dense + 26B-A4B MoE, both 256K context, vision) to the curated catalog — workstation-class (64–128GB unified memory) models suited to whole-manuscript editorial review where prose quality and a long context window matter most. Verified Ollama pull ids and sizes; the Gemma 4 builds also ship MLX variants (`gemma4:31b-mlx` / `gemma4:26b-mlx`) for faster inference on Apple Silicon. Qwen3 235B is intentionally omitted (142GB won't fit 128GB).
- **[context-aware-editorial-budgeting] Manuscript editorial passes now scale to the target model's context window — whole-manuscript when it fits, chunked when it doesn't.** A new `contextBudget` helper plus a `contextWindow` provider field (inferred large for frontier CLI/cloud providers, from `numCtx` for local Ollama) drive all three passes: the completeness pass ("Finish the draft"), manuscript-fix ("Generate fix"), and per-issue editorial analysis. Big-context models (Claude 4.8 ~1M, GPT 5.5) now receive the entire manuscript in one call instead of being capped at the old hardcoded 200K/48K-char limits; models too small to hold the book chunk by issue — completeness feeds each chunk a digest of prior-chunk findings for cross-chapter continuity and merges with first-wins dedupe, manuscript-fix concatenates per-chunk edits — instead of silently truncating. The completeness/fix API responses now report `chunked` + `chunkCount`, and the Manuscript Editor shows a "Reviewed in N chunks" badge (with an explanatory tooltip) when a review had to chunk. Design record: `docs/plans/2026-05-31-context-aware-manuscript-editorial.md`.
diff --git a/PLAN.md b/PLAN.md
index 306d19d132..ae92cf83f3 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -57,14 +57,15 @@ Claimable, well-specified, no decision needed — `/claim`-able. Unordered.
- [ ] [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`. On `peer:online`, `retryPendingPushesForPeer` walks them, `loadOne` returns null, and the push no-ops (harmless but inflates the "retrying N pending pushes" count). Add an orphan-subscription sweep (drop subs whose `recordKind/recordId` no longer resolves) to the tombstone GC path.
- [ ] [coalesce-fallback-provider-failure-storm] **Coalesce duplicate fallback work during an N-way provider-failure storm.** When a stuck provider has N simultaneous in-flight calls, each failure independently runs `pickFallbackProvider` → `getAllProviders()` → `loadProviders()` (reads `providers.json` from disk every time — no in-memory cache) → `markUnavailable` (writing `provider-status.json`). Two compounding fixes: (a) add a tiny TTL cache (~1s) to `aiToolkit/providers.js#loadProviders`; (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. Acceptance: under a simulated 10-concurrent-failure load, providers.json is read at most twice and provider-status.json is written once. Surfaced by /simplify during the ai-fallback PR (2026-05-22).
- [ ] [extract-use-universe-load-hook] **Extract a `useUniverse(universeId)` load hook.** `client/src/components/pipeline/stages/StoryboardsStage.jsx` (~line 57) and `NounsStage.jsx` (~line 149) now run a byte-identical `useMounted` + `let cancelled` + `getUniverse(series.universeId).then(...).catch(...)` effect to load the linked universe record. Extract a `client/src/hooks/useUniverse.js` returning `[universe, loading, error]` (handling the mount/cancel guards internally), register it in the hooks `index.js` barrel + README, and migrate both call sites. Deferred from the wardrobe-picking PR: migrating `NounsStage` is outside that diff's scope and the new module trips the barrel maintenance rule. Surfaced by /simplify (reuse, 2026-06-01).
+- [ ] [vo-mux-preserve-clip-audio-under-ducked-vo] **Preserve + duck stitched-clip audio under VO.** `muxVoLines` (`server/services/pipeline/audioMux.js`) currently *replaces* the episode's audio track with the VO mix (+ optional ducked music bed), matching the prior `muxMusicBed` behavior. AI-gen clips are silent today, but LTX-2 audio-to-video can carry a clip soundtrack that this drops. Mix the stitched video's `0:a` into the final graph as a third `amix` input, ducked under VO via the same sidechain key. Deferred from the 4d.2 PR to keep the initial filter graph bounded. Surfaced during implementation (2026-06-01).
- [ ] [wardrobe-appearance-id-route-validation] **Validate `characterAppearances` ids against the linked universe at the persistence boundary.** The generic `POST /issues/:id/stages/:stageId/visual` route (`visualGenerateSchema` in `server/routes/pipeline.js`) accepts `characterAppearances` and validates only shape (`characterId`/`wardrobeId` are non-empty strings), not that the ids actually resolve to a canon character + one of its wardrobes. Today `buildScenePrompt`'s defensive read silently drops unresolved picks (matches the existing scene pass-through convention for `shots`), so this is robustness/clarity, not correctness. If tightened later, resolve the ids against `loadBibleContext(issueId).canon.characters` at the route and 400 on a dangling id rather than relying on the prompt-builder's silent drop. Surfaced by /simplify (altitude, 2026-06-01).
## Blocked / Deferred (skip for `/claim`)
Items here need a user decision, design pass, code precondition, hardware validation, or future priority signal before they become claimable. Keep this section at the bottom so `/claim` works from the backlog downward.
-- [ ] [pipeline-audio-phase-4c-2-4c-3-4d-2-local-oss] **Pipeline Audio Phase 4c.2/4c.3/4d.2.** Local OSS music gen (MusicGen sidecar; pick generator first); 3rd-party engine stubs; VO line muxing into the CD stitch with per-line offsets + music-bed ducking.
- > ❓ **Question:** Which local OSS music generator should the sidecar use? **Recommendation: MusicGen** (Meta; MLX-portable, runs locally, bounded ~30s clips, well-supported) for the first slice, with AudioLDM2 as a possible second backend and a commercial API (Suno, duration control) deferred to the 3rd-party-stub phase. Confirm MusicGen, or name a different starting generator.
+- [ ] [music-gen-3rd-party-engine-stubs] **3rd-party music engine stubs (Suno / AudioLDM2).** Phase 4c.2 shipped local MusicGen (MLX) only — the `audioStage` `music.source: 'gen'` path and `server/services/pipeline/musicGen.js`'s `generateMusic` contract are deliberately generator-agnostic, so a commercial backend (Suno, with real duration control) or a second local backend (AudioLDM2, long-form) plugs in as a sibling generator behind the same route. Deferred per the product call ("no 3rd party yet"). Needs: a provider abstraction + key management for Suno, or an AudioLDM2 sidecar mirroring `scripts/generate_musicgen.py`.
+ > ❓ **Question:** Which engine first when this is picked up — a long-form local backend (AudioLDM2) or a commercial API (Suno, real duration control + key management)?
- [ ] [whole-episode-audio-generation-strategy-stop] **Whole-episode audio generation strategy.** Stop relying on per-clip audio; drive audio gen from episode-level prose/script arc. New `audioMode: 'per-clip' | 'silent' | 'generated' | 'uploaded-track'`. Treat as a new sub-brainstorm when picked up — investigation first.
> ❓ **Question:** Two decisions gate this: (1) which generator family — local-bounded (MusicGen-MLX, ~30s), local long-form (AudioLDM2), or commercial (Suno, real duration control)? and (2) at what granularity does episode-level audio drive — one track per episode, per-scene beds, or per-arc cues? Pick a generator + granularity and I'll scope the `audioMode` design from there.
- [ ] [world-builder-phase-2-external-sd-api-per-bucket] **World Builder Phase 2 — external SD-API + per-bucket model overrides.** Wire Together / Replicate / Fal into the world-builder batch path so high-end renders are practical; let each bucket pick its own model.