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
feat([pipeline-visual-stages-setting-field-injection]): inject place era/weather into visual prompts
[._.]/ Adam Eivy28998f2c56c4
diff --git a/DONE.md b/DONE.mdindex 66bbdca290..164955c4e8 100644--- a/DONE.md+++ b/DONE.md@@ -8,6 +8,10 @@ For active roadmap see [PLAN.md](./PLAN.md). For project goals see [GOALS.md](./## 2026-05+### 2026-05-19++- **[pipeline-visual-stages-setting-field-injection] Inject setting `palette`/`era`/`weather`/`recurringDetails` into visual stages.** Visual prompts now pull the full RICH place descriptor set (description + Palette + Era + Weather + recurringDetails) instead of the SHORT subset (description + Palette + recurringDetails) — era + weather are continuity-critical visual cues that diffusion models weight strongly for lighting, atmosphere, and period dress, and they were already wired through the bible schema + LLM extraction but silently dropped at the visual-prompt boundary. Two surfaces touched: (1) `buildScenePrompt` in `server/lib/scenePrompt.js` + the client mirror at `client/src/lib/scenePrompt.js` swap `shortCanonDescriptorFragments('place', …)` for `richCanonDescriptorFragments('place', …)`, so storyboard scene renders (via `composeVisualPrompt` in `visualStages.js`) AND Writers Room's `SceneCard.jsx` pick up era/weather; (2) `composeComicPagePrompt`'s hand-rolled multi-place clause is replaced with the same `richCanonDescriptorFragments` helper, so the per-page `Setting — Place: description. Palette: X. Era: Y. Weather: Z. recurringDetails` shape is consistent with the scene-prompt path. The capital-cased `Palette:` prefix replaces the previous lowercase `palette:` in comic-page output as a side-effect of the shared helper (RICH_SPEC's uniform capitalization convention). UI card summaries (`KINDS[].descFor` in `UniverseCanonSection`) still use the narrower SHORT spec — those don't drive renders, so widening would just clutter the bible. Truncation order under tight budget pressure: description survives longest; recurringDetails drops first, then weather, era, palette — the priority order documented in `buildScenePrompt`'s header comment. Coverage: 2 new tests in `scenePrompt.test.js` (RICH frags pinned in display order; era/weather omitted when blank) + 3 new tests in `visualStages.test.js` for `composeComicPagePrompt` (full RICH injection + order; blank-field skip without bare prefixes; multi-place ` | `-join). All 5661 server tests + 103 client tests pass; client build clean. Two `/simplify` follow-ups deferred to PLAN.md: `[extract-flatten-canon-descriptor-fragments-helper]` (collapse the 4-site `.map(f => prefix ? ...).join(...)` pattern) and `[cleanplateprompt-migrate-to-rich-canon-fragments]` (sibling visual-prompt surface still on SHORT spec).+### 2026-05-18- **[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.diff --git a/PLAN.md b/PLAN.mdindex 86a4223958..75169ab245 100644--- a/PLAN.md+++ b/PLAN.md@@ -36,7 +36,6 @@ _Nothing currently parked — pick the next item from the Backlog._- [ ] [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).- [ ] [pipeline-text-stages-worldentitiessummary] **Add `worldEntitiesSummary` to text stages.** Zero occurrences in codebase today; a one-string canon synopsis (top-N entities by frequency, name + 1-line descriptor) keeps text-stage prompts under context budget while still giving the LLM continuity anchors.- [ ] [bible-schema-speech-pattern-field] **Add a dedicated speech-pattern field to the character bible schema.** `voiceId` is the TTS engine pointer, not a written speech-pattern field. Add to `PROMPT_FIELDS[CHARACTER]` in `server/lib/storyBible.js:121` and pipe through extraction + script prompts.@@ -99,6 +98,8 @@ _Nothing currently parked — pick the next item from the Backlog._- [ ] [aitoolkit-createprovider-field-parity-test] **`createProvider` field-parity test.** Existing `providers.test.js` covers basic fields only. Add an exhaustive assertion that every field in `providerSchema` survives the `createProvider → save → loadProviders` round-trip — guards against the `createProvider` field-list regression noted in CLAUDE.md ("`updateProvider` uses spread but `createProvider` has explicit field list").- [ ] [datasync-migrate-categories-to-atomicwrite] **Migrate all `dataSync.js` categories to `atomicWrite`.** Every category (`goals`, `character`, `digitalTwin`, `meatspace`, `universe`, `pipeline`) inlines `ensureDir + writeFile + JSON.stringify(..., null, 2)` — 6+ duplicate sites. `server/lib/fileUtils.js:124` exports `atomicWrite(path, data)` that handles all three steps as a temp+rename atomic write. One-line collapse per site + meaningful partial-write protection for the larger pipeline JSON files (which other services write concurrently). Surfaced by /simplify during `extend-syncorchestrator-to-cover-pipeline-universe`; deferred to keep that PR focused on the new categories.- [ ] [datasync-checksum-only-fast-path] **Add a checksum-only fast path to `dataSync.js`.** `getChecksum(category)` currently calls the category's `getSnapshot` and discards `data` (`server/services/dataSync.js:451-456`) — every probe materializes the full payload. With pipeline/universe added the wasted work scales with the largest user-creative payload. Define per-category `getChecksum` shortcuts (e.g. hash file size+mtime, or hash raw bytes without parse) and dispatch via `CATEGORIES[cat].getChecksum`. The orchestrator hits the checksum endpoint every cycle — this is the hottest sync-side I/O. Surfaced by /simplify during `extend-syncorchestrator-to-cover-pipeline-universe`.+- [ ] [extract-flatten-canon-descriptor-fragments-helper] **Extract `flattenCanonDescriptorFragments(fragments, { separator, trailingPeriod })` into `server/lib/canonPrompt.js` (+ client mirror).** The `.map(f => f.prefix ? \`${f.prefix}: ${f.value}\` : f.value).join(...)` pattern is now inlined at 4+ sites: `descriptorForCanonEntry` (server/lib/canonPrompt.js:175 — joins with `. `, no trailing-period), `buildScenePrompt` (server/lib/scenePrompt.js + client mirror — per-frag trailing-period, later joined with single space), `composeComicPagePrompt` (server/services/pipeline/visualStages.js:613 — joins with `. `, no trailing-period), and `synthesizeCanonPrompt` (server/services/universeBuilder.js ~1417). Two flag axes (separator, per-frag trailing-period) collapse to a small helper. Deferred from /simplify during `[pipeline-visual-stages-setting-field-injection]` to keep that PR tightly scoped to the field-injection.+- [ ] [cleanplateprompt-migrate-to-rich-canon-fragments] **Migrate `client/src/lib/cleanPlatePrompt.js#composeCleanPlatePrompt` to `richCanonDescriptorFragments('place', setting)`.** Clean-plate prompt builder (Cluster A — A4 setting reference renders) hand-rolls `description + Palette + recurringDetails` extraction at `cleanPlatePrompt.js:26-30` and is missing `era` / `weather` for the same reason `[pipeline-visual-stages-setting-field-injection]` was missing them — both are visual prompts that benefit from period/atmosphere cues. Tightly scoped sibling change (one client file + one test file). Deferred from that PR because the PLAN item targeted storyboard+comic-panel specifically; clean plates are setting-reference renders, adjacent but distinct.### v2.1.0 pre-release review residue (deferred from main→release multi-agent review, 2026-05-16)diff --git a/client/src/lib/scenePrompt.js b/client/src/lib/scenePrompt.jsindex 0e107d57e9..5bffb553a9 100644--- a/client/src/lib/scenePrompt.js+++ b/client/src/lib/scenePrompt.js@@ -1,7 +1,7 @@// Mirror of server/lib/scenePrompt.js — keep byte-for-byte in sync.// The shape-invariant tests in server/lib/scenePrompt.test.js are the contract.-import { shortCanonDescriptorFragments } from './canonPrompt.js';+import { richCanonDescriptorFragments } from './canonPrompt.js';const PROMPT_MAX = 1900;@@ -101,7 +101,7 @@ export function buildScenePrompt(workTitle, scene, matchedCharacters, worldStyle: '';const placeMetaFrag = [intExtPart, todPart].filter(Boolean).join(', ');const baselineFrags = matchedPlace- ? shortCanonDescriptorFragments('place', matchedPlace)+ ? richCanonDescriptorFragments('place', matchedPlace).map((f) => (f.prefix ? `${f.prefix}: ${f.value}.` : f.value)): [];const placeFrags = matchedPlace ? [diff --git a/server/lib/scenePrompt.js b/server/lib/scenePrompt.jsindex efd5352bb8..02843af4e3 100644--- a/server/lib/scenePrompt.js+++ b/server/lib/scenePrompt.js@@ -3,7 +3,7 @@* deps — mirrored to `client/src/lib/scenePrompt.js` for the client bundle.*/-import { shortCanonDescriptorFragments } from './canonPrompt.js';+import { richCanonDescriptorFragments } from './canonPrompt.js';const PROMPT_MAX = 1900;@@ -112,14 +112,16 @@ export function matchObjectsInText(text, allObjects) {* weight earlier tokens heaviest):* 1. worldStyle preset (cinematic / film-noir / etc.) — broadest aesthetic* 2. workTitle — gives the model story-context cues- * 3. setting baseline (description / palette / recurring details) — the place+ * 3. setting baseline (description / palette / era / weather / recurring) — the place* 4. Featuring — char1: desc, char2: desc — the subjects* 5. scene.visualPrompt — what's NEW this beat** Truncation priority is the inverse: visualPrompt survives unconditionally,* then setting baseline, then characters. Style + title are short so they're* always kept. Featuring drops characters one-by-one to fit; setting drops- * secondary fields (palette, recurring) before description.+ * trailing fragments first (recurringDetails → weather → era → palette →+ * description) so the most identity-defining field — description — survives+ * longest under budget pressure.** Positional API kept for parity with the long-running Writers Room caller* (`SceneCard.jsx`) — adding new optional kwargs at the tail is fine.@@ -141,17 +143,15 @@ export function buildScenePrompt(workTitle, scene, matchedCharacters, worldStyle? matchedPlace.timeOfDay: '';const placeMetaFrag = [intExtPart, todPart].filter(Boolean).join(', ');- // Pull descriptor fragments via the shared canon-prompt helper so the- // setting baseline shares the *SHORT* spec subset (description / Palette /- // recurringDetails) with `KINDS[].descFor` (UI summary). Note:- // `synthesizeCanonPrompt` uses the *RICH* spec — same helper, broader- // field set (adds era / weather). Both call sites stay coherent via the- // shared helper, but they are not byte-equivalent prompts. Trailing-period- // on prefixed fragments preserves the pre-extraction "Palette: X." sentence- // boundary so palette + recurringDetails don't run together when the- // budget-truncation join collapses fragments with a single space.+ // RICH spec (description / Palette / Era / Weather / recurringDetails) —+ // era + weather are continuity-critical visual cues that diffusion models+ // weight for lighting / atmosphere / period dress. UI card summaries use the+ // narrower SHORT spec via `KINDS[].descFor`; both stay coherent through the+ // shared helper but are not byte-equivalent. Per-frag trailing period+ // preserves "Palette: X." sentence boundaries when the budget-truncation+ // join collapses fragments with a single space.const baselineFrags = matchedPlace- ? shortCanonDescriptorFragments('place', matchedPlace)+ ? richCanonDescriptorFragments('place', matchedPlace).map((f) => (f.prefix ? `${f.prefix}: ${f.value}.` : f.value)): [];const placeFrags = matchedPlace ? [diff --git a/server/lib/scenePrompt.test.js b/server/lib/scenePrompt.test.jsindex b709ee2a3f..0d6bb7c994 100644--- a/server/lib/scenePrompt.test.js+++ b/server/lib/scenePrompt.test.js@@ -160,6 +160,51 @@ describe('scenePrompt — buildScenePrompt', () => {expect(out).not.toContain('Featuring');});+ it('injects palette / era / weather / recurringDetails into the setting baseline (RICH spec)', () => {+ const out = buildScenePrompt(+ '',+ baseScene,+ [],+ '',+ {+ description: 'cramped chrome bar',+ palette: 'amber',+ era: 'late 1970s post-industrial',+ weather: 'sodium-vapor rain outside',+ recurringDetails: 'broken jukebox in corner',+ },+ );+ expect(out).toContain('cramped chrome bar');+ expect(out).toContain('Palette: amber');+ expect(out).toContain('Era: late 1970s post-industrial');+ expect(out).toContain('Weather: sodium-vapor rain outside');+ expect(out).toContain('broken jukebox in corner');+ // Description must precede every secondary fragment so the diffusion+ // model anchors on identity before atmospheric cues.+ expect(out.indexOf('cramped chrome bar'))+ .toBeLessThan(out.indexOf('Palette:'));+ expect(out.indexOf('Palette:'))+ .toBeLessThan(out.indexOf('Era:'));+ expect(out.indexOf('Era:'))+ .toBeLessThan(out.indexOf('Weather:'));+ expect(out.indexOf('Weather:'))+ .toBeLessThan(out.indexOf('broken jukebox'));+ });++ it('omits era / weather fragments when the matched place has no value for them', () => {+ const out = buildScenePrompt(+ '',+ baseScene,+ [],+ '',+ { description: 'cramped chrome bar', palette: 'amber' },+ );+ expect(out).toContain('cramped chrome bar');+ expect(out).toContain('Palette: amber');+ expect(out).not.toContain('Era:');+ expect(out).not.toContain('Weather:');+ });+it('drops palette + recurringDetails before description when budget runs out', () => {// Reserve space for `description` (20) + a separator + the prefix-less// setting baseline, but NOT enough for `Palette: AMBER.` (15) on top.diff --git a/server/services/pipeline/visualStages.js b/server/services/pipeline/visualStages.jsindex 200bdc32aa..44af72c66a 100644--- a/server/services/pipeline/visualStages.js+++ b/server/services/pipeline/visualStages.js@@ -36,6 +36,7 @@ import {buildCharByKey, matchSceneCharacters, matchCharactersInText,matchPlacesInText, matchObjectsInText,} from '../../lib/scenePrompt.js';+import { richCanonDescriptorFragments } from '../../lib/canonPrompt.js';import { composeStyledPrompt } from '../../lib/composeStyledPrompt.js';import { resolveVisualStyle } from '../../lib/visualStyles.js';import { getDefaultVideoModelId, getVideoModels } from '../../lib/mediaModels.js';@@ -600,18 +601,19 @@ export function composeComicPagePrompt({.map((c) => `${c.name}: ${c.desc}`).join('; ');- // Place baseline: pull description + palette + recurringDetails per matched- // place. Same pattern as buildScenePrompt's placeFrags, but multi-place- // (a single comic page can span more than one location).+ // Place baseline: pull the full RICH descriptor set per matched place+ // (description / Palette / Era / Weather / recurringDetails). Same shared+ // helper that drives buildScenePrompt's placeFrags + synthesizeCanonPrompt's+ // body, so comic-page renders pick up the same era/weather/atmosphere cues+ // diffusion models weight for lighting + period dress. Multi-place per page+ // is supported (a single page can span more than one location).const placesClause = (matchedPlaces || []).map((p) => {- const parts = [p.name && `${p.name}:`, (p.description || '').trim()].filter(Boolean);- const head = parts.join(' ');- const tail = [- p.palette ? `palette: ${p.palette.trim()}` : '',- (p.recurringDetails || '').trim(),- ].filter(Boolean).join('; ');- return [head, tail].filter(Boolean).join('. ');+ const body = richCanonDescriptorFragments('place', p)+ .map((f) => (f.prefix ? `${f.prefix}: ${f.value}` : f.value))+ .join('. ');+ const head = p.name ? `${p.name}:` : '';+ return [head, body].filter(Boolean).join(' ');}).filter(Boolean).join(' | ');diff --git a/server/services/pipeline/visualStages.test.js b/server/services/pipeline/visualStages.test.jsindex 425b8bf79a..9f5d71a6e6 100644--- a/server/services/pipeline/visualStages.test.js+++ b/server/services/pipeline/visualStages.test.js@@ -277,6 +277,56 @@ describe('composeComicPagePrompt', () => {expect(prompt).toMatch(/Panel 1: A solitary frame\./);expect(prompt).toMatch(/SFX lettering: fmp\./);});++ it('injects matched-place palette / era / weather / recurringDetails into the Setting clause', () => {+ const matchedPlaces = [+ {+ name: 'The Rib',+ description: 'cathedral-scale fossil interior',+ palette: 'bone-white, dust-gold',+ era: 'nine thousand years post-titan',+ weather: 'still air, soft dawn shafts',+ recurringDetails: 'beetles tracking across polished bone',+ },+ ];+ const prompt = composeComicPagePrompt({ series: SERIES, page: PAGE, pageNumber: 1, matchedPlaces });+ expect(prompt).toMatch(/Setting — The Rib: cathedral-scale fossil interior/);+ expect(prompt).toMatch(/Palette: bone-white, dust-gold/);+ expect(prompt).toMatch(/Era: nine thousand years post-titan/);+ expect(prompt).toMatch(/Weather: still air, soft dawn shafts/);+ expect(prompt).toMatch(/beetles tracking across polished bone/);+ // Order within the per-place clause mirrors RICH_SPEC: description first+ // (identity anchor), then palette/era/weather, then recurringDetails.+ const settingBlock = prompt.match(/Setting — [^\n]+/)?.[0] || '';+ expect(settingBlock.indexOf('cathedral-scale fossil interior'))+ .toBeLessThan(settingBlock.indexOf('Palette:'));+ expect(settingBlock.indexOf('Palette:'))+ .toBeLessThan(settingBlock.indexOf('Era:'));+ expect(settingBlock.indexOf('Era:'))+ .toBeLessThan(settingBlock.indexOf('Weather:'));+ expect(settingBlock.indexOf('Weather:'))+ .toBeLessThan(settingBlock.indexOf('beetles'));+ });++ it('skips per-place empty fragments without emitting bare prefixes', () => {+ const matchedPlaces = [+ { name: 'The Rib', description: 'fossil interior', palette: '', era: '', weather: '', recurringDetails: '' },+ ];+ const prompt = composeComicPagePrompt({ series: SERIES, page: PAGE, pageNumber: 1, matchedPlaces });+ expect(prompt).toMatch(/Setting — The Rib: fossil interior/);+ expect(prompt).not.toMatch(/Palette:/);+ expect(prompt).not.toMatch(/Era:/);+ expect(prompt).not.toMatch(/Weather:/);+ });++ it('joins multiple matched places with " | " in the Setting clause', () => {+ const matchedPlaces = [+ { name: 'The Rib', description: 'fossil interior', era: 'post-titan' },+ { name: 'Sun Pier', description: 'wooden dock', weather: 'salt fog' },+ ];+ const prompt = composeComicPagePrompt({ series: SERIES, page: PAGE, pageNumber: 1, matchedPlaces });+ expect(prompt).toMatch(/The Rib: fossil interior\. Era: post-titan \| Sun Pier: wooden dock\. Weather: salt fog/);+ });});describe('visual style resolution threads into image prompts', () => {