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: split DONE.md run-on bullet and correct test count

[._.]/ Adam Eivy7fcd51e59604
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 06fdec48f3..25e1c620b7 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -30,7 +30,7 @@
### Pipeline
- **Manual canon extraction from comicScript / teleplay stages.** Auto-extract still runs only after `prose`, but a new "Extract canon" button on both script stages lets writers pull characters/places/objects that surface only in panel directions or dialogue cues (a barkeep in a stage direction, a recurring location named only in the script) into the linked universe on demand. New route `POST /api/pipeline/issues/:id/stages/:stageId/extract-canon` (`stageId` must be `comicScript` or `teleplay`) reads the stage's `output` as the corpus and reuses the generic `extractCanonFromProse` with the same `parallel: true` + `autoLock: true` + `sourceSeriesId` stamping as the prose auto-extract, so script-derived entries survive later AI refines and stay attributable. Returns the merged universe + per-kind counts so the UI toast can summarize the merge. Three precondition errors: `PIPELINE_CANON_EXTRACT_BAD_STAGE`, `PIPELINE_CANON_EXTRACT_NO_CORPUS`, `PIPELINE_CANON_EXTRACT_NO_UNIVERSE`. New shared component `ExtractCanonButton.jsx` (gated on stage content + linked universe; tooltip explains the specific blocker when disabled); wired into `TeleplayStage` via `TextStagePanel.extraActions` and `ComicScriptStage` directly in its header. Client helper `extractPipelineCanonFromScript` in `apiPipeline.js`. 5 new vitest cases cover all precondition guards + happy path for both stage IDs.
-- **Auto-resolve prompt now anchors edits in per-episode synopses.** `buildVerifyContext` already wires `seasonsTreeJson.episodes[].synopsis` into both the verify AND resolve passes (resolve reuses verify's context via `buildResolveContext`), but the resolve prompt's "How to resolve" list never explicitly told the LLM to USE those episode-level entries — so the auto-resolve pass could rewrite a volume's `synopsis` in ways that contradicted what its child episodes already describe. New first bullet in `data.sample/prompts/stages/pipeline-arc-resolve.md` 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, and can't paper over contradictions that originate at the episode level. 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. Migration `023-resolve-prompt-episode-anchor.js` auto-bumps unmodified installs from any of the three prior shipped hashes (pre-005, pre-019, post-019) to the new template; customized installs get a manual-merge warning. Migration 019's `NEW_SHIPPED_MD5` for `pipeline-arc-resolve.md` is bumped to track the live sample so fresh installs (where `data/` is seeded post-023) don't trip 019's "customized" warning. 7 new tests in `023-resolve-prompt-episode-anchor.test.js`. Closes PLAN.md `[resolve-issues-inherits-verify-gaps-verify-the]`.
+- **Auto-resolve prompt now anchors edits in per-episode synopses.** `buildVerifyContext` already wires `seasonsTreeJson.episodes[].synopsis` into both the verify AND resolve passes (resolve reuses verify's context via `buildResolveContext`), but the resolve prompt's "How to resolve" list never explicitly told the LLM to USE those episode-level entries — so the auto-resolve pass could rewrite a volume's `synopsis` in ways that contradicted what its child episodes already describe. New first bullet in `data.sample/prompts/stages/pipeline-arc-resolve.md` 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, and can't paper over contradictions that originate at the episode level. 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. Migration `023-resolve-prompt-episode-anchor.js` auto-bumps unmodified installs from any of the three prior shipped hashes (pre-005, pre-019, post-019) to the new template; customized installs get a manual-merge warning. Migration 019's `NEW_SHIPPED_MD5` for `pipeline-arc-resolve.md` is bumped to track the live sample so fresh installs (where `data/` is seeded post-023) don't trip 019's "customized" warning. 6 new tests in `023-resolve-prompt-episode-anchor.test.js`. Closes PLAN.md `[resolve-issues-inherits-verify-gaps-verify-the]`.
### Brain / Notes
diff --git a/DONE.md b/DONE.md
index 142eece2d1..bf42371092 100644
--- a/DONE.md
+++ b/DONE.md
@@ -11,7 +11,8 @@ For active roadmap see [PLAN.md](./PLAN.md). For project goals see [GOALS.md](./
### 2026-05-18
- **[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`.- **[extraction-after-comicscript-teleplay-stages] Extraction after comicScript / teleplay stages.** Resolves the deferred decision in favor of an opt-in, manually-triggered extraction: auto-extract stays prose-only (so the auto-pipeline isn't paying an extra LLM call per script stage on every issue), but writers can now pull canon from a script stage on demand. New route `POST /api/pipeline/issues/:id/stages/:stageId/extract-canon` (stageId must be `comicScript` or `teleplay`) reads `issue.stages[stageId].output` as the corpus and calls the existing generic `extractCanonFromProse` with the same `parallel: true` + `autoLock: true` + `sourceSeriesId` stamping the prose auto-extract uses, so script-derived entries survive later AI refines and stay attributable to the triggering series. Schema `extractCanonFromScriptSchema` accepts an optional `providerOverride`; the route also returns the merged universe plus `{ characters, places, objects }` counts so the UI toast can summarize the merge. Three precondition guards: `PIPELINE_CANON_EXTRACT_BAD_STAGE` (400) for any stage other than the two script stages, `PIPELINE_CANON_EXTRACT_NO_CORPUS` (400) when the script stage has no output, `PIPELINE_CANON_EXTRACT_NO_UNIVERSE` (400) when the series isn't linked to a universe. New shared component `client/src/components/pipeline/stages/ExtractCanonButton.jsx` (BookOpen icon + "Extract canon" label) is gated on stage content + linked universe and surfaces a tooltip explaining the specific blocker when disabled. Wired into both script stages: `TeleplayStage.jsx` passes it through `TextStagePanel`'s `extraActions` slot; `ComicScriptStage.jsx` mounts it directly in its header actions next to the Image-gen settings button. Client helper `extractPipelineCanonFromScript(issueId, stageId, body, options)` in `apiPipeline.js` follows the project's silent/toast convention (helper passes `{ silent: true }` since the button owns its own error toast). 5 new vitest cases in `server/routes/pipeline.test.js` cover all three precondition guards plus the happy path for both stage IDs, asserting the corpus is forwarded and the autoLock/sourceSeriesId stamping matches the prose auto-extract semantics. All 5570 server tests + 92 client tests pass; client build clean.
+- **[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`.
+- **[extraction-after-comicscript-teleplay-stages] Extraction after comicScript / teleplay stages.** Resolves the deferred decision in favor of an opt-in, manually-triggered extraction: auto-extract stays prose-only (so the auto-pipeline isn't paying an extra LLM call per script stage on every issue), but writers can now pull canon from a script stage on demand. New route `POST /api/pipeline/issues/:id/stages/:stageId/extract-canon` (stageId must be `comicScript` or `teleplay`) reads `issue.stages[stageId].output` as the corpus and calls the existing generic `extractCanonFromProse` with the same `parallel: true` + `autoLock: true` + `sourceSeriesId` stamping the prose auto-extract uses, so script-derived entries survive later AI refines and stay attributable to the triggering series. Schema `extractCanonFromScriptSchema` accepts an optional `providerOverride`; the route also returns the merged universe plus `{ characters, places, objects }` counts so the UI toast can summarize the merge. Three precondition guards: `PIPELINE_CANON_EXTRACT_BAD_STAGE` (400) for any stage other than the two script stages, `PIPELINE_CANON_EXTRACT_NO_CORPUS` (400) when the script stage has no output, `PIPELINE_CANON_EXTRACT_NO_UNIVERSE` (400) when the series isn't linked to a universe. New shared component `client/src/components/pipeline/stages/ExtractCanonButton.jsx` (BookOpen icon + "Extract canon" label) is gated on stage content + linked universe and surfaces a tooltip explaining the specific blocker when disabled. Wired into both script stages: `TeleplayStage.jsx` passes it through `TextStagePanel`'s `extraActions` slot; `ComicScriptStage.jsx` mounts it directly in its header actions next to the Image-gen settings button. Client helper `extractPipelineCanonFromScript(issueId, stageId, body, options)` in `apiPipeline.js` follows the project's silent/toast convention (helper passes `{ silent: true }` since the button owns its own error toast). 5 new vitest cases in `server/routes/pipeline.test.js` cover all three precondition guards plus the happy path for both stage IDs, asserting the corpus is forwarded and the autoLock/sourceSeriesId stamping matches the prose auto-extract semantics. All 5570 server tests + 92 client tests pass; client build clean.
- **[same-collection-export-pattern-for-pipeline-series] Same collection-export pattern for pipeline series with auto-collections.** Extends the v1.4 universe→manifest.collection share pattern to also cover universeless series. `mediaCollections.js` gains an optional `seriesId` field on `sanitizeCollection` (mutually exclusive with `universeId` — universe wins on hand-edited dual-stamp records), `seriesCollectionNameFor('Foo') → 'Series: Foo'` naming convention, and `findCollectionBySeriesId` / `findOrCreateSeriesCollection` / `unlinkCollectionsForSeries` / `renameCollectionForSeries` helpers mirroring the universe-side set. `updateCollection` now also locks the visible name when `seriesId` is set; the four mutation paths (`addItem`, `removeItem`, `bulkUpdateCollectionItems`, `deleteCollection`) fan `recordEvents('updated', 'series', seriesId)` alongside the existing universe emit so series subscriptions auto-re-export when peer adds new images. `coverUniverseFiler.js` gains a `fileCoverIntoAutoCollection({ seriesId, filename })` dispatcher that routes universe-linked series to the universe collection path (existing behavior) and universeless series to a new `fileCoverIntoSeriesCollection` path with the same delete-race recovery shape. The two cover hooks (`comicPagesFilenameHook.js`, `seasonCoverFilenameHook.js`) switch from the universe-only helper to the dispatcher. `pipeline/series.js#updateSeries` cascades name changes onto the linked per-series collection (no-op when no series-collection exists, which is the common case for universe-backed series); `deleteSeries` unlinks the per-series collection so the orphan becomes a normal user-owned bucket. `sharing/exporter.js#exportSeries` falls back to `findCollectionBySeriesId(series.id)` when there is no universe-linked collection — same `manifest.collection` shape, just keyed on `seriesId` instead of `universeId`; the local `findCollectionForUniverse`/`findCollectionForSeries` helpers were dropped in favor of the canonical `mediaCollections` exports (better seriesId normalization). `sharing/manifest.js#buildManifest` accepts `collection: { seriesId, ... }` alongside the existing `universeId` shape, using `universeCollectionNameFor`/`seriesCollectionNameFor` for fallback names (proper NAME_MAX_LENGTH truncation). `sharing/importer.js#mergeCollectionPayload` branches on which id the payload carries; defers with `missingSeries: true` when the local series doesn't exist yet (cursor stays un-advanced so a later sync of the series unblocks the merge — mirrors the existing `missingUniverse` path); `applyAutoMerge` returns `collectionPendingSeries` and `processManifest` includes it in the pending-gate predicate. `promoteInboxItem` throws `SHARING_SERIES_PENDING` (status 409 via `routes/sharing.js` mapping) when the collection waits on a missing series. Backward-compatible — older peers' importers no-op on seriesId-keyed payloads via the existing `if (!payload.universeId)` early-return. 30 new tests: 10 in `mediaCollections.test.js` (sanitizer mutual-exclusion, name helpers, find/create/rename/unlink, recordEvents fan-out on both add and delete), 9 in `coverUniverseFiler.test.js` (series-fallback path + dispatcher routing), 3 in `sharing/integration.test.js` (series-export round-trip with per-series collection, prefer-universe-when-both, defer-when-series-missing). All 5587 server + 92 client tests pass. Dispatcher's redundant pre-branch `getSeries` call deferred to PLAN.md as `[coverautofiler-dispatcher-redundant-getseries]`.
- **[solidify-character-descriptions-before-visual] Solidify character descriptions before visual render.** Closed as superseded by the character bible expansion + artist reference sheet work (PR #310). The original spec called for a "Solidify characters" sidebar action running an LLM pass to synthesize one canonical `physicalDescription` from accumulated evidence. The underlying goal — solid, render-ready character descriptions before visual stages — is now met via a different mechanism: `sanitizeCharacter` carries 15 prose fields + 5 structured lists (`stats`, `colorPalette`, `props`, `expressions`, `handGestures`); `POST /api/universe-builder/:id/characters/:entryId/expand` runs an LLM no-clobber fill-blanks pass over the extended fields; `POST .../render-reference-sheet` produces a single dense artist reference sheet image that becomes the visual canonical anchor (`character.referenceSheetImageRef`); and downstream pipeline stages already read `physicalDescription` via `canonPrompt`'s shared field-precedence helper. The accumulated-evidence synthesis primitive itself was not built; if it's needed later (e.g. multi-issue prose extraction starts drifting per-character `physicalDescription` and a one-click "consolidate" pass becomes valuable), it should be a fresh PLAN item against the post-#310 baseline, not this one.
- **[bible-kind-setting-rename-to-place] Bible `SETTING` kind rename to `PLACE`.** Completes the rename deferred from migration 018 (PR #265, 2026-05-17): renames the bible-domain "setting" entity to "place" everywhere it's an identifier. Server: `BIBLE_KIND.SETTING` → `PLACE` (value `'place'`), `BIBLE_FIELD[PLACE]` → `'places'`, `sanitizeSetting` → `sanitizePlace`, `matchSettingsInText` → `matchPlacesInText`, `PLACE_INT_EXT`/`PLACE_TIME_OF_DAY`/`PLACE_DESCRIPTION_MAX` constants, `CATEGORY_KINDS` plural `'settings'` → `'places'`, writers-room route `/works/:id/settings` → `/works/:id/places`, service file `writersRoom/settings.js` → `places.js` with `listPlaces/createPlace/updatePlace/deletePlace/mergeExtractedPlaces` exports and `wr-place-` id prefix, validation schemas (`writersRoomPlaceCreateSchema`/`UpdateSchema`/`placeBibleCreateSchema`/`UpdateSchema`), `canonPrompt` SHORT_SPEC/RICH_SPEC keys (server + client mirror), `seriesCanon.pickCanon` returns `places`, `canonUsage` keys on `places`, importer KIND_MAP, `universeBuilder.compilePrompts` CANON_TRUNKS, `universeBuilderExpand` LLM prompt + envelope key `parsed.places`. Persisted state migrated by `scripts/migrations/022-rename-bible-setting-to-place.js`: walks `data/universe-builder.json` (renames `state.universes[].settings[]` → `places[]`, `categories[k].kind 'settings'` → `'places'`), `data/pipeline-series.json` (legacy `settings[]` → `places[]`), and `data/writers-room/works/<id>/settings.json` → `places.json` with the inner `settings` key rewritten to `places`. The migration also patches `data/prompts/stages/writers-room-places.md` + `_partials/bible-deference.md` to use `{{existingPlacesJson}}` + `"places": [` when they match the OLD shipped MD5; customized templates are left alone (the drift surfaces in `setup-data.js`'s hash-check warning, which now treats the post-022 hash as the new shipped baseline with the pre-022 hash auto-updatable alongside migration 007's pre-007 hash). Client UI flips to the new vocabulary: `UniverseBuilder.jsx` `TRUNK_TABS` `kind: 'places'`, `mergeCanonByName(..., 'place')`, `pendingCanonAdditionsRef.places`, `bucketsByKind.places`, `groupBucketsByKind` returns `{ characters, places, objects, other }`, `WORLD_CATEGORY_DEFAULT_KINDS` `landscapes/environments/structures → 'places'`. Component updates: `NounsStage.jsx` (key/singular/match), `CanonCard.jsx` (`kind.key === 'places'`), `UniverseCanonSection.jsx` (key/apiKind), `StoryboardPanel.jsx` (`places` prop, `onPlacesChange`, `onRunPlaces`, `placesCount`, `BIBLE_KINDS.world.propName: 'places'`), `WorkEditor.jsx` (`ANALYSIS_KIND.PLACES`, `places` state, `listWritersRoomPlaces`), `ProseReader.jsx` + `proseTokenizer.jsx` (`places` prop), `ProseTokenPopover.jsx` (`places` prop), `apiWritersRoom.js` (`listWritersRoomPlaces`/`createWritersRoomPlace`/`updateWritersRoomPlace`/`deleteWritersRoomPlace`), `SettingsBible.jsx` imports updated. Non-goals stay untouched: `data/settings.json`, the Settings page, `/api/settings` routes, app-level user-prefs — all keep "settings" terminology. Existing pipeline canon entry id prefix `set-` is preserved (ids are opaque after creation; changing the prefix would force a second migration over per-entry records — pure churn). All 5499 server tests pass; 77 client tests pass. ~30 files touched.