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-visual-stages-setting-field-injection
[._.]/ Adam Eivy03ab75bb4a0b
diff --cc DONE.mdindex 164955c4e8,46867982b9..74f4e27094--- a/DONE.md+++ b/DONE.md@@@ -8,12 -8,10 +8,14 @@@ For active roadmap see [PLAN.md](./PLAN## 2026-05+### 2026-05-19++- **[pipeline-visual-stages-setting-field-injection] Inject setting `palette`/`era`/`weather`/`recurringDetails` into visual stages.** Visual prompts now pull the full RICH place descriptor set (description + Palette + Era + Weather + recurringDetails) instead of the SHORT subset (description + Palette + recurringDetails) — era + weather are continuity-critical visual cues that diffusion models weight strongly for lighting, atmosphere, and period dress, and they were already wired through the bible schema + LLM extraction but silently dropped at the visual-prompt boundary. Two surfaces touched: (1) `buildScenePrompt` in `server/lib/scenePrompt.js` + the client mirror at `client/src/lib/scenePrompt.js` swap `shortCanonDescriptorFragments('place', …)` for `richCanonDescriptorFragments('place', …)`, so storyboard scene renders (via `composeVisualPrompt` in `visualStages.js`) AND Writers Room's `SceneCard.jsx` pick up era/weather; (2) `composeComicPagePrompt`'s hand-rolled multi-place clause is replaced with the same `richCanonDescriptorFragments` helper, so the per-page `Setting — Place: description. Palette: X. Era: Y. Weather: Z. recurringDetails` shape is consistent with the scene-prompt path. The capital-cased `Palette:` prefix replaces the previous lowercase `palette:` in comic-page output as a side-effect of the shared helper (RICH_SPEC's uniform capitalization convention). UI card summaries (`KINDS[].descFor` in `UniverseCanonSection`) still use the narrower SHORT spec — those don't drive renders, so widening would just clutter the bible. Truncation order under tight budget pressure: description survives longest; recurringDetails drops first, then weather, era, palette — the priority order documented in `buildScenePrompt`'s header comment. Coverage: 2 new tests in `scenePrompt.test.js` (RICH frags pinned in display order; era/weather omitted when blank) + 3 new tests in `visualStages.test.js` for `composeComicPagePrompt` (full RICH injection + order; blank-field skip without bare prefixes; multi-place ` | `-join). All 5661 server tests + 103 client tests pass; client build clean. Two `/simplify` follow-ups deferred to PLAN.md: `[extract-flatten-canon-descriptor-fragments-helper]` (collapse the 4-site `.map(f => prefix ? ...).join(...)` pattern) and `[cleanplateprompt-migrate-to-rich-canon-fragments]` (sibling visual-prompt surface still on SHORT spec).+### 2026-05-18+ - **[per-season-and-per-field-locks-extend-arc-lock] Per-season editorial locks.** Extends the existing series-level arc lock to a per-volume editorial freeze. New `season.locked: boolean` field on each season record (`server/lib/storyArc.js#sanitizeSeason`, default `false`, strict-true coercion so a `locked: 'yes'` typo can't accidentally freeze a volume), opt-in through the existing `seasonSchema.passthrough()` in `server/routes/pipeline.js` (explicit `.locked z.boolean().optional()` per the CLAUDE.md "all inputs validated" convention). Three rewriter gates fire on `locked === true`: (1) `arcPlanner.generateSeasonEpisodes` refuses before any LLM call — same `ERR_VALIDATION` code as the existing arc-lock for symmetry; (2) `issuesSvc.bulkReassignSeason` refuses to move issues OUT of or INTO a locked volume (new `ERR_SEASON_LOCKED` code, mapped to HTTP 409) — checks the latest season state inside `queueIssueWrite` even though the source-of-truth is on the *series* file (which has its own queue), since the per-season-lock toggle isn't a hot path and a stale read here would let a single race window leak in; (3) `seasonsSvc.deleteSeason` refuses (new `ERR_LOCKED` code, also 409). The `updateSeason` content-patch gate uses a `LOCKED_SEASON_ALLOWED_KEYS = { locked, status }` allow-list — `locked` itself must always be patchable (otherwise the user can't unlock), and `status` is orthogonal to editorial content (the production workflow can flip `verified`→`in-production` while the editorial body stays frozen). A patch that includes `locked: false` lets the UI offer "unlock + edit" as one round-trip; any other content key on a still-locked season throws `ERR_LOCKED` with the forbidden field list in the message. `seasonsSvc.deleteSeason` passes its already-loaded series into `bulkReassignSeason` via a new `_preloadedSeries` option so the lock check skips the duplicate file read (same micro-opt as the cover-filer dispatcher in DONE for `[coverautofiler-dispatcher-redundant-getseries]`). UI: `ArcCanvas.jsx#SeasonRow` gains a Lock/Unlock toggle button in the header (mirrors the page-level arc-lock button's visual idiom — `border-port-warning/40 text-port-warning` accent when locked, `border-port-border text-gray-400` unlocked, Loader2 spinner on the in-flight PATCH); the trash button gates on `seasonLocked` with a "unlock to delete" tooltip; `SeasonEditor` flips all six content inputs to `disabled` + `opacity-60` (status select stays editable, save button stays enabled and only PATCHes `{ status }` so the server gate never fires on an attempted-no-op); `SeasonActions` disables the "Generate issues / episodes (LLM)" button with a "unlock to generate" tooltip; a new locked-state banner (`Lock` icon + "Volume locked — generation, delete, and content edits are blocked. Unlock above to make changes.") renders under the season header so the user has one canonical place to read the freeze status. `PipelineIssue.jsx` finds the parent season via the existing `series.seasons` array on first render and surfaces the lock as both (a) a trailing `<Lock>` icon in place of the per-stage status dot across the entire TabPills strip and (b) a sub-header pill with the unlock-on-arc-canvas hint — covers the PLAN's "surface a stage-progress strip" ask without duplicating any state-fetch (issue page already loads its series for the LLM picker). New tests: 5 in `seasons.test.js` (toggle on+off, content-patch refused, status flip allowed on locked, unlock+edit in one patch, delete refused), 3 in `issues.test.js` (out-of-locked refused, into-locked refused, post-unlock allowed), 1 in `arcPlanner.test.js` (generateSeasonEpisodes skips LLM when locked), 1 in `storyArc.test.js` (sanitizer default + truthy-non-boolean rejection). All 5666 server tests + 103 client tests pass; client build clean. Two follow-ups deferred to PLAN.md: `[per-field-locks-arc-and-stage-granularity]` (per-arc-field granularity + per-issue-stage locks — the more complex half of the original PLAN scope) and `[season-lock-aware-arc-resolve]` (teach `resolveVerifyIssues` to either refuse on locked seasons or preserve locked-season payloads in `commitSeasonsWithRemap`).+ - **[pipeline-idea-stage-character-detail-plumbing] Plumb richer character bible into idea-stage prompt + extract migration scaffold.** Three slugs landed in one PR. (1) `data.sample/prompts/stages/pipeline-idea-expansion.md`'s `{{#series.characters}}` iteration now matches the prose/comicScript/teleplay templates verbatim: `**{{name}}**{{#role}} ({{role}}){{/role}} — {{#physicalDescription}}{{physicalDescription}}{{/physicalDescription}}{{^physicalDescription}}{{description}}{{/physicalDescription}}{{#personality}} | personality: {{personality}}{{/personality}}{{#background}} | background: {{background}}{{/background}}`. The beat-sheet LLM now sees the same character interiority + role that downstream stages see, so arc decisions made at idea-stage don't lose context the bible already carries. New migration `scripts/migrations/025-idea-stage-character-detail.js` rewrites any of three legacy shipped hashes (pre-003, post-003/pre-004, post-004/pre-025) onto the new shape; customized installs get a manual-merge warning. `scripts/setup-data.js` drift table updated in parallel (`1ee44cf95851ff8debf18729ebcd40b4` appended to the auto-updatable OLD list, NEW bumped to `1f3c5d077a5ef9a4b610335d5e3edd9c`). (2) `[extract-migration-scaffolding-into-scripts]` shipped — `scripts/migrations/_lib.js` exposes `md5`, `applyPromptReplaceMigration({ rootDir, accepted, current, label, customizedHint })`, and `makePromptReplaceMigration({ accepted, current, label, customizedHint, skipFooter? })` returning `{ applyMigration, up }`. Per-migration files collapse to ~50 LOC of hash table + label + hint. (3) `[extract-migration-test-helpers]` shipped — `scripts/migrations/_testHelpers.js` exposes `md5` (re-exported from `_lib.js`), `repoRoot`, `sampleBody(filename, subdir?)`, `customizedBody(filename)`, and a `runPromptMigrationTests({ migration, applyMigration, ACCEPTED_OLD_MD5, NEW_SHIPPED_MD5, prefix, subdir? })` describe-block builder that fires the six standard cases (missing-file no-op / idempotent / drift-catch / synthetic-OLD upgrade / customized preservation / hash-table shape) inside the surrounding describe. Per-migration test files collapse to a single `runPromptMigrationTests` call. Migration 023 refactored as proof-of-pattern: source went 130→58 LOC, test went 113→21 LOC. `scripts/run-migrations.js` filter gained `&& !f.startsWith('_')` so the shared helpers stay out of the migration sequence; new `scripts/run-migrations.test.js` regression case pins the exclusion against a phantom `_lib.js` fixture. All 257 server test files (5663 tests) + 48 migration/runner tests pass. Three `/simplify` follow-ups deferred to PLAN.md: `[backport-pre-023-migrations-to-_lib]` (collapse the other six prompt-replace migrations onto `_lib.js`), `[setup-data-import-drift-tables-from-migrations]` (drop the hand-mirrored hash tables in `setup-data.js` once every migration exports them), and `[parallelize-applypromptreplacemigration-files]` (theoretical, for the first multi-file migration).- **[coverautofiler-dispatcher-redundant-getseries] `fileCoverIntoAutoCollection` dispatcher — pass preloaded series into the universe leaf.** `server/services/pipeline/coverUniverseFiler.js`'s dispatcher now forwards its already-fetched series to `fileCoverIntoUniverseCollection` via an optional `_preloadedSeries` arg; the universe leaf accepts the preload, skips its initial `getSeries`, and preserves the mid-flight race-detection re-read. Net effect for the dominant (universe-linked) path: 2 `getSeries` calls per cover completion instead of 3. The series leaf intentionally does NOT accept a preload — its own first read is load-bearing for the early re-route check (a universe link added between the dispatcher's fetch and the leaf's entry must trigger the re-route into the universe leaf, otherwise the cover would land in the per-series collection and merely get orphaned by the post-`addItem` recovery instead of filed to the universe). Direct callers of the universe leaf (no preload) keep the old shape via a `?? await getSeries(...).catch(() => null)` fallback. +1 test in `coverUniverseFiler.test.js` spies on `seriesSvc.getSeries` and pins the post-optimization universe-path call count (2 total) via the capture-restore-assert pattern so a failing assertion doesn't leak the spy. All 21 cover-filer tests + 349 pipeline-service tests pass.- **[importer-canonprompt-preview-fragments-helper] Share a per-kind preview-fragments helper between Importer and `canonPrompt.js`.** New `previewCanonFragments(kind, entry)` helper in the mirrored `server/lib/canonPrompt.js` + `client/src/lib/canonPrompt.js` returns `{ subtitle, body }` where `subtitle` is a single trimmed string and `body` is an ordered `[{ field, value }]` array of non-blank fields. Backed by a new `PREVIEW_SPEC` keyed by canonical kind name (`characters` → `{ subtitleField: 'role', bodyFields: ['physicalDescription','personality','background'] }`, `places` → `{ subtitleField: 'slugline', bodyFields: ['description'] }`, `objects` → `{ subtitleField: null, bodyFields: ['description','significance'] }`). Intentionally wider than `shortCanonDescriptorFragments` (which is scoped to the visual subset that drives render-prompts) — preview exists so the user can disambiguate which entry to commit, so it surfaces narrative-only fields (`personality`, `background`, `slugline`) that have no visual role. The three `CanonReviewSection` callsites in `client/src/pages/Importer.jsx` no longer pass `renderSubtitle`/`renderBody` props — `CanonReviewSection` now calls the helper directly with the `kind` prop it was already passing, collapsing 18 lines of inline ternaries + filter/join calls onto a single helper invocation. 11 new vitest cases in `server/lib/canonPrompt.test.js` cover null/non-object/unknown-kind edge shapes, kind plural/singular passthrough, per-kind field-presence semantics (characters: role subtitle + 3-field body, no description fallback; places: slugline + description only; objects: empty subtitle + description+significance), whitespace trimming, and confirms RICH-only fields (palette/era/weather/recurringDetails) are NOT in preview. PLAN.md's `'places' → 'settings'` alias note was stale — codebase already canonicalized on `'places'` as the kind name (`normalizeKind` returns `'places'` correctly), so no alias work was needed. All 5608 server tests + 92 client tests pass.- **[resolve-issues-inherits-verify-gaps-verify-the] Resolve-issues inherits verify gaps.** The auto-resolve LLM pass (`pipeline-arc-resolve.md`) was receiving per-episode `synopsis` strings via `seasonsTreeJson.episodes[].synopsis` (wired in `buildVerifyContext` and inherited by `buildResolveContext`) but its "How to resolve" instructions never told the LLM to use them — only the sibling verify prompt ("Did a character die in episode 4 but get dialogue in episode 7?") called the data out by name. As a result the resolve pass could rewrite a volume's `synopsis` in ways that contradicted what its child episodes already described. Added a new first bullet to `data.sample/prompts/stages/pipeline-arc-resolve.md` that pins the LLM to treat episode synopses as ground truth: volume-level synopsis rewrites must summarize what the child episodes describe, can't invent beats no episode covers, can't paper over contradictions that originate at the episode level, and when a finding cites an episode (e.g. `season:2 / episode:5`) the fix means re-framing the volume around what that episode already shows. Empty/null episode synopses are called out as the "user hasn't drafted that issue yet" signal so the LLM doesn't infer the volume has no content. New migration `scripts/migrations/023-resolve-prompt-episode-anchor.js` rewrites the installed prompt for any of three legacy shipped hashes (pre-005, pre-019, post-019); customized installs get a manual-merge warning. Migration 019's `NEW_SHIPPED_MD5['pipeline-arc-resolve.md']` bumped to the new post-023 live-sample hash so fresh installs (where `data/` is seeded from the latest sample) report `alreadyCurrent` instead of a misleading "customized" warning; the comment block above 019's table now documents the convention that later migrations re-touching a file must bump 019's entry too. `scripts/setup-data.js` drift table updated in parallel (`8e348f3d...` appended to the auto-updatable OLD list, NEW bumped to `5b340885...`). 6 new tests in `023-resolve-prompt-episode-anchor.test.js` cover missing-file no-op, idempotent re-run, drift-catch against the live sample, OLD→NEW upgrade via synthetic fixture, customized-file preservation, and table shape consistency. All 5604 server tests + 28 migration tests pass. Two `/simplify` follow-ups deferred to PLAN.md: `[extract-migration-scaffolding-into-scripts]` expanded to flag that 023 is the fourth clone of the migration scaffold, and new companion item `[extract-migration-test-helpers]` for lifting the test scaffold (md5 helper, repoRoot/sampleBody/customizedBody, mkdtemp seed beforeEach, 5 shared test bodies) alongside `_lib.js`.diff --cc PLAN.mdindex 75169ab245,1c6a003f98..6231b80094--- a/PLAN.md+++ b/PLAN.md@@@ -30,12 -25,11 +25,10 @@@ _Nothing currently parked — pick the- [x] ~~**arcPlanner prompt context — include canon characters/places/objects.**~~ Shipped via the Universe Builder redesign Phase B (`renderCanonForPrompt(world)` + `worldCanonText` + migration 019 for `pipeline-arc-overview`, `pipeline-arc-verify`, `pipeline-arc-resolve`, `pipeline-volume-verify`). Follow-up still open: sweep `grep -rn "world\.categories" server/services/pipeline server/services/universeBuilder*.js` for other prompt builders that read categories but not canon.- - [ ] [use-rendered-reference-images-as-i2i-anchors-in] **Use rendered reference images as i2i anchors in downstream comic-page renders for models that support it.** SDXL/Flux pipelines anchor every panel render on the per-character rendered ref.-### Pipeline continuity / approval- - [ ] [per-season-and-per-field-locks-extend-arc-lock] **Per-season + per-field locks.** Arc-level lock shipped (`LOCKABLE_STAGES = ['arc']` in `server/services/pipeline/series.js:59`, enforced at `server/services/pipeline/arcPlanner.js:231`); extend to seasons and per-field. Gate bulk runners (`bulkReassignSeason` at `server/services/pipeline/issues.js:418` has no lock check today). Surface a stage-progress strip in `client/src/pages/PipelineIssue.jsx`.- - [ ] [pipeline-idea-stage-character-detail-plumbing] **Plumb character `physicalDescription`/`personality`/`background` into idea-stage prompt.** Today `data.sample/prompts/stages/pipeline-idea-expansion.md:16` iterates `{{#series.characters}}` with `name`/`description` only — richer bible fields are dropped.+ - [ ] [per-field-locks-arc-and-stage-granularity] **Per-field locks for arc and per-stage locks on issues.** Follow-on to `[per-season-and-per-field-locks-extend-arc-lock]` (per-season locks shipped). Two remaining ratchets: (1) per-field arc locks — let `series.locked` carry a sub-map (`{ arc: true, arcFields: { logline: true, themes: true } }`) so `resolveVerifyIssues` and `commitSeasonsWithRemap` can rewrite unlocked fields while preserving locked ones. (2) per-stage locks at the issue level — add `issue.stages.{id}.locked: boolean` so the user can freeze a finalized comic-script while still iterating the storyboard. Wire the trailing Lock indicator on `PipelineIssue.jsx`'s TabPills strip per-stage (currently shows arc/season-level lock for the whole strip).+ - [ ] [season-lock-aware-arc-resolve] **Make `resolveVerifyIssues` respect per-season locks.** Today the arc-level lock blocks resolve entirely. With per-season locks landed (the parent slug above), a user can unlock the arc but keep individual seasons frozen; auto-resolve would currently rewrite locked season metadata via `commitSeasonsWithRemap` → `updateSeries({ arc, seasons })`. Either (a) refuse resolve up-front with a "seasons X, Y are locked — unlock or skip" error, or (b) teach `commitSeasonsWithRemap` to preserve `locked` season payloads field-for-field on merge.-- [ ] [pipeline-visual-stages-setting-field-injection] **Inject setting `palette`/`era`/`weather`/`recurringDetails` into visual stages.** Storyboard/comic-panel prompts mention these in prose instructions but don't hydrate them from the matched bible entry. Tie this to the bible-SETTING→PLACE rename (`existingPlacesJson` carries them once that lands).- [ ] [pipeline-text-stages-worldentitiessummary] **Add `worldEntitiesSummary` to text stages.** Zero occurrences in codebase today; a one-string canon synopsis (top-N entities by frequency, name + 1-line descriptor) keeps text-stage prompts under context budget while still giving the LLM continuity anchors.- [ ] [bible-schema-speech-pattern-field] **Add a dedicated speech-pattern field to the character bible schema.** `voiceId` is the TTS engine pointer, not a written speech-pattern field. Add to `PROMPT_FIELDS[CHARACTER]` in `server/lib/storyBible.js:121` and pipe through extraction + script prompts.