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
expose Series Autopilot + canon readiness in the series UI
[._.]/ Adam Eivyaba5191feb30
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex f6a61a3e69..791a7f6a79 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -2,7 +2,7 @@## Added-- **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 → **canon descriptive-integrity gate** → **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`. With opt-in `fileGaps`, capability/quality gaps the run can't resolve on its own — an unparseable script, a failing render, a stalled verify/editorial gate, a run-ending error — are filed as **deduped CoS tasks** (scoped to the pipeline app) so they're tracked rather than silently swallowed. The per-issue script gate runs two checks: a structural parse gate (does the script become pages/panels) and a craft-level LLM verify (`pipeline-script-verify` — un-renderable panels, panel-to-panel flow, dialogue/art balance, within-issue continuity, page-turn placement); the craft gate is advisory (surfaces + files blocking findings without hard-pausing, since the gating quality pass is the series-level editorial review). Before any visual production it also runs a **canon descriptive-integrity gate**: every canon noun (character/place/object) that appears where it would be *drawn* — the comic-script panel descriptions, not prose narration — must have a description, or the run **pauses for human review** (an artist can't render a name). The visual-source distinction is deliberate: an off-page character named only in narration is never drawn, so it's a Nouns-stage quality note, not a production blocker. The same check is exposed for the pipeline UI via `GET /api/pipeline/issues/:id/canon-readiness` and `GET /api/pipeline/series/:id/canon-readiness` (read-only, deterministic — reuses the committed canon name-matchers and `getSeriesCanon`). (`server/services/pipeline/seriesAutopilot.js`, `server/services/pipeline/scriptVerify.js`, `server/services/pipeline/canonReadiness.js`, `server/routes/pipeline/canon.js`, `data.reference/prompts/stages/pipeline-script-verify.md`, `scripts/migrations/090-script-verify-stage.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 → **canon descriptive-integrity gate** → **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`. With opt-in `fileGaps`, capability/quality gaps the run can't resolve on its own — an unparseable script, a failing render, a stalled verify/editorial gate, a run-ending error — are filed as **deduped CoS tasks** (scoped to the pipeline app) so they're tracked rather than silently swallowed. The per-issue script gate runs two checks: a structural parse gate (does the script become pages/panels) and a craft-level LLM verify (`pipeline-script-verify` — un-renderable panels, panel-to-panel flow, dialogue/art balance, within-issue continuity, page-turn placement); the craft gate is advisory (surfaces + files blocking findings without hard-pausing, since the gating quality pass is the series-level editorial review). Before any visual production it also runs a **canon descriptive-integrity gate**: every canon noun (character/place/object) that appears where it would be *drawn* — the comic-script panel descriptions, not prose narration — must have a description, or the run **pauses for human review** (an artist can't render a name). The visual-source distinction is deliberate: an off-page character named only in narration is never drawn, so it's a Nouns-stage quality note, not a production blocker. The same check is exposed for the pipeline UI via `GET /api/pipeline/issues/:id/canon-readiness` and `GET /api/pipeline/series/:id/canon-readiness` (read-only, deterministic — reuses the committed canon name-matchers and `getSeriesCanon`). The whole feature is surfaced in the UI by an **Autonomous mode panel** on the series page (`AutopilotPanel`): a Run/Resume button with a run-options popover (draft visuals, file-gaps), live SSE step progress (with the dry-run plan when the cos domain is in dry-run), a Stop control, a paused/done/error banner driven by the persisted marker that lists the residual findings, and a one-click "production readiness" canon check that links each undescribed drawn noun to its issue's Nouns stage. (`server/services/pipeline/seriesAutopilot.js`, `server/services/pipeline/scriptVerify.js`, `server/services/pipeline/canonReadiness.js`, `server/routes/pipeline/canon.js`, `data.reference/prompts/stages/pipeline-script-verify.md`, `scripts/migrations/090-script-verify-stage.js`, `server/routes/pipeline/autopilot.js`, `server/routes/pipeline/index.js`, `server/services/pipeline/series.js`, `server/index.js`, `client/src/components/pipeline/AutopilotPanel.jsx`, `client/src/pages/PipelineSeries.jsx`, `client/src/services/apiPipeline.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`)diff --git a/client/src/components/pipeline/AutopilotPanel.jsx b/client/src/components/pipeline/AutopilotPanel.jsxnew file mode 100644index 0000000000..9c7d24b44b--- /dev/null+++ b/client/src/components/pipeline/AutopilotPanel.jsx@@ -0,0 +1,306 @@+import { useCallback, useEffect, useRef, useState } from 'react';+import { Link } from 'react-router-dom';+import {+ Rocket, Loader2, X, Sliders, ShieldCheck, AlertCircle, CheckCircle2,+ PauseCircle, Play, ScanSearch, ChevronRight,+} from 'lucide-react';+import toast from '../ui/Toast';+import { usePipelineProgress } from '../../hooks/usePipelineProgress';+import {+ startPipelineAutopilot,+ cancelPipelineAutopilot,+ getPipelineAutopilotStatus,+ pipelineAutopilotSseUrl,+ getPipelineSeriesCanonReadiness,+ getPipelineSeries,+ listPipelineIssues,+} from '../../services/api';++const SEVERITY_COLORS = {+ high: 'text-port-error border-port-error/40 bg-port-error/10',+ medium: 'text-port-warning border-port-warning/40 bg-port-warning/10',+ low: 'text-gray-400 border-gray-500/30 bg-gray-700/20',+};++// Human labels for each conductor step kind (matches seriesAutopilot.js).+const STEP_LABELS = {+ generateArc: 'Generating arc',+ generateEpisodes: 'Generating episodes',+ verifyArc: 'Verifying arc',+ beatSheet: 'Generating beat sheets',+ textStages: 'Writing prose + scripts',+ scriptVerify: 'Verifying scripts',+ editorialReview: 'Editorial review',+ canonVerify: 'Checking canon descriptions',+ visualDraft: 'Drafting comic art',+};++const stepLabel = (kind) => STEP_LABELS[kind] || kind;++// Turn an SSE frame into a one-line status string.+function frameLabel(f) {+ if (!f) return null;+ switch (f.type) {+ case 'start': return f.mode === 'dry-run' ? 'Planning (dry-run)…' : 'Starting…';+ case 'note': return f.message;+ case 'step:start': return `${stepLabel(f.kind)}…`;+ case 'step:complete': return `${stepLabel(f.kind)} done`;+ case 'step:skip': return `Skipped ${stepLabel(f.kind)}${f.reason ? ` — ${f.reason}` : ''}`;+ case 'verify:round': return `${f.scope} check — ${f.blocking} blocking of ${f.findings} finding(s)`;+ case 'render:queued': return `Queued draft render: ${f.target}`;+ case 'gap:filed': return `Filed CoS task (${f.gapKind})`;+ case 'paused': return `Paused — ${f.reason}`;+ case 'complete': return f.dryRun ? 'Plan ready' : 'Complete';+ case 'canceled': return 'Canceled';+ case 'error': return `Failed — ${f.error}`;+ default: return f.type;+ }+}++const RUN_ENDED = new Set(['complete', 'canceled', 'error', 'paused']);++function Findings({ items }) {+ if (!items?.length) return null;+ return (+ <ul className="space-y-1.5 mt-2">+ {items.map((f, i) => (+ <li key={i} className={`text-xs p-2 rounded border ${SEVERITY_COLORS[f.severity] || SEVERITY_COLORS.medium}`}>+ <div className="flex items-center gap-2">+ <AlertCircle size={12} />+ <span className="uppercase tracking-wider font-semibold">{f.severity || 'note'}</span>+ {f.location ? <span className="text-gray-500">— {f.location}</span> : null}+ </div>+ <p className="text-gray-200 mt-0.5">{f.problem}</p>+ </li>+ ))}+ </ul>+ );+}++/**+ * Series-level autonomous-mode control: launch / cancel / live progress, a+ * resume-or-paused banner driven by the persisted `series.autopilot` marker,+ * and a production-readiness (canon descriptive-integrity) check.+ */+export default function AutopilotPanel({ series, onSeriesUpdate, onIssuesUpdate }) {+ const seriesId = series?.id;+ const [active, setActive] = useState(false);+ const [starting, setStarting] = useState(false);+ const [mode, setMode] = useState(null);+ const [plan, setPlan] = useState(null);+ const [showOpts, setShowOpts] = useState(false);+ const [includeVisual, setIncludeVisual] = useState(true);+ const [fileGaps, setFileGaps] = useState(false);+ const [canon, setCanon] = useState(null);+ const [canonLoading, setCanonLoading] = useState(false);++ const { latest, frames } = usePipelineProgress(pipelineAutopilotSseUrl, [seriesId], { enabled: active });++ const onSeriesUpdateRef = useRef(onSeriesUpdate);+ const onIssuesUpdateRef = useRef(onIssuesUpdate);+ onSeriesUpdateRef.current = onSeriesUpdate;+ onIssuesUpdateRef.current = onIssuesUpdate;++ // Re-attach to an in-flight run on (re)mount.+ useEffect(() => {+ if (!seriesId) return undefined;+ let canceled = false;+ getPipelineAutopilotStatus(seriesId, { silent: true })+ .then((s) => { if (!canceled && s?.active) setActive(true); })+ .catch(() => null);+ return () => { canceled = true; };+ }, [seriesId]);++ // Capture dry-run plan + mode off the start frame.+ useEffect(() => {+ if (latest?.type === 'start') {+ setMode(latest.mode || null);+ if (Array.isArray(latest.plan)) setPlan(latest.plan);+ }+ }, [latest]);++ // Run-ended handling: refresh series (for the marker) + issues, toast outcome.+ useEffect(() => {+ if (!active || !latest || !RUN_ENDED.has(latest.type)) return;+ setActive(false);+ getPipelineSeries(seriesId, { silent: true }).then((s) => { if (s) onSeriesUpdateRef.current?.(s); }).catch(() => null);+ listPipelineIssues(seriesId, { silent: true }).then((is) => onIssuesUpdateRef.current?.(Array.isArray(is) ? is : [])).catch(() => null);+ if (latest.type === 'complete') toast.success(latest.dryRun ? 'Autopilot plan ready' : 'Autopilot complete — draft is production-ready');+ else if (latest.type === 'canceled') toast.success('Autopilot canceled');+ else if (latest.type === 'paused') toast.warning(`Autopilot paused — ${latest.reason || 'needs review'}`);+ else toast.error(latest.error || 'Autopilot failed');+ }, [active, latest, seriesId]);++ const start = useCallback(async () => {+ setStarting(true);+ setPlan(null);+ const res = await startPipelineAutopilot(seriesId, { includeVisual, fileGaps }, { silent: true })+ .catch((err) => { toast.error(err.message || 'Could not start autopilot'); return null; });+ setStarting(false);+ if (!res) return;+ setMode(res.mode || null);+ setShowOpts(false);+ setActive(true);+ }, [seriesId, includeVisual, fileGaps]);++ const cancel = useCallback(async () => {+ await cancelPipelineAutopilot(seriesId).catch(() => null);+ }, [seriesId]);++ const checkCanon = useCallback(async () => {+ setCanonLoading(true);+ const report = await getPipelineSeriesCanonReadiness(seriesId, { silent: true })+ .catch((err) => { toast.error(err.message || 'Canon check failed'); return null; });+ setCanonLoading(false);+ if (report) setCanon(report);+ }, [seriesId]);++ if (!seriesId) return null;++ const ap = series.autopilot;+ const liveLabel = active ? (frameLabel(latest) || 'Working…') : null;+ const runLabel = ap?.status === 'paused' ? 'Resume autopilot'+ : ap?.status === 'done' ? 'Run autopilot again'+ : 'Run autopilot';++ return (+ <div className="border border-port-border rounded-lg bg-port-card/40">+ <div className="flex items-center gap-2 flex-wrap p-3">+ <Rocket size={15} className="text-port-accent" />+ <span className="text-sm font-medium text-white">Autonomous mode</span>+ <span className="text-xs text-gray-500">drives every missing step to a production-ready draft</span>++ <div className="ml-auto flex items-center gap-2">+ {!active ? (+ <>+ <button+ type="button"+ onClick={() => setShowOpts((v) => !v)}+ className="inline-flex items-center gap-1 px-2 py-1.5 rounded text-xs text-gray-300 hover:text-white border border-port-border bg-port-bg hover:border-port-accent/40"+ title="Run options"+ >+ <Sliders size={12} /> Options+ </button>+ <button+ type="button"+ onClick={start}+ disabled={starting}+ className="inline-flex items-center gap-1.5 px-3 py-1.5 rounded text-sm font-medium border bg-port-bg text-port-accent border-port-border hover:border-port-accent/40 disabled:opacity-40"+ >+ {starting ? <Loader2 size={14} className="animate-spin" /> : (ap?.status === 'paused' ? <Play size={14} /> : <Rocket size={14} />)}+ {runLabel}+ </button>+ </>+ ) : (+ <button+ type="button"+ onClick={cancel}+ className="inline-flex items-center gap-1 px-3 py-1.5 rounded text-xs text-port-warning hover:text-white border border-port-warning/40 bg-port-bg hover:bg-port-warning/10"+ >+ <X size={12} /> Stop+ </button>+ )}+ </div>+ </div>++ {/* Options popover */}+ {showOpts && !active ? (+ <div className="px-3 pb-3 flex flex-col gap-2 border-t border-port-border pt-3">+ <label className="flex items-center gap-2 text-xs text-gray-300">+ <input type="checkbox" checked={includeVisual} onChange={(e) => setIncludeVisual(e.target.checked)} />+ Draft cover + all interior pages (comic targets)+ </label>+ <label className="flex items-center gap-2 text-xs text-gray-300">+ <input type="checkbox" checked={fileGaps} onChange={(e) => setFileGaps(e.target.checked)} />+ File CoS tasks for gaps it can't resolve+ </label>+ <p className="text-[11px] text-gray-500">+ Runs under the CoS auto-run autonomy domain. With it set to <em>dry-run</em>, this only previews the plan.+ </p>+ </div>+ ) : null}++ {/* Live progress */}+ {active ? (+ <div className="px-3 pb-3 border-t border-port-border pt-2">+ <div className="text-xs text-gray-300 flex items-center gap-2">+ <Loader2 size={12} className="animate-spin text-port-accent" />+ {mode === 'dry-run' ? <span className="uppercase tracking-wider text-[10px] text-port-accent">dry-run</span> : null}+ {liveLabel}+ </div>+ {plan ? (+ <div className="mt-2 text-[11px] text-gray-400">+ <div className="uppercase tracking-wider text-gray-500 mb-1">Planned steps</div>+ <ul className="space-y-0.5">+ {plan.map((p, i) => (+ <li key={i} className="flex items-center gap-1.5">+ <ChevronRight size={10} /> {stepLabel(p.kind)} ×{p.count}{p.note ? ` — ${p.note}` : ''}+ </li>+ ))}+ </ul>+ </div>+ ) : null}+ {frames?.length ? (+ <div className="mt-2 max-h-28 overflow-y-auto text-[11px] text-gray-500 space-y-0.5">+ {frames.slice(-6).map((f, i) => <div key={i}>{frameLabel(f)}</div>)}+ </div>+ ) : null}+ </div>+ ) : null}++ {/* Persisted status banner (paused / done / error) */}+ {!active && ap && ap.status && ap.status !== 'idle' && ap.status !== 'running' ? (+ <div className={`px-3 pb-3 border-t pt-2 ${ap.status === 'paused' ? 'border-port-warning/30' : ap.status === 'error' ? 'border-port-error/30' : 'border-port-success/30'}`}>+ <div className="flex items-center gap-2 text-xs">+ {ap.status === 'paused' ? <PauseCircle size={13} className="text-port-warning" />+ : ap.status === 'done' ? <CheckCircle2 size={13} className="text-port-success" />+ : <AlertCircle size={13} className="text-port-error" />}+ <span className={ap.status === 'paused' ? 'text-port-warning' : ap.status === 'done' ? 'text-port-success' : 'text-port-error'}>+ {ap.status === 'paused' ? `Paused at ${stepLabel(ap.currentStep)}` : ap.status === 'done' ? 'Last run completed — draft is production-ready' : 'Last run errored'}+ </span>+ </div>+ {ap.lastError && ap.status !== 'done' ? <p className="text-[11px] text-gray-400 mt-1">{ap.lastError}</p> : null}+ <Findings items={ap.residualFindings} />+ </div>+ ) : null}++ {/* Production readiness (canon descriptive integrity) */}+ <div className="px-3 pb-3 border-t border-port-border pt-2">+ <div className="flex items-center gap-2">+ <ShieldCheck size={13} className="text-gray-400" />+ <span className="text-xs text-gray-300">Production readiness — are all drawn characters/places/objects described?</span>+ <button+ type="button"+ onClick={checkCanon}+ disabled={canonLoading}+ className="ml-auto inline-flex items-center gap-1 px-2 py-1 rounded text-xs text-gray-300 hover:text-white border border-port-border bg-port-bg hover:border-port-accent/40 disabled:opacity-40"+ >+ {canonLoading ? <Loader2 size={12} className="animate-spin" /> : <ScanSearch size={12} />}+ Check+ </button>+ </div>+ {canon ? (+ canon.ready ? (+ <p className="mt-2 text-xs text-port-success flex items-center gap-1.5">+ <CheckCircle2 size={12} /> Every noun that gets drawn has a description.+ </p>+ ) : (+ <div className="mt-2 space-y-2">+ <p className="text-xs text-port-warning">+ {canon.undescribed.length} noun(s) appear where they'd be drawn but have no description — fix before generating art:+ </p>+ {canon.blockingIssues.map((bi) => (+ <div key={bi.issueId} className="text-xs">+ <Link to={`/pipeline/issues/${bi.issueId}/nouns`} className="text-port-accent hover:underline">+ #{bi.number} {bi.title || ''} →+ </Link>+ <span className="text-gray-400"> {bi.none.map((n) => `${n.name} (${n.kind})`).join(', ')}</span>+ </div>+ ))}+ </div>+ )+ ) : null}+ </div>+ </div>+ );+}diff --git a/client/src/components/pipeline/AutopilotPanel.test.jsx b/client/src/components/pipeline/AutopilotPanel.test.jsxnew file mode 100644index 0000000000..24bb6ee1d2--- /dev/null+++ b/client/src/components/pipeline/AutopilotPanel.test.jsx@@ -0,0 +1,94 @@+import { describe, it, expect, vi, beforeEach } from 'vitest';+import { fireEvent, render, screen, waitFor } from '@testing-library/react';+import { MemoryRouter } from 'react-router-dom';++vi.mock('../../services/api', () => ({+ startPipelineAutopilot: vi.fn(),+ cancelPipelineAutopilot: vi.fn(),+ getPipelineAutopilotStatus: vi.fn(),+ pipelineAutopilotSseUrl: (id) => `/api/pipeline/series/${id}/autopilot/progress`,+ getPipelineSeriesCanonReadiness: vi.fn(),+ getPipelineSeries: vi.fn(),+ listPipelineIssues: vi.fn(),+}));+vi.mock('../ui/Toast', () => ({ default: { success: vi.fn(), error: vi.fn(), warning: vi.fn() } }));+// Keep the SSE hook inert so tests don't touch EventSource.+vi.mock('../../hooks/usePipelineProgress', () => ({+ usePipelineProgress: () => ({ latest: null, frames: [] }),+}));++import {+ startPipelineAutopilot,+ getPipelineAutopilotStatus,+ getPipelineSeriesCanonReadiness,+} from '../../services/api';+import AutopilotPanel from './AutopilotPanel';++const renderPanel = (series, props = {}) =>+ render(+ <MemoryRouter>+ <AutopilotPanel series={series} onSeriesUpdate={vi.fn()} onIssuesUpdate={vi.fn()} {...props} />+ </MemoryRouter>,+ );++beforeEach(() => {+ vi.clearAllMocks();+ getPipelineAutopilotStatus.mockResolvedValue({ autopilot: null, active: false });+ startPipelineAutopilot.mockResolvedValue({ runId: 'r1', mode: 'execute', alreadyRunning: false });+});++describe('AutopilotPanel', () => {+ it('starts an autopilot run with the default options', async () => {+ renderPanel({ id: 's1', targetFormat: 'comic' });+ await waitFor(() => expect(getPipelineAutopilotStatus).toHaveBeenCalled());+ fireEvent.click(screen.getByRole('button', { name: /run autopilot/i }));+ await waitFor(() => expect(startPipelineAutopilot).toHaveBeenCalledWith(+ 's1', { includeVisual: true, fileGaps: false }, { silent: true },+ ));+ });++ it('passes options chosen in the popover', async () => {+ renderPanel({ id: 's1', targetFormat: 'comic' });+ await waitFor(() => expect(getPipelineAutopilotStatus).toHaveBeenCalled());+ fireEvent.click(screen.getByRole('button', { name: /options/i }));+ // uncheck draft visuals, check file-gaps+ const checks = screen.getAllByRole('checkbox');+ fireEvent.click(checks[0]); // includeVisual -> false+ fireEvent.click(checks[1]); // fileGaps -> true+ fireEvent.click(screen.getByRole('button', { name: /run autopilot/i }));+ await waitFor(() => expect(startPipelineAutopilot).toHaveBeenCalledWith(+ 's1', { includeVisual: false, fileGaps: true }, { silent: true },+ ));+ });++ it('shows a paused banner with residual findings and a Resume action', async () => {+ renderPanel({+ id: 's1',+ targetFormat: 'comic',+ autopilot: {+ status: 'paused',+ currentStep: 'verifyArc',+ residualFindings: [{ severity: 'high', location: 'season:2', problem: 'plot hole' }],+ },+ });+ await waitFor(() => expect(getPipelineAutopilotStatus).toHaveBeenCalled());+ expect(screen.getByText(/Paused at Verifying arc/i)).toBeInTheDocument();+ expect(screen.getByText(/plot hole/i)).toBeInTheDocument();+ expect(screen.getByRole('button', { name: /resume autopilot/i })).toBeInTheDocument();+ });++ it('renders canon readiness gaps with a link to the issue Nouns page', async () => {+ getPipelineSeriesCanonReadiness.mockResolvedValue({+ ready: false,+ undescribed: [{ id: 'c1', name: 'Kai', kind: 'character' }],+ blockingIssues: [{ issueId: 'iss-9', number: 3, title: 'Backdoor', none: [{ id: 'c1', name: 'Kai', kind: 'character' }] }],+ });+ renderPanel({ id: 's1', targetFormat: 'comic' });+ await waitFor(() => expect(getPipelineAutopilotStatus).toHaveBeenCalled());+ fireEvent.click(screen.getByRole('button', { name: /^check$/i }));+ await waitFor(() => expect(getPipelineSeriesCanonReadiness).toHaveBeenCalledWith('s1', { silent: true }));+ expect(await screen.findByText(/Kai \(character\)/i)).toBeInTheDocument();+ const link = screen.getByRole('link', { name: /#3 Backdoor/i });+ expect(link).toHaveAttribute('href', '/pipeline/issues/iss-9/nouns');+ });+});diff --git a/client/src/pages/PipelineSeries.jsx b/client/src/pages/PipelineSeries.jsxindex 97e671f42c..d08acb203e 100644--- a/client/src/pages/PipelineSeries.jsx+++ b/client/src/pages/PipelineSeries.jsx@@ -18,6 +18,7 @@ import {} from 'lucide-react';import toast from '../components/ui/Toast';import ArcCanvas from '../components/pipeline/ArcCanvas';+import AutopilotPanel from '../components/pipeline/AutopilotPanel';import CatalogCastPanel from '../components/CatalogCastPanel';import TabPills from '../components/ui/TabPills';import {@@ -205,6 +206,12 @@ export default function PipelineSeries() {</button></header>+ <AutopilotPanel+ series={series}+ onSeriesUpdate={updateSeriesFromServer}+ onIssuesUpdate={handleIssuesUpdate}+ />+<ArcCanvasseries={series}issues={issues}diff --git a/client/src/services/apiPipeline.js b/client/src/services/apiPipeline.jsindex d643d4098c..4be72ecb20 100644--- a/client/src/services/apiPipeline.js+++ b/client/src/services/apiPipeline.js@@ -595,6 +595,38 @@ export const getSeriesEditorialStatus = (seriesId, options = {}) =>export const pipelineEditorialSseUrl = (seriesId) =>`/api/pipeline/series/${encodeURIComponent(seriesId)}/editorial/analyze/progress`;+// ---- Series Autopilot (full autonomous mode) ----+// Drives a series from its current state to story-ready (+ draft visuals) by+// composing every pipeline pass. SSE-backed; gated on the cos autonomy domain+// (off → 409, dry-run → plan only, execute → full run).+export const startPipelineAutopilot = (seriesId, opts = {}, options = {}) =>+ request(`/pipeline/series/${encodeURIComponent(seriesId)}/autopilot/start`, {+ method: 'POST',+ body: JSON.stringify(opts),+ ...options,+ });++export const cancelPipelineAutopilot = (seriesId) =>+ request(`/pipeline/series/${encodeURIComponent(seriesId)}/autopilot/cancel`, {+ method: 'POST',+ });++// { autopilot: { status, runId, currentStep, residualFindings, ... } | null, active }+export const getPipelineAutopilotStatus = (seriesId, options = {}) =>+ request(`/pipeline/series/${encodeURIComponent(seriesId)}/autopilot/status`, options);++export const pipelineAutopilotSseUrl = (seriesId) =>+ `/api/pipeline/series/${encodeURIComponent(seriesId)}/autopilot/progress`;++// ---- Canon descriptive-integrity (production readiness) ----+// Read-only: which canon nouns appear where they'd be drawn but lack a+// description (blocking visual production).+export const getPipelineIssueCanonReadiness = (issueId, options = {}) =>+ request(`/pipeline/issues/${encodeURIComponent(issueId)}/canon-readiness`, options);++export const getPipelineSeriesCanonReadiness = (seriesId, options = {}) =>+ request(`/pipeline/series/${encodeURIComponent(seriesId)}/canon-readiness`, options);+// ---- Audio stage ----// Flat list of every voice the active engines expose, namespaced as// `engine:voiceName` (e.g. `kokoro:af_bella`, `piper:lessac-medium`). The