Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

docs([per-season-and-per-field-locks-extend-arc-lock]): archive to DONE.md

[._.]/ Adam Eivy8acdb43a9a17
diff --git a/DONE.md b/DONE.md
index 633912771f..46867982b9 100644
--- a/DONE.md
+++ b/DONE.md
@@ -10,6 +10,7 @@ For active roadmap see [PLAN.md](./PLAN.md). For project goals see [GOALS.md](./
### 2026-05-18
+- **[per-season-and-per-field-locks-extend-arc-lock] Per-season editorial locks.** Extends the existing series-level arc lock to a per-volume editorial freeze. New `season.locked: boolean` field on each season record (`server/lib/storyArc.js#sanitizeSeason`, default `false`, strict-true coercion so a `locked: 'yes'` typo can't accidentally freeze a volume), opt-in through the existing `seasonSchema.passthrough()` in `server/routes/pipeline.js` (explicit `.locked z.boolean().optional()` per the CLAUDE.md "all inputs validated" convention). Three rewriter gates fire on `locked === true`: (1) `arcPlanner.generateSeasonEpisodes` refuses before any LLM call — same `ERR_VALIDATION` code as the existing arc-lock for symmetry; (2) `issuesSvc.bulkReassignSeason` refuses to move issues OUT of or INTO a locked volume (new `ERR_SEASON_LOCKED` code, mapped to HTTP 409) — checks the latest season state inside `queueIssueWrite` even though the source-of-truth is on the *series* file (which has its own queue), since the per-season-lock toggle isn't a hot path and a stale read here would let a single race window leak in; (3) `seasonsSvc.deleteSeason` refuses (new `ERR_LOCKED` code, also 409). The `updateSeason` content-patch gate uses a `LOCKED_SEASON_ALLOWED_KEYS = { locked, status }` allow-list — `locked` itself must always be patchable (otherwise the user can't unlock), and `status` is orthogonal to editorial content (the production workflow can flip `verified`→`in-production` while the editorial body stays frozen). A patch that includes `locked: false` lets the UI offer "unlock + edit" as one round-trip; any other content key on a still-locked season throws `ERR_LOCKED` with the forbidden field list in the message. `seasonsSvc.deleteSeason` passes its already-loaded series into `bulkReassignSeason` via a new `_preloadedSeries` option so the lock check skips the duplicate file read (same micro-opt as the cover-filer dispatcher in DONE for `[coverautofiler-dispatcher-redundant-getseries]`). UI: `ArcCanvas.jsx#SeasonRow` gains a Lock/Unlock toggle button in the header (mirrors the page-level arc-lock button's visual idiom — `border-port-warning/40 text-port-warning` accent when locked, `border-port-border text-gray-400` unlocked, Loader2 spinner on the in-flight PATCH); the trash button gates on `seasonLocked` with a "unlock to delete" tooltip; `SeasonEditor` flips all six content inputs to `disabled` + `opacity-60` (status select stays editable, save button stays enabled and only PATCHes `{ status }` so the server gate never fires on an attempted-no-op); `SeasonActions` disables the "Generate issues / episodes (LLM)" button with a "unlock to generate" tooltip; a new locked-state banner (`Lock` icon + "Volume locked — generation, delete, and content edits are blocked. Unlock above to make changes.") renders under the season header so the user has one canonical place to read the freeze status. `PipelineIssue.jsx` finds the parent season via the existing `series.seasons` array on first render and surfaces the lock as both (a) a trailing `<Lock>` icon in place of the per-stage status dot across the entire TabPills strip and (b) a sub-header pill with the unlock-on-arc-canvas hint — covers the PLAN's "surface a stage-progress strip" ask without duplicating any state-fetch (issue page already loads its series for the LLM picker). New tests: 5 in `seasons.test.js` (toggle on+off, content-patch refused, status flip allowed on locked, unlock+edit in one patch, delete refused), 3 in `issues.test.js` (out-of-locked refused, into-locked refused, post-unlock allowed), 1 in `arcPlanner.test.js` (generateSeasonEpisodes skips LLM when locked), 1 in `storyArc.test.js` (sanitizer default + truthy-non-boolean rejection). All 5666 server tests + 103 client tests pass; client build clean. Two follow-ups deferred to PLAN.md: `[per-field-locks-arc-and-stage-granularity]` (per-arc-field granularity + per-issue-stage locks — the more complex half of the original PLAN scope) and `[season-lock-aware-arc-resolve]` (teach `resolveVerifyIssues` to either refuse on locked seasons or preserve locked-season payloads in `commitSeasonsWithRemap`).
- **[pipeline-idea-stage-character-detail-plumbing] Plumb richer character bible into idea-stage prompt + extract migration scaffold.** Three slugs landed in one PR. (1) `data.sample/prompts/stages/pipeline-idea-expansion.md`'s `{{#series.characters}}` iteration now matches the prose/comicScript/teleplay templates verbatim: `**{{name}}**{{#role}} ({{role}}){{/role}} — {{#physicalDescription}}{{physicalDescription}}{{/physicalDescription}}{{^physicalDescription}}{{description}}{{/physicalDescription}}{{#personality}} | personality: {{personality}}{{/personality}}{{#background}} | background: {{background}}{{/background}}`. The beat-sheet LLM now sees the same character interiority + role that downstream stages see, so arc decisions made at idea-stage don't lose context the bible already carries. New migration `scripts/migrations/025-idea-stage-character-detail.js` rewrites any of three legacy shipped hashes (pre-003, post-003/pre-004, post-004/pre-025) onto the new shape; customized installs get a manual-merge warning. `scripts/setup-data.js` drift table updated in parallel (`1ee44cf95851ff8debf18729ebcd40b4` appended to the auto-updatable OLD list, NEW bumped to `1f3c5d077a5ef9a4b610335d5e3edd9c`). (2) `[extract-migration-scaffolding-into-scripts]` shipped — `scripts/migrations/_lib.js` exposes `md5`, `applyPromptReplaceMigration({ rootDir, accepted, current, label, customizedHint })`, and `makePromptReplaceMigration({ accepted, current, label, customizedHint, skipFooter? })` returning `{ applyMigration, up }`. Per-migration files collapse to ~50 LOC of hash table + label + hint. (3) `[extract-migration-test-helpers]` shipped — `scripts/migrations/_testHelpers.js` exposes `md5` (re-exported from `_lib.js`), `repoRoot`, `sampleBody(filename, subdir?)`, `customizedBody(filename)`, and a `runPromptMigrationTests({ migration, applyMigration, ACCEPTED_OLD_MD5, NEW_SHIPPED_MD5, prefix, subdir? })` describe-block builder that fires the six standard cases (missing-file no-op / idempotent / drift-catch / synthetic-OLD upgrade / customized preservation / hash-table shape) inside the surrounding describe. Per-migration test files collapse to a single `runPromptMigrationTests` call. Migration 023 refactored as proof-of-pattern: source went 130→58 LOC, test went 113→21 LOC. `scripts/run-migrations.js` filter gained `&& !f.startsWith('_')` so the shared helpers stay out of the migration sequence; new `scripts/run-migrations.test.js` regression case pins the exclusion against a phantom `_lib.js` fixture. All 257 server test files (5663 tests) + 48 migration/runner tests pass. Three `/simplify` follow-ups deferred to PLAN.md: `[backport-pre-023-migrations-to-_lib]` (collapse the other six prompt-replace migrations onto `_lib.js`), `[setup-data-import-drift-tables-from-migrations]` (drop the hand-mirrored hash tables in `setup-data.js` once every migration exports them), and `[parallelize-applypromptreplacemigration-files]` (theoretical, for the first multi-file migration).
- **[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.
diff --git a/PLAN.md b/PLAN.md
index a58bf53d56..1c6a003f98 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -27,7 +27,8 @@ _Nothing currently parked — pick the next item from the Backlog._
### Pipeline continuity / approval
-- [ ] [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`.
+- [ ] [per-field-locks-arc-and-stage-granularity] **Per-field locks for arc and per-stage locks on issues.** Follow-on to `[per-season-and-per-field-locks-extend-arc-lock]` (per-season locks shipped). Two remaining ratchets: (1) per-field arc locks — let `series.locked` carry a sub-map (`{ arc: true, arcFields: { logline: true, themes: true } }`) so `resolveVerifyIssues` and `commitSeasonsWithRemap` can rewrite unlocked fields while preserving locked ones. (2) per-stage locks at the issue level — add `issue.stages.{id}.locked: boolean` so the user can freeze a finalized comic-script while still iterating the storyboard. Wire the trailing Lock indicator on `PipelineIssue.jsx`'s TabPills strip per-stage (currently shows arc/season-level lock for the whole strip).
+- [ ] [season-lock-aware-arc-resolve] **Make `resolveVerifyIssues` respect per-season locks.** Today the arc-level lock blocks resolve entirely. With per-season locks landed (the parent slug above), a user can unlock the arc but keep individual seasons frozen; auto-resolve would currently rewrite locked season metadata via `commitSeasonsWithRemap` → `updateSeries({ arc, seasons })`. Either (a) refuse resolve up-front with a "seasons X, Y are locked — unlock or skip" error, or (b) teach `commitSeasonsWithRemap` to preserve `locked` season payloads field-for-field on merge.
- [ ] [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.