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([coverautofiler-dispatcher-redundant-getseries]): archive to DONE.md, capture preload-universe follow-up
[._.]/ Adam Eivy6354d4ab7f78
diff --git a/DONE.md b/DONE.mdindex 54807a0f7d..a739d3ac3e 100644--- a/DONE.md+++ b/DONE.md@@ -10,8 +10,8 @@ For active roadmap see [PLAN.md](./PLAN.md). For project goals see [GOALS.md](./### 2026-05-18+- **[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.-- **[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.diff --git a/PLAN.md b/PLAN.mdindex db5e4aab3a..345f3a421c 100644--- a/PLAN.md+++ b/PLAN.md@@ -13,7 +13,7 @@ _Nothing currently parked — pick the next item from the Backlog._### Sharing- [ ] [multi-hop-provenance-chains-re-share-authors-a] **Multi-hop provenance chains.** Re-share authors a fresh `origin` block; `chain[]` would preserve full attribution. Defer until users ask.-- [ ] [coverautofiler-dispatcher-redundant-getseries] **`fileCoverIntoAutoCollection` dispatcher reads `series` 3-4× per cover completion.** `server/services/pipeline/coverUniverseFiler.js:43-52` does `seriesSvc.getSeries(seriesId)` purely to branch on `series.universeId`, then both leaf functions (`fileCoverIntoUniverseCollection` lines ~65/~71, `fileCoverIntoSeriesCollection` lines ~133/~154) re-fetch series via their own `getSeries` calls — worst case 4 full series.json reads per universe-linked cover, 3 for a series-linked one. Cover completion is human-pace (one or a few per render burst) so absolute waste is tiny, but trivially fixable: pass the dispatcher's already-fetched `series` into the leaf functions as an optional `_preloaded` arg to skip their first read. The mid-flight re-read (line ~71 in the universe path) is intentional race-detection and must stay. Surfaced by /simplify during the `[same-collection-export-pattern-for-pipeline-series]` PR; deferred to keep that diff focused on the new feature.+- [ ] [coverautofiler-preload-universe-record] **Mirror the `_preloadedSeries` pattern for `universeSvc.getUniverse`.** `server/services/pipeline/coverUniverseFiler.js#fileCoverIntoUniverseCollection` calls `universeSvc.getUniverse(universeId)` twice — once near the create (line ~83) and once for delete-race detection after `addItem` (line ~117). The second call must stay (race-detection contract). The first could be skipped via an optional `_preloadedUniverse` arg if a caller ever has the universe in hand; today neither hook caller does, so add a follow-up when a 3rd direct caller appears with a fresh universe. Surfaced by /simplify during the `[coverautofiler-dispatcher-redundant-getseries]` PR; deferred because no current caller would feed it.### Importer (deferred research)