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): arc-stage approval lock + visual-style dropdown z-fix
[._.]/ Adam Eivy9ee515c5fa32
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex c6c50d504e..f6d502a273 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -2,6 +2,37 @@## Added+- **Arc-stage approval lock on the Pipeline Arc Canvas.** The series-arc+ workflow now distinguishes "I'm still iterating" from "I've approved this+ — don't let anything overwrite it." Two changes work together: (1) a+ `Lock arc` / `Locked` toggle pill sits next to the Regenerate / Verify+ buttons on the Arc Canvas (`client/src/components/pipeline/ArcCanvas.jsx`);+ (2) clicking **Regenerate arc** now opens an inline confirmation row+ explaining that the action overwrites the arc logline, summary,+ protagonist arc, themes, and every volume / season outline, and pointing+ at the lock as the way to preserve the approved version. When `locked.arc`+ is true the Regenerate button is disabled outright and the auto-resolve+ affordances in the verify-findings panel hide themselves with a lock-icon+ note ("Arc is locked — unlock above to enable auto-resolve") so the user+ knows why the buttons are gone. Persisted as `series.locked.arc = true`+ in `pipeline-series.json`; defaults to `{}` so existing series migrate+ forward without a writer pass. Server-side enforcement parity:+ `arcPlanner.generateArcOverview` and `arcPlanner.resolveVerifyIssues`+ both throw `ERR_VALIDATION` before any LLM call when the arc is locked,+ so a stale tab or scripted client can't bypass the UI gate. The shape is+ open (`LOCKABLE_STAGES` array + `.passthrough()` on the route schema) so+ iteration 2's per-season + per-field locks land without a schema bump.+ Mirrors the universe-builder `locked` pattern. Touches:+ `server/services/pipeline/series.js`,+ `server/services/pipeline/arcPlanner.js`,+ `server/routes/pipeline.js`,+ `client/src/components/pipeline/ArcCanvas.jsx`,+ `server/services/pipeline/series.test.js` (+5 cases),+ `server/services/pipeline/arcPlanner.test.js` (+1 case).+ The broader step-by-step approval UX pass across the Universe + Series+ pipeline (per-season locks, per-field arc locks, stage-progress strip,+ "Approve this stage" buttons) is captured as deferred work in PLAN.md.+- **Clean-plate render mode for settings (Cluster A — A4).** Setting canoncards get a "Clean plate" button next to the existing "Render reference"affordance. Clicking it builds a no-people prompt variant — prefixed with@@ -41,6 +72,15 @@## Fixed+- **Visual Style Preset dropdown bleed-through on Pipeline Series.** The+ open dropdown on the series-bible right pane was rendering under the+ sticky bible sidebar (`<aside class="bg-port-card/40 ...">`), so the+ sidebar's character names and "Linked World" content visibly bled+ through the dropdown's panel with a 40%-opacity wash. Bumped the+ picker's panel z-index from `z-30` to `z-50`, matching the convention+ used by `NotificationDropdown` and `IconPicker`. Touches:+ `client/src/components/pipeline/VisualStylePicker.jsx`.+- **Series shares now deliver issues, scripts, and renders to collaborators.**When the manifest reached a peer ahead of its 30+ issue record JSONs(Google Drive sync is order-non-deterministic), the importer silentlydiff --git a/PLAN.md b/PLAN.mdindex aa34d9e032..b62d93c13e 100644--- a/PLAN.md+++ b/PLAN.md@@ -68,6 +68,14 @@ Captured 2026-05-13 while landing layer-1 (prior episodes in season prompt), lay- [ ] **Solidify character descriptions before visual render.** User asked: as the series progresses, characters accumulate descriptions across multiple extractions but may still have gaps. Add a "Solidify characters" action in the bible sidebar that runs an LLM pass synthesizing one canonical `physicalDescription` per character from all accumulated `firstAppearance` + `evidence` + existing text. Useful before kicking off the visual render passes for an issue.- [ ] **Resolve-issues inherits verify gaps.** Verify and resolve share `buildVerifyContext` so the new episode-synopsis context is already wired into both. But double-check the resolve LLM prompt instructs it to USE episode synopses when patching the arc — otherwise it'll just rewrite season-level synopses and leave per-episode contradictions intact.+- [ ] **Step-by-step approval UX pass across Universe + Series pipeline.** Iteration 1 shipped a single arc-level lock (`series.locked.arc`) on the Arc Canvas with an inline confirmation row on Regenerate. The broader UX pass should extend approval/locking through every stage so the workflow reads as a guided wizard:+ - **Per-season locks** (`series.locked.seasons[<id>] = true`). Build the prompt context with locked seasons rendered as `[LOCKED]` constraints (mirror `universeBuilder.LOCKABLE_FIELD_LABELS`); post-merge by `id` match — preserve the locked existing season and let the LLM regenerate the unlocked ones.+ - **Per-field arc locks** (`arc.logline`, `arc.summary`, `arc.protagonistArc`, `arc.themes`, `arc.shape`). Match the Universe builder's per-field LockButton pattern in `ArcCanvas.jsx#ArcContent`.+ - **Lock the volume beat-sheet bulk runner** (`POST /series/:id/seasons/:seasonId/generate-beats`) when its season is locked, and the per-issue stage generators (`POST /issues/:id/stages/:stageId/generate`) when the issue is approved.+ - **Approval as a first-class status.** Today `arc.status`/`season.status` carry `draft|verified|in-production|complete`. Wire "Approve this stage" buttons that set status + lock atomically, then the next regenerate-style action sees the approval as a refusal-to-overwrite signal everywhere downstream.+ - **Visible "next step" guidance.** A sticky stage-progress strip showing Universe → Series → Arc → Seasons → Episodes → Beats → Prose → Script → Storyboards with approve/lock state per stage. Replaces the current "everything happens on one page in any order" mental model with a wizard the user can both follow linearly and jump around inside.+ - **Server enforcement parity.** Every regenerator + auto-resolver must read locks BEFORE running the LLM, throwing `ERR_VALIDATION` like `arcPlanner.generateArcOverview` does for `locked.arc`. Tests in `arcPlanner.test.js` ("throws ERR_VALIDATION + skips the LLM call when arc is locked") are the template.+- [ ] **Fix `lib/creativeDirectorPrompts.test.js` imageStrength wording assertions.** 3 tests in `server/lib/creativeDirectorPrompts.test.js` (around line 210) fail on `expect(out).toContain('Image strength: default')` — the prompt template no longer emits that exact phrasing for unset/null imageStrength. Pre-existing on `main` (verified 2026-05-12 while landing world-bible → pipeline wiring; out of scope for that PR). Either re-add the wording in the prompt builder or update the test to match the new output.### v1.54.0 release-review deferred itemsdiff --git a/client/src/components/pipeline/ArcCanvas.jsx b/client/src/components/pipeline/ArcCanvas.jsxindex 468da30615..dba524eb17 100644--- a/client/src/components/pipeline/ArcCanvas.jsx+++ b/client/src/components/pipeline/ArcCanvas.jsx@@ -27,7 +27,7 @@ import { useEffect, useMemo, useRef, useState } from 'react';import { Link } from 'react-router-dom';import {Plus, Trash2, Loader2, Sparkles, ShieldCheck, ChevronRight, ChevronDown,- ChevronsUpDown, AlertCircle, Wand2, Info, ListChecks, X,+ ChevronsUpDown, AlertCircle, Wand2, Info, ListChecks, X, Lock, Unlock,} from 'lucide-react';import toast from '../ui/Toast';import { timeAgo } from '../../utils/formatters';@@ -162,11 +162,14 @@ export default function ArcCanvas({ series, issues, onSeriesUpdate, onIssuesUpdafunction ArcHeader({ series, onSeriesUpdate, onIssuesUpdate, onFlushPending }) {const arc = series.arc;+ const arcLocked = !!series.locked?.arc;const [running, setRunning] = useState(null); // 'generate' | 'verify' | 'resolve' | nullconst [verifyIssues, setVerifyIssues] = useState(null);// Which finding indexes have an in-flight per-finding resolve. Lets the row// show its own spinner without blocking the rest of the page.const [resolvingIdx, setResolvingIdx] = useState(new Set());+ const [confirmingRegen, setConfirmingRegen] = useState(false);+ const [lockBusy, setLockBusy] = useState(false);const llmOverride = useMemo(() => ({providerOverride: series.llm?.provider || undefined,@@ -182,6 +185,7 @@ function ArcHeader({ series, onSeriesUpdate, onIssuesUpdate, onFlushPending }) {};const runGenerate = async () => {+ setConfirmingRegen(false);setRunning('generate');const result = await withFlush(() =>generatePipelineArcOverview(series.id, { commit: true, ...llmOverride }).catch((err) => {@@ -194,6 +198,24 @@ function ArcHeader({ series, onSeriesUpdate, onIssuesUpdate, onFlushPending }) {onSeriesUpdate(result.series);toast.success('Arc generated and saved');};++ const toggleArcLock = async () => {+ const next = !arcLocked;+ setLockBusy(true);+ const updated = await updatePipelineSeries(series.id, {+ locked: { ...(series.locked || {}), arc: next },+ }).catch((err) => {+ toast.error(err.message || 'Failed to update lock');+ return null;+ });+ setLockBusy(false);+ if (!updated) return;+ onSeriesUpdate(updated);+ if (next) setConfirmingRegen(false);+ toast.success(next+ ? 'Arc locked — regeneration and auto-resolve are now blocked'+ : 'Arc unlocked');+ };const runVerify = async () => {setRunning('verify');const result = await withFlush(() =>@@ -269,6 +291,12 @@ function ArcHeader({ series, onSeriesUpdate, onIssuesUpdate, onFlushPending }) {arc && (arc.logline || arc.summary || arc.protagonistArc || arc.themes?.length));const generateBtnLabel = hasGeneratedArc ? 'Regenerate arc' : 'Generate arc';+ // First-time Generate has nothing to overwrite, so skip the confirm prompt.+ const handleGenerateClick = () => {+ if (arcLocked) return;+ if (hasGeneratedArc) setConfirmingRegen(true);+ else runGenerate();+ };return (<section className="bg-port-card border border-port-border rounded-lg p-4 space-y-3">@@ -280,10 +308,31 @@ function ArcHeader({ series, onSeriesUpdate, onIssuesUpdate, onFlushPending }) {onSeriesUpdate={onSeriesUpdate}disabled={!!running}/>+ {hasGeneratedArc ? (+ <button+ type="button"+ onClick={toggleArcLock}+ disabled={lockBusy || !!running}+ title={arcLocked+ ? 'Arc is locked — click to unlock and allow regeneration'+ : 'Lock the arc to prevent regeneration and auto-resolve from overwriting it'}+ className={`inline-flex items-center gap-1.5 px-3 py-1.5 rounded text-sm font-medium border transition-colors disabled:opacity-40 ${+ arcLocked+ ? 'bg-port-warning/10 text-port-warning border-port-warning/40 hover:bg-port-warning/20'+ : 'bg-port-bg text-gray-400 border-port-border hover:text-white hover:border-port-accent/40'+ }`}+ >+ {lockBusy+ ? <Loader2 size={14} className="animate-spin" />+ : (arcLocked ? <Lock size={14} /> : <Unlock size={14} />)}+ {arcLocked ? 'Locked' : 'Lock arc'}+ </button>+ ) : null}<buttontype="button"- onClick={runGenerate}- disabled={!!running}+ onClick={handleGenerateClick}+ disabled={!!running || arcLocked || confirmingRegen}+ title={arcLocked ? 'Arc is locked — unlock to regenerate' : undefined}className="inline-flex items-center gap-1.5 px-3 py-1.5 rounded text-sm font-medium border transition-colors bg-port-bg text-port-accent border-port-border hover:border-port-accent/40 disabled:opacity-40">{running === 'generate' ? <Loader2 size={14} className="animate-spin" /> : <Sparkles size={14} />}@@ -304,6 +353,35 @@ function ArcHeader({ series, onSeriesUpdate, onIssuesUpdate, onFlushPending }) {</div></div>+ {confirmingRegen ? (+ <div className="bg-port-bg border border-port-warning/30 rounded-lg p-3 space-y-2">+ <p className="text-sm text-white">Regenerate the entire arc?</p>+ <p className="text-xs text-gray-400">+ This overwrites the arc logline, summary, protagonist arc, themes, and every volume / season outline.+ Click <em>Lock arc</em> above first to preserve your approved version — once locked, regeneration and auto-resolve are blocked until you unlock.+ </p>+ <div className="flex items-center gap-2">+ <button+ type="button"+ onClick={runGenerate}+ disabled={!!running}+ className="inline-flex items-center gap-1.5 px-3 py-1.5 rounded text-sm font-medium bg-port-warning/20 text-port-warning border border-port-warning/40 hover:bg-port-warning/30 disabled:opacity-40"+ >+ {running === 'generate' ? <Loader2 size={14} className="animate-spin" /> : <Sparkles size={14} />}+ Confirm regenerate+ </button>+ <button+ type="button"+ onClick={() => setConfirmingRegen(false)}+ disabled={!!running}+ className="px-3 py-1.5 rounded text-sm text-gray-400 hover:text-white"+ >+ Cancel+ </button>+ </div>+ </div>+ ) : null}+{hasGeneratedArc ? <VerifyScopeHint scope={VERIFY_ARC_SCOPE} /> : null}{arc ? (@@ -318,10 +396,11 @@ function ArcHeader({ series, onSeriesUpdate, onIssuesUpdate, onFlushPending }) {<VerifyResultsissues={verifyIssues}onDismiss={() => setVerifyIssues(null)}- onResolveAll={resolveAll}- onResolveOne={resolveOne}+ onResolveAll={arcLocked ? null : resolveAll}+ onResolveOne={arcLocked ? null : resolveOne}resolvingAll={running === 'resolve' && resolvingIdx.size === 0}resolvingIdx={resolvingIdx}+ lockedNote={arcLocked ? 'Arc is locked — unlock above to enable auto-resolve.' : null}/>) : null}</section>@@ -464,10 +543,15 @@ function ArcContent({ series, onSeriesUpdate }) {);}-function VerifyResults({ issues, onDismiss, onResolveAll, onResolveOne, resolvingAll, resolvingIdx, title = 'Verification' }) {+function VerifyResults({ issues, onDismiss, onResolveAll, onResolveOne, resolvingAll, resolvingIdx, title = 'Verification', lockedNote = null }) {const busy = resolvingAll || (resolvingIdx && resolvingIdx.size > 0);return (<div className="border border-port-border rounded p-3 bg-port-bg/50 space-y-2">+ {lockedNote ? (+ <p className="text-[11px] text-port-warning italic flex items-center gap-1.5">+ <Lock size={11} /> {lockedNote}+ </p>+ ) : null}<div className="flex items-center justify-between gap-2 flex-wrap"><h3 className="text-xs uppercase tracking-wider text-gray-500">{title} — {issues.length} issue{issues.length === 1 ? '' : 's'}</h3><div className="flex items-center gap-2">diff --git a/client/src/components/pipeline/VisualStylePicker.jsx b/client/src/components/pipeline/VisualStylePicker.jsxindex 400e7c67b7..36db1ee35a 100644--- a/client/src/components/pipeline/VisualStylePicker.jsx+++ b/client/src/components/pipeline/VisualStylePicker.jsx@@ -107,7 +107,7 @@ export default function VisualStylePicker({</button>{open && (- <div className="absolute right-0 mt-1 w-80 max-h-[70vh] overflow-y-auto bg-port-card border border-port-border rounded-lg shadow-lg z-30 p-1">+ <div className="absolute right-0 mt-1 w-80 max-h-[70vh] overflow-y-auto bg-port-card border border-port-border rounded-lg shadow-lg z-50 p-1">{hasValue && (<buttontype="button"diff --git a/server/routes/pipeline.js b/server/routes/pipeline.jsindex df0c999518..4e162ebfb9 100644--- a/server/routes/pipeline.js+++ b/server/routes/pipeline.js@@ -166,6 +166,12 @@ const seasonSchema = z.object({status: z.enum(SEASON_STATUSES).optional(),}).passthrough();+// `.passthrough` keeps the door open for future per-season / per-field locks+// without a schema bump — the series sanitizer is the source of truth.+const seriesLockedSchema = z.object(+ Object.fromEntries(seriesSvc.LOCKABLE_STAGES.map((k) => [k, z.boolean().optional()])),+).passthrough();+const seriesCreateSchema = z.object({name: z.string().trim().min(1).max(seriesSvc.NAME_MAX),logline: z.string().trim().max(seriesSvc.LOGLINE_MAX).optional().default(''),@@ -177,6 +183,7 @@ const seriesCreateSchema = z.object({objects: z.array(objectSchema).max(seriesSvc.BIBLE_ENTRIES_PER_SERIES_MAX).optional(),arc: arcSchema.nullable().optional(),seasons: z.array(seasonSchema).max(ARC_LIMITS.SEASONS_PER_SERIES_MAX).optional(),+ locked: seriesLockedSchema.optional(),styleNotes: z.string().trim().max(seriesSvc.STYLE_NOTES_MAX).optional().default(''),visualStyleDefault: visualStyleRefSchema.optional(),targetFormat: z.enum(seriesSvc.TARGET_FORMATS).optional(),@@ -195,6 +202,7 @@ const seriesPatchSchema = z.object({objects: z.array(objectSchema).max(seriesSvc.BIBLE_ENTRIES_PER_SERIES_MAX).optional(),arc: arcSchema.nullable().optional(),seasons: z.array(seasonSchema).max(ARC_LIMITS.SEASONS_PER_SERIES_MAX).optional(),+ locked: seriesLockedSchema.optional(),styleNotes: z.string().trim().max(seriesSvc.STYLE_NOTES_MAX).optional(),visualStyleDefault: visualStyleRefSchema.optional(),targetFormat: z.enum(seriesSvc.TARGET_FORMATS).optional(),diff --git a/server/services/pipeline/arcPlanner.js b/server/services/pipeline/arcPlanner.jsindex cf4aa958f2..2fc0c568c1 100644--- a/server/services/pipeline/arcPlanner.js+++ b/server/services/pipeline/arcPlanner.js@@ -214,6 +214,12 @@ function shapeSeasonOutlines(rawOutlines) {export async function generateArcOverview(seriesId, options = {}) {const series = await getSeries(seriesId);+ if (series.locked?.arc === true) {+ throw makeErr(+ 'Arc is locked — unlock it on the Arc Canvas before regenerating',+ ERR_VALIDATION,+ );+ }const ctx = await buildArcOverviewContext(series);const { content, runId, providerId, model } = await runStagedLLM('pipeline-arc-overview',@@ -656,6 +662,14 @@ export async function resolveVerifyIssues(seriesId, options = {}) {{ status: 400, code: 'PIPELINE_NO_ARC' },);}+ // Resolve rewrites arc + seasons in place, so the lock gates this too.+ // Verify (read-only) stays enabled — the user can act on findings manually.+ if (series.locked?.arc === true) {+ throw new ServerError(+ 'Arc is locked — unlock it before auto-resolving findings',+ { status: 400, code: ERR_VALIDATION },+ );+ }// Load the world once and thread it through verify + resolve so the// refresh-then-resolve path doesn't hit the filesystem twice for the samediff --git a/server/services/pipeline/arcPlanner.test.js b/server/services/pipeline/arcPlanner.test.jsindex 9e9891aa43..1eb716e6b4 100644--- a/server/services/pipeline/arcPlanner.test.js+++ b/server/services/pipeline/arcPlanner.test.js@@ -209,6 +209,15 @@ describe('arcPlanner — generateArcOverview', () => {expect(ctx.worldName).toMatch(/no linked world/i);expect(ctx.worldCategoriesText).toMatch(/none/i);});++ it('throws ERR_VALIDATION + skips the LLM call when arc is locked', async () => {+ const s = await setupSeries();+ await seriesSvc.updateSeries(s.id, { locked: { arc: true } });+ stageRunnerSpy = vi.fn();+ await expect(planner.generateArcOverview(s.id))+ .rejects.toMatchObject({ code: planner.ERR_VALIDATION });+ expect(stageRunnerSpy).not.toHaveBeenCalled();+ });});describe('arcPlanner — generateSeasonEpisodes', () => {diff --git a/server/services/pipeline/series.js b/server/services/pipeline/series.jsindex 24fb487132..e9697e2f68 100644--- a/server/services/pipeline/series.js+++ b/server/services/pipeline/series.js@@ -50,6 +50,17 @@ export const WRITERS_ROOM_WORK_ID_MAX = 64;export const TARGET_FORMATS = Object.freeze(['comic', 'tv', 'comic+tv']);export const ISSUE_COUNT_TARGET_MAX = 999;+export const LOCKABLE_STAGES = Object.freeze(['arc']);++const sanitizeSeriesLocked = (raw = {}) => {+ if (!raw || typeof raw !== 'object') return {};+ const out = {};+ for (const key of LOCKABLE_STAGES) {+ if (raw[key] === true) out[key] = true;+ }+ return out;+};+const DEFAULT_STATE = { series: [] };const sanitizeSeries = (raw) => {@@ -86,6 +97,7 @@ const sanitizeSeries = (raw) => {// files migrate forward without a writer pass — first save backfills.arc: sanitizeArc(raw.arc),seasons: sanitizeSeasonList(raw.seasons),+ locked: sanitizeSeriesLocked(raw.locked),styleNotes: trimTo(raw.styleNotes, STYLE_NOTES_MAX),// Series-level default visual style (catalog id + optional custom prompt).// `null` when the user hasn't picked one — stage-level fallbacks in@@ -142,6 +154,7 @@ export async function createSeries(input = {}) {objects: input.objects || [],arc: input.arc || null,seasons: input.seasons || [],+ locked: input.locked || {},styleNotes: input.styleNotes || '',targetFormat: input.targetFormat || 'comic+tv',issueCountTarget: input.issueCountTarget || 0,@@ -199,6 +212,8 @@ export async function updateSeries(id, patch = {}) {...('objects' in patch ? { objects: patch.objects } : {}),...('arc' in patch ? { arc: patch.arc } : {}),...('seasons' in patch ? { seasons: patch.seasons } : {}),+ // Wholesale replace — `locked: {}` clears every lock; omission preserves.+ ...('locked' in patch ? { locked: patch.locked } : {}),...('styleNotes' in patch ? { styleNotes: patch.styleNotes } : {}),...('visualStyleDefault' in patch ? { visualStyleDefault: patch.visualStyleDefault } : {}),...('targetFormat' in patch ? { targetFormat: patch.targetFormat } : {}),diff --git a/server/services/pipeline/series.test.js b/server/services/pipeline/series.test.jsindex 18d4df30f1..c092177aa0 100644--- a/server/services/pipeline/series.test.js+++ b/server/services/pipeline/series.test.js@@ -131,4 +131,44 @@ describe('pipeline series service', () => {.rejects.toMatchObject({ code: svc.ERR_VALIDATION });});});++ describe('locked field (stage approval)', () => {+ it('defaults to empty object on a fresh series', async () => {+ const s = await svc.createSeries({ name: 'X' });+ expect(s.locked).toEqual({});+ });++ it('persists locked.arc=true through round-trip', async () => {+ const s = await svc.createSeries({ name: 'X' });+ const updated = await svc.updateSeries(s.id, { locked: { arc: true } });+ expect(updated.locked).toEqual({ arc: true });+ // Survives a re-read (sanitizer + atomic write).+ const fresh = await svc.getSeries(s.id);+ expect(fresh.locked).toEqual({ arc: true });+ });++ it('toggling locked.arc back off clears the key', async () => {+ const s = await svc.createSeries({ name: 'X' });+ await svc.updateSeries(s.id, { locked: { arc: true } });+ const cleared = await svc.updateSeries(s.id, { locked: { arc: false } });+ // Only `true` is recorded — false collapses to absent so the on-disk+ // shape stays minimal (matches universeBuilder.sanitizeLocked).+ expect(cleared.locked).toEqual({});+ });++ it('ignores unknown lock keys', async () => {+ const s = await svc.createSeries({+ name: 'X',+ locked: { arc: true, bogus: true, premise: true },+ });+ expect(s.locked).toEqual({ arc: true });+ });++ it('omitting locked from patch preserves existing locks', async () => {+ const s = await svc.createSeries({ name: 'X', locked: { arc: true } });+ const updated = await svc.updateSeries(s.id, { logline: 'new logline' });+ expect(updated.locked).toEqual({ arc: true });+ expect(updated.logline).toBe('new logline');+ });+ });});