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
docs([resolve-issues-inherits-verify-gaps-verify-the]): archive to DONE.md
[._.]/ Adam Eivyb5461dcf60a8
diff --git a/DONE.md b/DONE.mdindex 54807a0f7d..142eece2d1 100644--- a/DONE.md+++ b/DONE.md@@ -11,8 +11,7 @@ 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.--- **[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.diff --git a/PLAN.md b/PLAN.mdindex db5e4aab3a..cc7cdd4bb5 100644--- a/PLAN.md+++ b/PLAN.md@@ -43,7 +43,6 @@ _Nothing currently parked — pick the next item from the Backlog._### Pipeline continuity / approval-- [ ] [resolve-issues-inherits-verify-gaps-verify-the] **Resolve-issues inherits verify gaps.** Verify the resolve prompt USES episode synopses when patching the arc.- [ ] [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.- [ ] [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).@@ -161,7 +160,8 @@ _Nothing currently parked — pick the next item from the Backlog._- [ ] [comic-book-pdf-export-once-stages-comicpages] **Comic-book PDF export.** Once `stages.comicPages` carries enough panel data + rendered images, export print-ready PDF.- [ ] [voice-controlled-stage-advancement-register] **Voice-controlled stage advancement.** Register pipeline stage navigation actions in `voice/tools.js`.- [ ] [ai-assisted-panel-scene-prompt-generation-reserve] **AI-assisted panel/scene prompt generation.** Reserve `pipeline-comic-panel-image-prompt.md` and `pipeline-storyboard-image-prompt.md` for a future "turn script fragment into N image-gen prompts" button.-- [ ] [extract-migration-scaffolding-into-scripts] **Extract migration scaffolding into `scripts/migrations/_lib.js`.** Migrations 003, 006, and 019 all implement the same hash-driven prompt-replace pattern (~75 lines of boilerplate each). Lift to a shared helper; next migration becomes ~15 lines.+- [ ] [extract-migration-scaffolding-into-scripts] **Extract migration scaffolding into `scripts/migrations/_lib.js`.** Migrations 003, 006, 019, and now 023 all implement the same hash-driven prompt-replace pattern (~75 lines of boilerplate each). Lift to a shared helper; next migration becomes ~15 lines. Migration 023 was the fourth migration to clone the scaffold — the next migration after 023 should block on this extraction first; the boilerplate cost is now larger than typical content changes.+- [ ] [extract-migration-test-helpers] **Extract migration test scaffolding into `scripts/migrations/_testHelpers.js`.** Companion to `[extract-migration-scaffolding-into-scripts]`. `019.test.js` and `023.test.js` share near-verbatim setup: a newline-normalizing `md5`, a `repoRoot` + `sampleBody(filename)` helper, a `customizedBody(filename)` fixture, a `mkdtempSync`-based `beforeEach` that seeds `data.sample/`, and five of the test cases themselves (no-op-missing / idempotent / drift-catch / synthetic-old-upgrade / customized-skip / shape-consistency). Lift `{ md5, repoRoot, sampleBody, customizedBody, makeSandbox(prefix) }` and a shared describe-block builder so each per-migration test only carries migration-specific assertions. Land alongside `_lib.js` as one cleanup PR. Surfaced by /simplify during `[resolve-issues-inherits-verify-gaps-verify-the]`.- [ ] [shots-aware-scene-output-contract-partial-split] **Shots-aware scene-output-contract partial.** Split into `_partials/scene-fields-core.md` + `_partials/scene-fields-shots.md` when a third shots-using stage appears.- [ ] [per-panel-scene-image-progress-in-the-pipeline-ui] **Per-panel/scene image progress in the Pipeline UI.** ComicPages and Storyboards record `jobId` but don't subscribe to the media-job SSE for live preview.