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
address review([character-bible-simplify-followups]): copilot pass
[._.]/ Adam Eivyec5eaf2680e2
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex dbaa4b040c..98a4a8fdc7 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -14,7 +14,7 @@### Universe Builder-- **Character bible / reference-sheet `/simplify` follow-ups.** Nine cleanups bundled from the simplify review during the character bible expansion PR. (1) `CanonCard`'s four character-only props collapsed into a single `characterExtensions` object so non-character call sites skip them entirely. (2) New `client/src/lib/bibleLimits.js` mirrors `server/lib/storyBible.js` `BIBLE_LIMITS` so client-side `max:` literals can't drift from the server caps. (3) Single-field `useFieldDraft` hook shared by `CharacterDetailEditor#DraftField` and a new per-row `WardrobeRow` sub-component (replaces the indexed `${idx}:${field}` drafts map). (4) `runPromptRefine` split into a lower-level `runPromptRefineRaw` so multi-field merges (`universeCharacterExpand`) can reuse the empty-guard + rationale-trim + log-tag scaffold. (5) `resolveGalleryImage` / `resolveImageRef` / `resolveTemplateAsset` collapsed onto a `makePathResolver(rootOrGetter, { extensions, cache })` factory — preserves test-time late-binding semantics via thunk roots. (6) New `shortId(id, n=8)` helper in `fileUtils.js` replaces inline `String(x).slice(0, 8)` across the universe character family. (7) New `createImageGenWaiter` extracts the shared `imageGenEvents` completion-waiter pattern used by `sdapi.js#createCompletionWaiter` and `voice/tools.js#image_gen`. (8) `flattenStats`/`flattenPalette`/`flattenWardrobes`/`flattenProps`/`flattenNamedList` moved from `universeCharacterSheet.js` to `canonPrompt.js` alongside `RICH_SPEC`. (9) `CharacterReferenceSheetPanel#waitForImageRef` accepts an `AbortSignal` so unmount aborts the 3 s HEAD-poll loop instead of letting it issue requests against a dead component. Three sub-bullets deferred to dedicated PLAN entries: `[purge-reference-sheet-image-ref-on-sheet-delete]` and `[clear-pending-sheet-slot-on-entry-delete]` gate on character/universe-delete routes that don't exist yet; `[characterdetaileditor-listrow-row-draft-hook]` carves off the `ListRow` half of item 3 — the multi-column ride-along race protection can't survive a per-field split, so a `useRowDraft` hook for multi-column row state is the right successor.+- **Character bible / reference-sheet `/simplify` follow-ups.** Nine cleanups bundled from the simplify review during the character bible expansion PR. (1) `CanonCard`'s four character-only props collapsed into a single `characterExtensions` object so non-character call sites skip them entirely. (2) New `client/src/lib/bibleLimits.js` mirrors `server/lib/storyBible.js` `BIBLE_LIMITS` so client-side `max:` literals can't drift from the server caps. (3) Single-field `useFieldDraft` hook shared by `CharacterDetailEditor#DraftField` and a new per-row `WardrobeRow` sub-component (replaces the indexed `${idx}:${field}` drafts map). (4) `runPromptRefine` split into a lower-level `runPromptRefineRaw` so multi-field merges (`universeCharacterExpand`) can reuse the empty-guard + rationale-trim + log-tag scaffold. (5) `resolveGalleryImage` / `resolveImageRef` / `resolveTemplateAsset` collapsed onto a `makePathResolver(getRoot, { extensions, cache })` factory — thunk-only API (throws on non-function `getRoot`) so test-time mutations of `PATHS.x` at mock-eval time still steer the resolver; `rootAbsPrefix` is cached lazily on first call. (6) New `shortId(id, n=8)` helper in `fileUtils.js` replaces inline `String(x).slice(0, 8)` across the universe character family. (7) New `createImageGenWaiter` extracts the shared `imageGenEvents` completion-waiter pattern used by `sdapi.js#createCompletionWaiter` and `voice/tools.js#image_gen`. (8) `flattenStats`/`flattenPalette`/`flattenWardrobes`/`flattenProps`/`flattenNamedList` moved from `universeCharacterSheet.js` to `canonPrompt.js` alongside `RICH_SPEC`. (9) `CharacterReferenceSheetPanel#waitForImageRef` accepts an `AbortSignal` so unmount aborts the 3 s HEAD-poll loop instead of letting it issue requests against a dead component. Three sub-bullets deferred to dedicated PLAN entries: `[purge-reference-sheet-image-ref-on-sheet-delete]` and `[clear-pending-sheet-slot-on-entry-delete]` gate on character/universe-delete routes that don't exist yet; `[characterdetaileditor-listrow-row-draft-hook]` carves off the `ListRow` half of item 3 — the multi-column ride-along race protection can't survive a per-field split, so a `useRowDraft` hook for multi-column row state is the right successor.- **Character bible expansion + artist reference sheet.** Universe canon characters now carry novelist + graphic-novelist depth and can render a single dense artist reference sheet styled to match the universe. `sanitizeCharacter` in `server/lib/storyBible.js` gains 15 prose fields (pronouns, age, coreTheme, speechAccent, visualNotes, silhouetteNotes, postureNotes, specialTraits, visualIdentity, motivations, likes, dislikes, mannerisms, relationships, skills) + 5 structured lists (stats, colorPalette, props, expressions, handGestures) + 1 operational pointer (`referenceSheetImageRef`). Stats are an open `[{label, value}]` list so non-human characters (ghosts, spiders, clouds, AIs) aren't shoehorned into human anatomy. Two new endpoints: `POST /api/universe-builder/:id/characters/:entryId/expand` runs one LLM call (new `universe-character-expand` stage) that fills BLANK extended fields without clobbering populated content; `POST /api/universe-builder/:id/characters/:entryId/render-reference-sheet` enqueues a media-job render driven by a rich TEXT prompt (no init image required) that works equally well across codex and local image-gen backends. The renderer emits a multi-paragraph layout-prescriptive prompt (turnaround, expression progression, color palette swatches, wardrobe + prop cards, hand gestures), routes through `mediaJobQueue` with the active `imageGen.mode` (codex → codex lane, local → GPU lane; external SD-API returns `UNIVERSE_CHARACTER_SHEET_UNSUPPORTED_MODE` rather than a silently-degraded render), and on `mediaJobEvents` completion copies the result into `data/image-refs/` then stamps `character.referenceSheetImageRef`. Completed renders are also filed into the universe's media collection (`Universe: <name>` bucket) via `universeBuilderCollectionHook` by attaching a `universeRun` tag to the enqueued job, alongside the rest of the universe's concept art. `/data/image-refs/` is now exposed as a static route so the UI can render the sheet inline. New UI: `CharacterDetailEditor.jsx` (sectioned collapsible editor for the extended fields) + `CharacterReferenceSheetPanel.jsx` (Generate / Regenerate / lightbox) embedded in `CanonCard.jsx` behind a single "Character details + reference sheet" toggle that only renders when the caller passes the universe wiring — the per-series NounsStage stays focused on naming + visual refs. New migration `022-character-extended-fields.js` is record-only (sanitizer fills defaults on next read). 18+ new server tests (storyBible extensions + universeCharacterSheet prompt builder + universeCharacterExpand merge semantics + route mocks).- **CanonCard provenance chip now names the source series.** The "from series" chip on `CanonCard` (rendered by both the Universe Canon section and the per-issue Nouns stage) now reads `from <Series Name>` when an entry's `sourceSeriesId` resolves through a new `seriesNameMap` prop; the tooltip carries both name and id (`Introduced by series "<name>" (<id>)`). Map is sourced from a new top-level `seriesNameMap` field on the `GET /api/universe-builder/:id/canon-usage` response, which now lists every linked series — not just ones with a prose-match row — so an entry whose `sourceSeriesId` points at a series with no matching prose still resolves to a name. Missing-map / unknown-id cases keep the legacy `from series` label + id-only tooltip. New `SourceSeriesChip` helper extracted in `client/src/components/pipeline/CanonCard.jsx`; 4 vitest cases in `CanonCard.test.jsx` + 2 vitest cases in `server/services/canonUsage.test.js`.diff --git a/DONE.md b/DONE.mdindex e38979509b..21c1d9d25b 100644--- a/DONE.md+++ b/DONE.md@@ -14,7 +14,7 @@ For active roadmap see [PLAN.md](./PLAN.md). For project goals see [GOALS.md](./- **[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.- **[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]`.-- **[character-bible-simplify-followups] Character bible / reference-sheet `/simplify` follow-ups.** Captured from the simplify review during the character bible expansion PR. Of the eleven sub-bullets: eight fully landed in this PR; one (item 3 — extract the WardrobeSection draft+blur+pending-row editor into a shared hook reused by both `WardrobeSection` and `CharacterDetailEditor.jsx`'s `ListRow`) shipped its `useFieldDraft` half but couldn't unify `ListRow` (the multi-column ride-along race protection doesn't survive a per-field split — captured as `[characterdetaileditor-listrow-row-draft-hook]` in PLAN.md); two more (active-purge `referenceSheetImageRef` + prune `_latestPendingByCharacter`) gate on character/universe-delete routes that don't exist yet (`[purge-reference-sheet-image-ref-on-sheet-delete]` and `[clear-pending-sheet-slot-on-entry-delete]`). Touched files: (1) `client/src/components/pipeline/CanonCard.jsx` + `client/src/components/universe/UniverseCanonSection.jsx` — bundled four character-only props (`universeId`, `onExpandCharacter`, `expanding`, `onSheetCompleted`) into a single `characterExtensions` object so the gate collapses to one truthiness check; NounsStage still passes nothing and stays focused. (2) New `client/src/lib/bibleLimits.js` mirrors `server/lib/storyBible.js` `BIBLE_LIMITS` verbatim; `CharacterDetailEditor.jsx`'s 25+ `max:` literals + `CanonCard.jsx`'s wardrobe `maxLength`s now reference the constants by name. (3) New `client/src/hooks/useFieldDraft.js` — single-field draft+blur hook used by `CharacterDetailEditor#DraftField` and a new per-row `WardrobeRow` sub-component (replaces the indexed `${idx}:${field}` drafts map in `WardrobeSection`). `ListRow`'s multi-column row-state (with sibling-draft "ride-along" race protection) was deliberately left as-is — splitting per-column would lose the protection. (4) `server/services/pipeline/refineHelpers.js` split into `runPromptRefineRaw` (lower-level: runStagedLLM + empty-guard + rationale-trim + optional logTag) and the existing `runPromptRefine` (single-field convenience wrapper built atop the raw variant); `server/services/universeCharacterExpand.js` now consumes `runPromptRefineRaw` with `logTag: null` so it can log a context-rich line after the merge. (5) New `makePathResolver(rootOrGetter, { extensions, cache })` factory in `server/lib/fileUtils.js`; collapses `resolveGalleryImage` / `resolveImageRef` / `resolveTemplateAsset` onto one closure. Accepts a thunk for late-binding so existing test mutations of `PATHS.images` at mock-eval time still steer the resolver. (6) New `shortId(id, n=8)` helper in `fileUtils.js` (null-safe); replaces inline `String(x).slice(0, 8)` in `universeCharacterExpand.js`, `universeCharacterSheet.js`, and `universeCanon.js` (the in-scope universe character family). Other call sites (shell, agents, cos) intentionally left alone — outside scope. (7) New `server/services/imageGenWaiter.js` (`createImageGenWaiter`) extracts the shared `imageGenEvents` completion-waiter pattern used by `server/routes/sdapi.js#createCompletionWaiter` (now a thin error-shape wrapper) and `server/services/voice/tools.js#image_gen` (drops the inline duplicate). The `universeCharacterSheet.js#subscribeToSheetJob` pattern stays distinct — it uses a different events bus (`mediaJobEvents`), an internal dispatcher that bounds listeners, callback-style handlers, and a two-stage timeout with `onStarted` reset. (8) `flattenStats`/`flattenPalette`/`flattenWardrobes`/`flattenProps`/`flattenNamedList` moved from `universeCharacterSheet.js` to `server/lib/canonPrompt.js` alongside `RICH_SPEC` so per-page render prompts can reuse them. (9) `CharacterReferenceSheetPanel.jsx#waitForImageRef` accepts an `AbortSignal`; a new `pollAbortRef` is wired into a useEffect-cleanup so unmount aborts the 3 s HEAD-poll loop (and the in-flight fetch) instead of letting it issue requests against a dead component. Sentinel `null` return distinguishes "aborted" from "give up + toast." Coverage: all 5565 server tests pass; all 92 client tests pass. Test files updated: `server/services/universeCanon.test.js` adds `shortId` to its `fileUtils.js` mock so the new log-line consumer doesn't break the lock-semantics tests.+- **[character-bible-simplify-followups] Character bible / reference-sheet `/simplify` follow-ups.** Captured from the simplify review during the character bible expansion PR. Of the eleven sub-bullets: eight fully landed in this PR; one (item 3 — extract the WardrobeSection draft+blur+pending-row editor into a shared hook reused by both `WardrobeSection` and `CharacterDetailEditor.jsx`'s `ListRow`) shipped its `useFieldDraft` half but couldn't unify `ListRow` (the multi-column ride-along race protection doesn't survive a per-field split — captured as `[characterdetaileditor-listrow-row-draft-hook]` in PLAN.md); two more (active-purge `referenceSheetImageRef` + prune `_latestPendingByCharacter`) gate on character/universe-delete routes that don't exist yet (`[purge-reference-sheet-image-ref-on-sheet-delete]` and `[clear-pending-sheet-slot-on-entry-delete]`). Touched files: (1) `client/src/components/pipeline/CanonCard.jsx` + `client/src/components/universe/UniverseCanonSection.jsx` — bundled four character-only props (`universeId`, `onExpandCharacter`, `expanding`, `onSheetCompleted`) into a single `characterExtensions` object so the gate collapses to one truthiness check; NounsStage still passes nothing and stays focused. (2) New `client/src/lib/bibleLimits.js` mirrors `server/lib/storyBible.js` `BIBLE_LIMITS` verbatim; `CharacterDetailEditor.jsx`'s 25+ `max:` literals + `CanonCard.jsx`'s wardrobe `maxLength`s now reference the constants by name. (3) New `client/src/hooks/useFieldDraft.js` — single-field draft+blur hook used by `CharacterDetailEditor#DraftField` and a new per-row `WardrobeRow` sub-component (replaces the indexed `${idx}:${field}` drafts map in `WardrobeSection`). `ListRow`'s multi-column row-state (with sibling-draft "ride-along" race protection) was deliberately left as-is — splitting per-column would lose the protection. (4) `server/services/pipeline/refineHelpers.js` split into `runPromptRefineRaw` (lower-level: runStagedLLM + empty-guard + rationale-trim + optional logTag) and the existing `runPromptRefine` (single-field convenience wrapper built atop the raw variant); `server/services/universeCharacterExpand.js` now consumes `runPromptRefineRaw` with `logTag: null` so it can log a context-rich line after the merge. (5) New `makePathResolver(getRoot, { extensions, cache })` factory in `server/lib/fileUtils.js`; collapses `resolveGalleryImage` / `resolveImageRef` / `resolveTemplateAsset` onto one closure. Thunk-only API (throws on non-function `getRoot`) so the late-binding semantics tests rely on (mutating `PATHS.images` at mock-eval time) stay correct; the resolver caches `rootAbsPrefix` lazily on first call. `resolveImageInputPath`'s root-prefix dispatch table is precomputed at module load. (6) New `shortId(id, n=8)` helper in `fileUtils.js` (null-safe); replaces inline `String(x).slice(0, 8)` in `universeCharacterExpand.js`, `universeCharacterSheet.js`, and `universeCanon.js` (the in-scope universe character family). Other call sites (shell, agents, cos) intentionally left alone — outside scope. (7) New `server/services/imageGenWaiter.js` (`createImageGenWaiter`) extracts the shared `imageGenEvents` completion-waiter pattern used by `server/routes/sdapi.js#createCompletionWaiter` (now a thin error-shape wrapper) and `server/services/voice/tools.js#image_gen` (drops the inline duplicate). The `universeCharacterSheet.js#subscribeToSheetJob` pattern stays distinct — it uses a different events bus (`mediaJobEvents`), an internal dispatcher that bounds listeners, callback-style handlers, and a two-stage timeout with `onStarted` reset. (8) `flattenStats`/`flattenPalette`/`flattenWardrobes`/`flattenProps`/`flattenNamedList` moved from `universeCharacterSheet.js` to `server/lib/canonPrompt.js` alongside `RICH_SPEC` so per-page render prompts can reuse them. (9) `CharacterReferenceSheetPanel.jsx#waitForImageRef` accepts an `AbortSignal`; a new `pollAbortRef` is wired into a useEffect-cleanup so unmount aborts the 3 s HEAD-poll loop (and the in-flight fetch) instead of letting it issue requests against a dead component. Sentinel `null` return distinguishes "aborted" from "give up + toast." Coverage: all 5566 server tests pass (added one BIBLE_LIMITS client-mirror drift test); all 92 client tests pass. Test files updated: `server/services/universeCanon.test.js` adds `shortId` to its `fileUtils.js` mock so the new log-line consumer doesn't break the lock-semantics tests.- **[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.- **[tabpills-pipelineissue-status-dot-trailing-slot] Extend `<TabPills>` with a `trailing` slot to migrate `PipelineIssue.jsx`.** Added an optional `t.trailing` ReactNode to the tab shape, rendered after the count in both `underline` and `pills` variants of `client/src/components/ui/TabPills.jsx`. Migrated `client/src/pages/PipelineIssue.jsx`'s previously-inlined stage tab row (the 11th outlier — its per-tab `STATUS_DOT[status]` indicator didn't fit the prior contract) onto `<TabPills>`, with the status dot supplied via `trailing`. Net 22-line bespoke `<button>` block collapsed onto the shared primitive; the row also picks up the standard mobile touch-target (`min-h-[44px]`) and icon size (16 vs 14) used elsewhere. +1 vitest case in `TabPills.test.jsx` pins the DOM-order contract (`trailing` follows `count`) in both variants; all 78 client tests pass.diff --git a/PLAN.md b/PLAN.mdindex d06eef4ca4..4bfcd721f1 100644--- a/PLAN.md+++ b/PLAN.md@@ -22,7 +22,7 @@ _Nothing currently parked — pick the next item from the Backlog._### Universe-as-Canon — Phase 2 + extensions- [ ] [purge-reference-sheet-image-ref-on-sheet-delete] **Active-purge `character.referenceSheetImageRef` when its sheet file is deleted.** Today there is no delete-route for sheet files; the GET-time lazy `pruneStaleReferenceSheets` masks staleness at read-time. When a sheet-delete route lands it must also call into a new `purgeReferenceSheetFromAllUniverses(filename)` helper mirroring `purgeImageRefFromAllUniverses` in `server/services/universeCanon.js:263`. Deferred from `[character-bible-simplify-followups]` because the delete route doesn't exist yet.-- [ ] [clear-pending-sheet-slot-on-entry-delete] **Prune `_latestPendingByCharacter` on character / universe delete.** Map at `server/services/universeCharacterSheet.js:221` grows bounded by characters ever rendered, but stale slot entries persist across the process lifetime. Wire a `clearPendingSheetSlot(universeId, entryId)` helper into the character-delete + universe-delete paths once those exist. Deferred from `[character-bible-simplify-followups]` because the delete paths don't exist yet.+- [ ] [clear-pending-sheet-slot-on-entry-delete] **Prune `_latestPendingByCharacter` on character / universe delete.** Map at `server/services/universeCharacterSheet.js` (search `_latestPendingByCharacter`) grows bounded by characters ever rendered, but stale slot entries persist across the process lifetime. Wire a `clearPendingSheetSlot(universeId, entryId)` helper into the character-delete + universe-delete paths once those exist. Deferred from `[character-bible-simplify-followups]` because the delete paths don't exist yet.- [ ] [characterdetaileditor-listrow-row-draft-hook] **Extract `ListRow`'s multi-column row-draft state in `CharacterDetailEditor.jsx` into a shared `useRowDraft` hook.** `useFieldDraft` shipped with `[character-bible-simplify-followups]` covers single-field draft+blur, but the `ListRow` component has multi-column row-level state with sibling-draft "ride-along" race protection (`{...row, ...drafts, [col]: v}` so a fast A-blur → B-blur sequence doesn't lose column A). Splitting per-column would lose that protection. A `useRowDraft(row, columns)` hook keyed by column name would expose the same `draftFor(col)`/`setDraft(col, v)`/`commit(col)` API and let CharacterDetailEditor's `ListRow` drop the inline state. Low priority — single consumer today; revisit when a second multi-column-row editor lands.- [x] ~~**Drop the default `characters` category.**~~ Shipped via the Universe Builder redesign Phase A migration; default `characters` bucket retired, variations backfilled into `universe.characters[]`.diff --git a/client/src/components/pipeline/CanonCard.jsx b/client/src/components/pipeline/CanonCard.jsxindex d34fd85de0..97fcd13b50 100644--- a/client/src/components/pipeline/CanonCard.jsx+++ b/client/src/components/pipeline/CanonCard.jsx@@ -173,15 +173,15 @@ function WardrobeSection({ wardrobes, editable, onChange }) {const current = pendingNew[pendingIdx] || { name: '', description: '' };if ((current[field] || '') === value) return;const nextPending = pendingNew.map((p, i) => i === pendingIdx ? { ...p, [field]: value } : p);- // Once a pending row has a non-empty name it's safe to promote into- // the persisted list (server sanitizer no longer drops it). Strip the- // client-only `pending-wardrobe-*` id so server `ensureId('wd-')` mints- // a fresh `wd-<uuid>` — `ensureId` preserves any non-empty string, so- // an unstripped prefix would round-trip onto the persisted row.+ // Promote on name-non-empty. The pending row already carries a+ // server-shaped `wd-<uuid>` id (minted client-side in `addOne`) so+ // it persists verbatim — and crucially, the React key stays stable+ // across promotion so the `WardrobeRow` instance doesn't unmount+ // and lose any uncommitted description draft buffered inside its+ // `useFieldDraft` hook.if (field === 'name' && value.trim()) {- const { id: _pendingId, ...promoted } = nextPending[pendingIdx];setPendingNew(nextPending.filter((_, i) => i !== pendingIdx));- onChange([...wardrobes, promoted]);+ onChange([...wardrobes, nextPending[pendingIdx]]);} else {setPendingNew(nextPending);}@@ -202,9 +202,10 @@ function WardrobeSection({ wardrobes, editable, onChange }) {const addOne = () => {setOpen(true);- // Client-only id so React keys are stable across re-renders before the- // row promotes into the persisted list (server mints its own id then).- const id = `pending-wardrobe-${(crypto?.randomUUID?.() ?? Date.now().toString(36) + Math.random().toString(36).slice(2))}`;+ // Mint a server-shaped `wd-<uuid>` client-side so the React key stays+ // stable across the pending → persisted promotion. Server `ensureId`+ // preserves any non-empty string, so this id round-trips unchanged.+ const id = `wd-${(crypto?.randomUUID?.() ?? Date.now().toString(36) + Math.random().toString(36).slice(2))}`;setPendingNew((prev) => [...prev, { id, name: '', description: '' }]);};diff --git a/client/src/components/universe/UniverseCanonSection.jsx b/client/src/components/universe/UniverseCanonSection.jsxindex 36d6f9084a..c9002543a8 100644--- a/client/src/components/universe/UniverseCanonSection.jsx+++ b/client/src/components/universe/UniverseCanonSection.jsx@@ -560,7 +560,12 @@ export default function UniverseCanonSection({ universe, universeId, onUniverseCfunction KindSection({ kind, universeId, all, totalCount, filtered, usage, renderingJobs, onRender, onJobCompleted, onJobFailed, onPreview, onRefine, refiningId, onExpandCharacter, expandingId, onSheetCompleted, onToggleLock, togglingLockId, onPatchEntry, onRenderCleanPlate, seriesNameMap }) {// Universe-only character wiring — `null` for non-character kinds so// CanonCard's gate stays `kind === 'characters' && characterExtensions`.- // Memoized so re-renders don't pass fresh-by-identity props into every card.+ // Memoized so the BASE object is stable across re-renders that aren't+ // expansion-related (refining, lock toggle, etc). The per-card spread+ // below still allocates a fresh object every render to fold in+ // `expanding: expandingId === entry.id`; that's unavoidable without+ // per-card memoization and isn't worth the complexity at typical cast+ // sizes.const characterExtensions = useMemo(() => (kind.key === 'characters' ? { universeId, onExpandCharacter, onSheetCompleted } : null),[kind.key, universeId, onExpandCharacter, onSheetCompleted],diff --git a/client/src/lib/canonPrompt.js b/client/src/lib/canonPrompt.jsindex d4b7f7f44a..0e9111f203 100644--- a/client/src/lib/canonPrompt.js+++ b/client/src/lib/canonPrompt.js@@ -1,8 +1,13 @@-// Mirror of server/lib/canonPrompt.js — logic kept in sync (specs + helpers-// must match exactly). Header comments differ intentionally (the server copy-// carries the full JSDoc); when editing, port logic changes verbatim and-// leave commentary scoped to each side. The server copy is authoritative;-// tests in server/lib/canonPrompt.test.js are the contract.+// Mirror of server/lib/canonPrompt.js — the SHORT_SPEC / RICH_SPEC tables+// + `shortCanonDescriptorFragments` / `richCanonDescriptorFragments` /+// `descriptorForCanonEntry` / `hasCanonDescriptorContent` helpers must+// match the server side exactly. The server-only `flatten*` exports+// (`flattenStats`/`flattenPalette`/etc.) are NOT part of the mirror —+// they're consumed by reference-sheet rendering paths that don't run in+// the client and would only bloat the bundle. Header comments differ+// intentionally; when editing the mirrored helpers, port logic changes+// verbatim and leave commentary scoped to each side. The server copy is+// authoritative; tests in server/lib/canonPrompt.test.js are the contract.const trim = (s) => (typeof s === 'string' ? s.trim() : '');diff --git a/server/lib/canonPrompt.js b/server/lib/canonPrompt.jsindex 7517efc3f6..c9557a899c 100644--- a/server/lib/canonPrompt.js+++ b/server/lib/canonPrompt.js@@ -216,6 +216,10 @@ export function hasCanonDescriptorContent(kind, entry) {// Flatteners for character bible list fields — used by the reference-sheet// builder and future per-page render prompts so the join logic stays in one// place. Each returns `''` when the input is missing/empty.+//+// Server-only — NOT part of the `client/src/lib/canonPrompt.js` mirror+// contract. Adding them client-side would bloat the bundle for code that+// only runs in image-gen / prompt-building paths.export function flattenStats(stats) {if (!Array.isArray(stats) || stats.length === 0) return '';return stats