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
Merge remote-tracking branch 'origin/main' into claim/pipeline-audio-phase-4c-2-4c-3-4d-2-local-oss
[._.]/ Adam Eivy75ff0cc73bc5
diff --cc .changelog/NEXT.mdindex 844d0eef90,0aae2997c4..7f48a71945--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@@ -2,9 -2,8 +2,10 @@@## 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.+ - **[story-builder-issue-llm-seeding] Story Builder can now generate issues straight from the arc.** The issues step gains a "Generate issues from arc" button that breaks every season of your plot arc into episodes and creates one issue per episode — seeded with each episode's logline and synopsis — without leaving the builder for the Pipeline. Locked or empty seasons are skipped and reported rather than blocking the rest, and you can still plan issues in the Pipeline as before.- **[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 --cc PLAN.mdindex ae92cf83f3,4da330e194..3580544a8e--- a/PLAN.md+++ b/PLAN.md@@@ -55,10 -53,9 +53,10 @@@ Claimable, well-specified, no decision- [ ] [manuscript-review-sync] **Wire the manuscript-review comment set into cross-install sync.** `data/pipeline-series/{id}/manuscript-review.json` is written as a sibling of the series record but is NOT carried by `exportSeries`/`importSeries` or the peer-sync path. `manuscriptReview.mergeReviewFromSync(seriesId, remoteReview)` (LWW-per-comment) already exists; what's missing is (a) including the review document in the series export bundle, (b) a wire-schema-version gate in `server/lib/schemaVersions.js`, and (c) calling `mergeReviewFromSync` on the receiving side. Accepted *fixes* already sync (they write to issue stage outputs); only the comment list/status/dismissals don't propagate yet.- [ ] [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. Not a correctness bug, just an inconsistency. Add the same `providerMatchesSeries`-guarded provider/model resolution used by the extract-canon and extract-scenes routes.- [ ] [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).+ - [ ] [create-issue-preload-series-for-batch] **`createIssue`'s renumber pass re-reads the series on every call — preload it for batch episode seeding.** `createIssue` (`server/services/pipeline/issues.js`) calls `getSeries()` inside its `renumberInline` pass on every invocation. `commitEpisodesToIssues` (`server/services/pipeline/arcPlanner.js`) creates one issue per episode in a loop, so a 12-episode season does 12 redundant `getSeries()` reads of an unchanging record (and `generateIssuesFromArc` already fetched it once). Add a `createIssueWithPreloadedSeries(series, input)` variant (or a `{ preloadedSeries }` option) that threads the already-fetched series into `renumberInline`, and route the batch loop through it. Pre-existing in `createIssue` (the Pipeline season-episodes route pays the same cost); LLM-bound batch so the realized win is small — surfaced by /simplify (efficiency) during the story-builder-issue-llm-seeding PR (2026-06-01). Deferred because it touches the `issues.js` renumber internals beyond this diff's scope.+ - [ ] [extract-single-flight-map-helper] **Extract a shared single-flight / in-flight-coalescing helper.** Three sites now hand-roll the `Map<key, Promise>` "share the in-flight result, delete on settle" idiom: `server/lib/sseDownload.js` (`inFlight` keyed by repo, line ~12), `server/lib/promptRunner.js` (`_fallbackMarkAndPickInFlight` keyed by failed provider id), and the read-coalescing half of `server/lib/aiToolkit/providers.js#loadProviders` (`providersLoadInFlight`). A small `server/lib/singleFlight.js` (`createSingleFlight()` returning `run(key, fn)` that returns the shared promise and auto-clears on settle) would dedupe the boilerplate and standardize the cleanup. Note the three sites differ in shape — providers.js layers a TTL snapshot cache on top, promptRunner does keyed side-effectful work — so the helper must stay minimal (just the keyed coalesce) and not try to absorb the TTL/cache concern. Deferred from the coalesce-fallback PR: it's a new public lib module (barrel + README maintenance) that also touches an unrelated file, so it warrants its own PR. Surfaced by /simplify (reuse, 2026-06-01).## Blocked / Deferred (skip for `/claim`)