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
add Series Autopilot Phase 2: draft cover + back + all interior pages
[._.]/ Adam Eivy988c919429d4
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 3dff0eaedc..dd42a05fc0 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -2,7 +2,7 @@## Added-- **Series Autopilot — drive a whole series toward "story-ready" autonomously (Phase 1).** A new `POST /api/pipeline/series/:id/autopilot/start` runs a *conductor* that inspects the series' current state and walks every missing step in order — generate arc → generate episodes per volume → verify arc → per-issue beat sheets → per-issue text stages (prose + scripts) → structural comic-script gate → series-level editorial review — by composing the existing pipeline service functions (it never re-implements generation). The "what's next" decision is a **pure resolver over the canonical records**, so it is non-destructive and resumable: anything already `ready`/`edited` is skipped (every pass runs `force:false`), and on restart you just start again and it picks up at the first still-missing step (a partially-built series is never clobbered). Progress streams over SSE (`/autopilot/progress`); `/autopilot/cancel` stops it (propagating to the active child runner); `/autopilot/status` exposes a thin persisted `series.autopilot` marker for resume/paused UI. Gated on the **cos** autonomy domain: `off` rejects the start (409), `dry-run` emits a no-side-effect `plan` of what it would do, `execute` runs and meters the daily cos action budget (pausing when exhausted). The arc-verify and editorial loops are **bounded** and **pause for human review** when they can't converge (arc verification can surface fresh findings every pass) — the residual findings are persisted on the marker. Boot recovery demotes a marker stuck at `running` to `paused`. Known scope: comic-script verification is a structural parse gate only (a craft-level LLM verify is a follow-up), and draft cover/page rendering plus CoS gap-filing are Phase 2/3. (`server/services/pipeline/seriesAutopilot.js`, `server/routes/pipeline/autopilot.js`, `server/routes/pipeline/index.js`, `server/services/pipeline/series.js`, `server/index.js`)+- **Series Autopilot — drive a whole series end-to-end autonomously.** A new `POST /api/pipeline/series/:id/autopilot/start` runs a *conductor* that inspects the series' current state and walks every missing step in order — generate arc → generate episodes per volume → verify arc → per-issue beat sheets → per-issue text stages (prose + scripts) → structural comic-script gate → series-level editorial review → **draft cover + back cover + all interior comic pages** — by composing the existing pipeline service functions (it never re-implements generation). The "what's next" decision is a **pure resolver over the canonical records**, so it is non-destructive and resumable: anything already `ready`/`edited`/rendered is skipped (every pass runs `force:false`), and on restart you just start again and it picks up at the first still-missing step (a partially-built series is never clobbered). Progress streams over SSE (`/autopilot/progress`); `/autopilot/cancel` stops it (propagating to the active child runner); `/autopilot/status` exposes a thin persisted `series.autopilot` marker for resume/paused UI. Gated on the **cos** autonomy domain: `off` rejects the start (409), `dry-run` emits a no-side-effect `plan` of what it would do, `execute` runs and meters the daily cos action budget (pausing when exhausted — every draft render is one budget-gated action, since a comic is many GPU jobs). The arc-verify and editorial loops are **bounded** and **pause for human review** when they can't converge (arc verification can surface fresh findings every pass) — the residual findings are persisted on the marker. Draft renders are fire-and-forget proof-quality jobs whose in-flight job ids are persisted onto each cover/page slot (so a resumed run never re-renders an already-queued slot). Boot recovery demotes a marker stuck at `running` to `paused`. Remaining follow-ups: a craft-level LLM comic-script verify (today's script gate is a structural parse only) and auto-filing CoS tasks for capability gaps. (`server/services/pipeline/seriesAutopilot.js`, `server/routes/pipeline/autopilot.js`, `server/routes/pipeline/index.js`, `server/services/pipeline/series.js`, `server/index.js`)- **"Describe from prose" button on the Nouns stage backfills missing descriptions — and flags the nouns the manuscript can't describe.** Extracted nouns (characters/places/objects) often land with a name but no description, so a generated reference image has nothing to work from but the name. The new button writes a description for every undescribed noun that appears in the issue, using **only** what the prose actually establishes — and, crucially, it does **not** invent. This is the inverse of "Extract from prose" (which commits opinionated, renderable choices when the prose is silent so it never leaves a blank): a noun the manuscript names but never describes comes back graded `none` and stays blank, surfacing in a persistent red-flag banner ("The manuscript is thin on description for N nouns…") rather than being papered over with a fabricated look. Nouns the prose describes only in passing are graded `thin` (the grounded fragment is filled, with a note on what's missing). Strictly prose-grounded descriptions double as a manuscript-quality check: if the story can't describe its own people and places, that's a signal the prose needs enriching, not the bible. Fills only empty, unlocked entries (never clobbers an existing description or a locked one), re-reads freshest state at write time, and persists the gap report on the prose stage so the banner survives reload. Driven by a new strictly-grounded `pipeline-canon-describe-from-prose` stage prompt. (`data.reference/prompts/stages/pipeline-canon-describe-from-prose.md`, `scripts/migrations/089-canon-describe-from-prose-stage.js`, `server/services/universeCanon.js`, `server/routes/pipeline/issues.js`, `server/services/pipeline/issues.js`, `client/src/services/apiPipeline.js`, `client/src/components/pipeline/stages/NounsStage.jsx`)@@ -34,6 +34,8 @@## Fixed+- **The pipeline Nouns stage showed "No description yet" for characters that are actually described.** Characters store their renderable text in `physicalDescription`, but `NounsStage`'s per-kind config omitted `descField`, so `CanonCard` fell back to reading the (usually empty) `description` field — making a fully-described character like `ASTER-9 CHANDELIER` (457 chars of `physicalDescription`) read as undescribed, and also leaving its description un-editable inline (the editor gates on `descField`). Wired `NounsStage`'s `KINDS` to the same `descField`/`descFieldFallback`/`descFieldMax` the universe view (`UniverseCanonSection`) already uses — characters → `physicalDescription` (fallback `description`), objects → `description` (fallback `significance`), places → `description` — so the pipeline and universe canon views render and edit identically. (`client/src/components/pipeline/stages/NounsStage.jsx`)+- **A TUI run whose model id is rejected by the backend now fails (and falls back) instead of returning a screen-scrape of the error.** When a Claude Code TUI run hit a non-recoverable model-id rejection — e.g. a bare Anthropic id like `claude-opus-4-8` passed to a Bedrock-backed Claude Code, which answers `API Error (…): 400 The provided model identifier is invalid` and suggests `global.anthropic.…` — the TUI just sat at an unanswered prompt. The one-shot runner saw output go idle, marked the run `success`, and (no `tui-response.txt` having been written) scraped the error *screen* and returned it as the model's "response." Downstream that surfaced as a baffling failure: AI manuscript Reformat reported `AI reformat changed the wording` (its integrity guard correctly rejecting the screen garbage), while other TUI-backed stages silently consumed the noise. The one-shot TUI runner now recognizes Claude Code's terminal model-id rejection (Bedrock 400 "model identifier is invalid" and Anthropic 404 `not_found_error`) and fails the run as `MODEL_NOT_FOUND`, so `runPromptThroughProvider` benches the provider and retries its configured fallback (e.g. `claude-code-tui` → `claude-code-bedrock`, whose Bedrock ids are valid) — turning a silent corruption into a transparent recovery, or, with no fallback, an actionable error. The check is line-anchored, requires the 400/404 to immediately follow the `API Error` prefix (so a retryable 429/500 Claude Code auto-retries is left alone), and is deliberately scoped to the one-shot runner — *not* the shared fallback detector the long-running agent spawn paths use, so an agent that merely echoes the error line in its own output (cat-ing a log, running the tests, investigating this very failure) can't have its run killed and misclassified. (`server/lib/aiToolkit/errorDetection.js`, `server/lib/tuiPromptRunner.js`)- **The "Verify arc" hover tooltip on the series arc page no longer renders clipped behind the nav and other cards.** The `VerifyScopeTooltip` panel sat in the arc-header's button row as an `absolute`-positioned child. That row scrolls horizontally (the "Derive from manuscript" button overflows on narrow widths), so its `overflow` clipped the popover and trapped it in an ancestor stacking context — no `z-index` could lift it above the sidebar nav or the cards below. Rewrote it as a portal-rendered (`createPortal` to `<body>`), `position: fixed` popover anchored below-right of its trigger via the live `getBoundingClientRect()`, so it floats above everything and is clamped on-screen on narrow viewports. (A prior pass bumped the z-index to `z-[60]`, which didn't help because the clip was an `overflow`/stacking-context problem, not a layering one.) `aria-describedby` wiring is preserved. (`client/src/components/pipeline/ArcCanvas.jsx`)diff --git a/server/services/pipeline/seriesAutopilot.js b/server/services/pipeline/seriesAutopilot.jsindex 670a09d00c..71fe0e6b34 100644--- a/server/services/pipeline/seriesAutopilot.js+++ b/server/services/pipeline/seriesAutopilot.js@@ -37,12 +37,16 @@* script parse into pages+panels). A real craft-level LLM script-verify prompt* is a deliberate Phase-3 follow-up, not silently assumed solved.*- * NOT YET IMPLEMENTED — draft visuals (cover + all interior pages). The render- * endpoints persist their job ids at the ROUTE layer (the enqueue helpers only- * return a jobId the caller must record), so faithful draft rendering needs that- * persistence replicated per slot. Gated behind VISUAL_DRAFT_ENABLED (false) so- * the Phase-1 terminal is "text-ready + editorial review"; flip the flag and- * implement `runVisualDraft` in Phase 2.+ * DRAFT VISUALS (Phase 2, VISUAL_DRAFT_ENABLED): once a story is text-ready,+ * extract comic pages from the script (if not already), then enqueue PROOF+ * (draft) renders for the front cover, back cover, and every interior page —+ * replicating the per-slot jobId persistence the render routes do at the route+ * layer (buildRenderSlot → updateStageWithLatest). Renders are async media jobs:+ * we fire the kickoff, persist the in-flight slot, and do NOT block on pixels+ * (mirrors autoRunner's episodeVideo fire-and-forget). Each render is one+ * billable cos action and is budget-gated individually (a comic is many GPU+ * jobs), and already-enqueued slots are skipped so a resumed run doesn't+ * re-render. Gated behind `options.includeVisual`.*/import { randomUUID } from 'crypto';@@ -52,8 +56,11 @@ import { parseComicScript } from '../../lib/comicScriptParser.js';import { loadState } from '../cosState.js';import { getDomainBudgetStatus, recordDomainUsage } from '../domainUsage.js';import { getSeries, updateSeries } from './series.js';-import { listIssues, getIssue, isStageReady } from './issues.js';+import { listIssues, getIssue, isStageReady, updateStageWithLatest } from './issues.js';import { compareIssuesByPosition } from './arcPlanner.js';+import { enqueueComicCover, enqueueComicBackCover, enqueueVisualComicPage } from './visualStages.js';+import { slotKeyForVariant } from './owners.js';+import { buildRenderSlot } from '../../lib/renderSlot.js';import {generateArcOverview,commitSeasonsWithRemap,@@ -77,8 +84,9 @@ const runs = new Map();export const MAX_ARC_VERIFY_ROUNDS = 3;export const MAX_EDITORIAL_ROUNDS = 2;-// Phase-2 flag — see module header. While false the terminal is text + editorial.-export const VISUAL_DRAFT_ENABLED = false;+// When true, a comic-target run with `includeVisual` proceeds past the text ++// editorial terminal into draft cover/page rendering (see runVisualDraft).+export const VISUAL_DRAFT_ENABLED = true;// Severities that block a verify/review gate (low is informational).const ARC_BLOCKING = new Set(['high', 'medium']);@@ -130,6 +138,34 @@ export function scriptStructurallyReady(issue) {return pages.some((p) => Array.isArray(p.panels) && p.panels.length > 0);}+// A render slot counts as "enqueued" once it carries a jobId or a stamped+// filename (proof or final). Draft rendering only kicks off proof renders, but+// we accept either so a re-run never re-renders a slot the user already+// finalized manually.+const slotEnqueued = (slot) => !!(+ slot && (slot.proofImage?.jobId || slot.proofImage?.filename+ || slot.finalImage?.jobId || slot.finalImage?.filename)+);+const pageEnqueued = (page) => !!(+ page && (page.proofImage?.jobId || page.proofImage?.filename+ || page.finalImage?.jobId || page.finalImage?.filename)+);++/**+ * Has an issue's comic art been drafted? True once pages exist, the front cover+ * is enqueued, any authored back cover is enqueued, and every page that HAS+ * panels is enqueued. Pages with no panels can't be rendered, so they don't+ * block readiness.+ */+export function visualReady(issue) {+ const cp = issue.stages?.comicPages;+ const pages = Array.isArray(cp?.pages) ? cp.pages : [];+ if (pages.length === 0) return false;+ if (!slotEnqueued(cp?.cover)) return false;+ if (cp?.backCover?.script && !slotEnqueued(cp?.backCover)) return false;+ return pages.every((p) => (Array.isArray(p.panels) && p.panels.length > 0 ? pageEnqueued(p) : true));+}+/*** Return the first unmet step for a series given its canonical records and the* in-run accumulator (`runState`). Pure — caller supplies fresh state.@@ -192,10 +228,11 @@ export function resolveNextStep(series, issues, runState = {}, options = {}) {return { kind: 'editorialReview', reason: 'editorial review not yet run this run' };}- // STEP 6 — draft visuals (Phase 2; gated off for now).+ // STEP 6 — draft visuals (cover + back + all interior pages).if (VISUAL_DRAFT_ENABLED && options.includeVisual && isComicTarget(series)) {for (const issue of ordered) {if (setHas(runState.visualDrafted, issue.id)) continue;+ if (visualReady(issue)) continue;return { kind: 'visualDraft', issueId: issue.id, reason: 'comic pages not yet drafted' };}}@@ -403,6 +440,108 @@ async function runEditorial(sId, record) {return {};}+// Turn a render-enqueue result into the { slotKey, slot } pair the render+// routes persist (proof → proofImage, final → finalImage).+const slotFromRenderResult = (result) => {+ const slotKey = slotKeyForVariant(result.variant);+ return { slotKey, slot: buildRenderSlot({ slotKey, jobId: result.jobId, prompt: result.prompt, fromProof: result.fromProof }) };+};++// Persist an in-flight render slot the way the render routes do: enqueue the+// proof render, then splice the returned jobId onto the freshest persisted+// cover/backCover slot via updateStageWithLatest.+async function enqueueCoverDraft(issueId, slotField, enqueueFn) {+ const { slotKey, slot } = slotFromRenderResult(await enqueueFn(issueId, { target: 'proof' }));+ await updateStageWithLatest(issueId, 'comicPages', (current) => {+ const currentSlot = current?.[slotField] || {};+ return { [slotField]: { ...currentSlot, [slotKey]: slot } };+ });+}++async function enqueuePageDraft(issueId, pageIndex) {+ const { slotKey, slot } = slotFromRenderResult(await enqueueVisualComicPage(issueId, { pageIndex, target: 'proof' }));+ await updateStageWithLatest(issueId, 'comicPages', (current) => {+ const pages = Array.isArray(current?.pages) ? current.pages : [];+ if (!pages[pageIndex]) return {};+ const next = [...pages];+ next[pageIndex] = { ...pages[pageIndex], [slotKey]: slot };+ return { status: 'edited', pages: next };+ });+}++async function runVisualDraft(sId, issueId, record) {+ record.runState.visualDrafted.add(issueId);+ let issue = await getIssue(issueId);+ let cp = issue.stages?.comicPages;++ // 1. Seed pages + cover concepts from the comic script if not already done+ // (mirrors the extract-pages route; pure parse, no LLM).+ if (!(Array.isArray(cp?.pages) && cp.pages.length > 0)) {+ const source = (issue.stages?.comicScript?.output || '').trim();+ if (source) {+ const { pages, coverConcept, backCoverConcept } = parseComicScript(source);+ await updateStageWithLatest(issueId, 'comicPages', (current) => {+ const coverScript = current?.cover?.script || '';+ const backScript = current?.backCover?.script || '';+ return {+ status: pages.length ? 'ready' : 'empty',+ pages,+ cover: coverConcept && !coverScript ? { script: coverConcept, imageJobId: null, prompt: null } : (current?.cover ?? null),+ backCover: backCoverConcept && !backScript ? { script: backCoverConcept, imageJobId: null, prompt: null } : (current?.backCover ?? null),+ errorMessage: '',+ };+ });+ issue = await getIssue(issueId);+ cp = issue.stages?.comicPages;+ }+ }++ const pageCount = Array.isArray(cp?.pages) ? cp.pages.length : 0;+ if (pageCount === 0) {+ broadcast(sId, { type: 'step:skip', kind: 'visualDraft', issueId, reason: 'no comic pages to render (script did not parse)' });+ return {};+ }++ // Budget-gate + bill each render individually — a comic is many GPU jobs.+ // A failed enqueue (e.g. a page with no panels) is surfaced and skipped.+ const enqueueOne = async (target, fn) => {+ const budget = await getDomainBudgetStatus('cos');+ if (!budget.withinBudget) return { pause: true, reason: `daily cos ${budget.exceeded} budget reached` };+ try {+ await fn();+ await recordDomainUsage('cos', { actions: 1 });+ broadcast(sId, { type: 'render:queued', issueId, target });+ } catch (err) {+ broadcast(sId, { type: 'step:skip', kind: 'visualDraft', issueId, target, reason: (err?.message || String(err)).slice(0, 200) });+ }+ return {};+ };++ // 2. Front cover.+ if (!slotEnqueued(cp?.cover)) {+ const r = await enqueueOne('cover', () => enqueueCoverDraft(issueId, 'cover', enqueueComicCover));+ if (r.pause) return r;+ }+ // 3. Back cover (only when a concept/script exists to render).+ issue = await getIssue(issueId);+ cp = issue.stages?.comicPages;+ if (cp?.backCover?.script && !slotEnqueued(cp?.backCover)) {+ const r = await enqueueOne('backCover', () => enqueueCoverDraft(issueId, 'backCover', enqueueComicBackCover));+ if (r.pause) return r;+ }+ // 4. Every interior page (re-read per page so each splice merges fresh state).+ for (let i = 0; i < pageCount; i += 1) {+ if (record.cancelRequested) return { canceled: true };+ const fresh = await getIssue(issueId);+ const page = fresh.stages?.comicPages?.pages?.[i];+ if (!page || !Array.isArray(page.panels) || page.panels.length === 0) continue;+ if (pageEnqueued(page)) continue;+ const r = await enqueueOne(`page ${i + 1}`, () => enqueuePageDraft(issueId, i));+ if (r.pause) return r;+ }+ return {};+}+async function dispatchStep(sId, step, record) {switch (step.kind) {case 'generateArc': {@@ -429,6 +568,8 @@ async function dispatchStep(sId, step, record) {return runScriptVerify(sId, step.issueId, record);case 'editorialReview':return runEditorial(sId, record);+ case 'visualDraft':+ return runVisualDraft(sId, step.issueId, record);default:return {};}@@ -458,7 +599,8 @@ function buildDryRunPlan(series, issues, options) {if (isComicTarget(series)) plan.push({ kind: 'scriptVerify', count: ordered.length });plan.push({ kind: 'editorialReview', count: 1, note: `up to ${MAX_EDITORIAL_ROUNDS} rounds` });if (VISUAL_DRAFT_ENABLED && options.includeVisual && isComicTarget(series)) {- plan.push({ kind: 'visualDraft', count: ordered.length });+ const visualNeeded = ordered.filter((i) => !visualReady(i)).length;+ if (visualNeeded) plan.push({ kind: 'visualDraft', count: visualNeeded, note: 'cover + back + all pages (draft)' });}return plan;}diff --git a/server/services/pipeline/seriesAutopilot.test.js b/server/services/pipeline/seriesAutopilot.test.jsindex 8daa63f7f5..4361f33bb3 100644--- a/server/services/pipeline/seriesAutopilot.test.js+++ b/server/services/pipeline/seriesAutopilot.test.js@@ -75,12 +75,19 @@ vi.mock('./manuscriptFix.js', () => ({acceptManuscriptFix: vi.fn(async () => ({})),}));+const visualSpies = {+ enqueueComicCover: vi.fn(async () => ({ jobId: 'job-cover', prompt: 'p', variant: 'proof', fromProof: false })),+ enqueueComicBackCover: vi.fn(async () => ({ jobId: 'job-back', prompt: 'p', variant: 'proof', fromProof: false })),+ enqueueVisualComicPage: vi.fn(async (_issueId, { pageIndex }) => ({ jobId: `job-page-${pageIndex}`, prompt: 'p', variant: 'proof', fromProof: false })),+};+vi.mock('./visualStages.js', () => visualSpies);+// Real services + the unit under test (imported AFTER the mocks above).const seriesSvc = await import('./series.js');const seasonsSvc = await import('./seasons.js');const issuesSvc = await import('./issues.js');const autopilot = await import('./seriesAutopilot.js');-const { resolveNextStep, requiredScriptStages, scriptStructurallyReady } = autopilot;+const { resolveNextStep, requiredScriptStages, scriptStructurallyReady, visualReady } = autopilot;// A comic script string that parseComicScript turns into >=1 page/panel.const VALID_SCRIPT = 'PAGE 1\nPANEL 1\nA scene.';@@ -169,7 +176,7 @@ describe('resolveNextStep (pure)', () => {expect(step.kind).toBe('editorialReview');});- it('is done once editorial review has run', () => {+ it('is done once editorial review has run (no visuals requested)', () => {const step = resolveNextStep(comic,[issue({ stages: { idea: ready(), comicScript: ready(VALID_SCRIPT) } })],@@ -178,6 +185,34 @@ describe('resolveNextStep (pure)', () => {expect(step.kind).toBe('done');});+ it('asks for visual draft when includeVisual and pages are not rendered', () => {+ const step = resolveNextStep(+ comic,+ [issue({ stages: { idea: ready(), comicScript: ready(VALID_SCRIPT) } })],+ { arcVerified: true, scriptChecked: new Set(['iss1']), editorialReviewed: true },+ { includeVisual: true },+ );+ expect(step).toMatchObject({ kind: 'visualDraft', issueId: 'iss1' });+ });++ it('is done when visuals are already rendered', () => {+ const renderedStages = {+ idea: ready(),+ comicScript: ready(VALID_SCRIPT),+ comicPages: {+ cover: { proofImage: { jobId: 'j' } },+ pages: [{ panels: [{ description: 'x' }], proofImage: { jobId: 'p0' } }],+ },+ };+ const step = resolveNextStep(+ comic,+ [issue({ stages: renderedStages })],+ { arcVerified: true, scriptChecked: new Set(['iss1']), editorialReviewed: true },+ { includeVisual: true },+ );+ expect(step.kind).toBe('done');+ });+it('does not run script verify for a tv-only target', () => {const tv = { targetFormat: 'tv', arc: { logline: 'L' }, seasons: [{ id: 'se1', number: 1 }] };const step = resolveNextStep(@@ -204,6 +239,30 @@ describe('requiredScriptStages / scriptStructurallyReady', () => {});});+describe('visualReady', () => {+ it('is false with no pages, true once cover + all paneled pages are enqueued', () => {+ expect(visualReady({ stages: { comicPages: { pages: [] } } })).toBe(false);+ // pages but cover not enqueued+ expect(visualReady({ stages: { comicPages: { pages: [{ panels: [{}], proofImage: { jobId: 'p' } }] } } })).toBe(false);+ // cover + page enqueued+ expect(visualReady({+ stages: { comicPages: { cover: { proofImage: { jobId: 'c' } }, pages: [{ panels: [{}], proofImage: { jobId: 'p' } }] } },+ })).toBe(true);+ });++ it('does not block on a page that has no panels', () => {+ expect(visualReady({+ stages: { comicPages: { cover: { finalImage: { filename: 'c.png' } }, pages: [{ panels: [] }] } },+ })).toBe(true);+ });++ it('requires an authored back cover to be enqueued', () => {+ expect(visualReady({+ stages: { comicPages: { cover: { proofImage: { jobId: 'c' } }, backCover: { script: 'back' }, pages: [{ panels: [{}], proofImage: { jobId: 'p' } }] } },+ })).toBe(false);+ });+});+// ---------------------------------------------------------------------------// Conductor lifecycle + gating (uses real series/issues against file store).// ---------------------------------------------------------------------------@@ -292,6 +351,29 @@ describe('autopilot conductor', () => {autopilot.cancelSeriesAutopilot(seriesId);});+ it('drafts cover + interior pages when includeVisual is set', async () => {+ const { seriesId, issueId } = await seedComplete();+ await autopilot.startSeriesAutopilot(seriesId, { includeVisual: true });+ await waitFor(runFinished(seriesId));+ expect(autopilot.__testing.runs.get(seriesId)?.lastPayload?.type).toBe('complete');+ expect(visualSpies.enqueueComicCover).toHaveBeenCalledTimes(1);+ expect(visualSpies.enqueueVisualComicPage).toHaveBeenCalled();+ // The returned jobIds were persisted onto the comicPages slots.+ const issue = await issuesSvc.getIssue(issueId);+ expect(issue.stages.comicPages.cover.proofImage.jobId).toBe('job-cover');+ expect(issue.stages.comicPages.pages[0].proofImage.jobId).toBe('job-page-0');+ const series = await seriesSvc.getSeries(seriesId);+ expect(series.autopilot?.status).toBe('done');+ });++ it('does not render visuals when includeVisual is false', async () => {+ const { seriesId } = await seedComplete();+ await autopilot.startSeriesAutopilot(seriesId, { includeVisual: false });+ await waitFor(runFinished(seriesId));+ expect(visualSpies.enqueueComicCover).not.toHaveBeenCalled();+ expect(visualSpies.enqueueVisualComicPage).not.toHaveBeenCalled();+ });+it('recoverStuckAutopilots demotes a running marker to paused', async () => {const series = await seriesSvc.createSeries({ name: 'S', logline: 'L', premise: 'P' });await seriesSvc.updateSeries(series.id, { autopilot: { status: 'running', runId: 'dead' } });