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: pause autopilot without stopping active work
[._.]/ Adam Eivycb8b94550762
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 4a13da7f07..35062a4089 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -11,6 +11,7 @@- **Foundation structure repair retains shrinking corrective progress.** A broad structure rewrite whose specialized arc verification improved from many blockers to a smaller residual used to get one correction attempt and then roll the entire improvement back. The repair now continues a bounded correction sequence while the blocker count stays monotonic, still restoring the original checkpoint if the set grows or cannot clear within the cap.- **A late structure-repair regression no longer erases an independently verified improvement.** The bounded correction sequence could shrink nine arc blockers to one, then let its final attempt trade that residual for five and restore the entire pre-repair plan—discarding the proven one-blocker checkpoint. It now restores the best verified intermediate state, sends that partial improvement through the harsh foundation re-judge, and leaves the full arc gate dirty so the residual must still clear before beats. Model evidence follows the same transaction boundary: the retained repair runs remain provisional, while the regressive run is immediately scored as rejected; a fully reverted repair is also a rejection rather than a schema-invalid response.- **Character-first planning now includes the cast's visual foundation.** The pre-arc character architect used to complete psychology and relationships while its response contract omitted physical description, silhouette, visual identity, and palette, so a graphic-novel series could settle its plot around characters the image pipeline still had to invent. Those identity-bearing fields now participate in completeness, prompt hashing, harsh foundation scoring, and repair; optional sheets such as props, expressions, gestures, and wardrobes are authored when the character's form supports them.+- **Series Autopilot can pause without killing productive work.** The live control used to offer only Stop, which terminates the active provider run even when a long foundation judgment is doing useful work. **Pause safely** now records a graceful request, lets the active step and any provisional repair-verification transaction settle, then persists a resumable manual pause; **Stop now** remains available as the immediate emergency control.- **Arc verification can now repair the per-character milestones it judges.** The verifier already read canonical per-character arcs, but its resolver could only edit the series arc, volumes, and issue synopses, so a contradiction in a character transition was impossible to close and repeated retries rewrote unrelated records instead. Finding-keyed character-arc patches now preserve character and transition IDs, merge only named fields, participate in regression rollback, and migrate existing prompt installations to the sparse contract.diff --git a/client/src/components/pipeline/AutopilotPanel.jsx b/client/src/components/pipeline/AutopilotPanel.jsxindex 7ac3233fe4..3006063009 100644--- a/client/src/components/pipeline/AutopilotPanel.jsx+++ b/client/src/components/pipeline/AutopilotPanel.jsx@@ -10,6 +10,7 @@ import usePersistedOptions, { readBoolean, readInteger, readNumber } from '../..import {startPipelineAutopilot,cancelPipelineAutopilot,+ pausePipelineAutopilot,getPipelineAutopilotStatus,getPipelineAutopilotModelMetrics,pipelineAutopilotSseUrl,@@ -351,6 +352,7 @@ function frameLabel(f) {: `Orchestrator dispatched a pipeline fix (${f.area})${f.title ? `: ${f.title}` : ''}`;// #1617 — immediate cancel ack; the active step finishes before `canceled`.case 'cancel:acknowledged': return 'Cancelling — finishing the active step…';+ case 'pause:acknowledged': return 'Pausing safely — finishing the active step…';case 'paused': return `Paused — ${f.reason}`;case 'complete': return f.dryRun ? 'Plan ready' : 'Complete';case 'canceled': return 'Canceled';@@ -836,6 +838,10 @@ export default function AutopilotPanel({ series, onSeriesUpdate, onIssuesUpdateawait cancelPipelineAutopilot(seriesId).catch(() => null);}, [seriesId]);+ const pause = useCallback(async () => {+ await pausePipelineAutopilot(seriesId).catch(() => null);+ }, [seriesId]);+const checkCanon = useCallback(async () => {setCanonLoading(true);const report = await getPipelineSeriesCanonReadiness(seriesId, { silent: true })@@ -852,6 +858,7 @@ export default function AutopilotPanel({ series, onSeriesUpdate, onIssuesUpdate// disabled "Cancelling…" state so the user gets feedback (and can't re-fire// cancel) while the active step finishes and the terminal frame arrives.const canceling = active && latest?.type === 'cancel:acknowledged';+ const pausing = active && latest?.type === 'pause:acknowledged';const runLabel = ap?.status === 'paused' ? 'Resume autopilot': ap?.status === 'done' ? 'Run autopilot again': 'Run autopilot';@@ -885,14 +892,26 @@ export default function AutopilotPanel({ series, onSeriesUpdate, onIssuesUpdate</button></>) : (- <button- type="button"- onClick={cancel}- disabled={canceling}- 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 disabled:opacity-50 disabled:hover:text-port-warning disabled:cursor-default"- >- {canceling ? <Loader2 size={12} className="animate-spin" /> : <X size={12} />} {canceling ? 'Cancelling…' : 'Stop'}- </button>+ <>+ <button+ type="button"+ onClick={pause}+ disabled={pausing || canceling}+ className="inline-flex items-center gap-1 px-3 py-1.5 rounded text-xs text-port-accent hover:text-white border border-port-accent/40 bg-port-bg hover:bg-port-accent/10 disabled:opacity-50 disabled:cursor-default"+ title="Finish the active step, then pause without stopping its AI run"+ >+ {pausing ? <Loader2 size={12} className="animate-spin" /> : <PauseCircle size={12} />} {pausing ? 'Pausing…' : 'Pause safely'}+ </button>+ <button+ type="button"+ onClick={cancel}+ disabled={canceling}+ 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 disabled:opacity-50 disabled:hover:text-port-warning disabled:cursor-default"+ title="Stop the active AI run immediately"+ >+ {canceling ? <Loader2 size={12} className="animate-spin" /> : <X size={12} />} {canceling ? 'Cancelling…' : 'Stop now'}+ </button>+ </>)}</div></div>diff --git a/client/src/components/pipeline/AutopilotPanel.test.jsx b/client/src/components/pipeline/AutopilotPanel.test.jsxindex cf5536412d..a9600cbb2f 100644--- a/client/src/components/pipeline/AutopilotPanel.test.jsx+++ b/client/src/components/pipeline/AutopilotPanel.test.jsx@@ -5,6 +5,7 @@ import { MemoryRouter } from 'react-router';vi.mock('../../services/api', () => ({startPipelineAutopilot: vi.fn(),cancelPipelineAutopilot: vi.fn(),+ pausePipelineAutopilot: vi.fn(),getPipelineAutopilotStatus: vi.fn(),getPipelineAutopilotModelMetrics: vi.fn(),pipelineAutopilotSseUrl: (id) => `/api/pipeline/series/${id}/autopilot/progress`,@@ -732,6 +733,16 @@ describe('AutopilotPanel', () => {expect(screen.getByText(/finishing the active step/i)).toBeInTheDocument();});+ it('shows a non-destructive Pausing… state for a graceful pause request', async () => {+ getPipelineAutopilotStatus.mockResolvedValue({ autopilot: { status: 'running', runId: 'r1' }, active: true });+ sseLatest = { type: 'pause:acknowledged', runId: 'r1' };+ renderPanel({ id: 's1', targetFormat: 'comic' });+ await waitFor(() => expect(getPipelineAutopilotStatus).toHaveBeenCalled());+ expect(await screen.findByRole('button', { name: /pausing/i })).toBeDisabled();+ expect(screen.getByRole('button', { name: /stop now/i })).toBeEnabled();+ expect(screen.getByText(/pausing safely.*finishing the active step/i)).toBeInTheDocument();+ });+// Pipeline self-improvement — the opt-in that lets a run diagnose PortOS's own// automation and file a fix task against it.describe('pipeline self-improvement', () => {diff --git a/client/src/services/apiPipeline.js b/client/src/services/apiPipeline.jsindex 37e5b1c112..3f05400467 100644--- a/client/src/services/apiPipeline.js+++ b/client/src/services/apiPipeline.js@@ -985,6 +985,11 @@ export const cancelPipelineAutopilot = (seriesId) =>method: 'POST',});+export const pausePipelineAutopilot = (seriesId) =>+ request(`/pipeline/series/${encodeURIComponent(seriesId)}/autopilot/pause`, {+ method: 'POST',+ });+// { autopilot: { status, runId, currentStep, residualFindings, ... } | null, active }export const getPipelineAutopilotStatus = (seriesId, options = {}) =>request(`/pipeline/series/${encodeURIComponent(seriesId)}/autopilot/status`, options);diff --git a/server/routes/pipeline/autopilot.js b/server/routes/pipeline/autopilot.jsindex cdc41d540c..88baac7b0b 100644--- a/server/routes/pipeline/autopilot.js+++ b/server/routes/pipeline/autopilot.js@@ -12,6 +12,9 @@* immediately; the active step/LLM call* finishes before the terminal `canceled`* frame (cooperative, between-step cancel).+ * POST /series/:id/autopilot/pause → { pauseRequested }+ * Finishes the active step/transaction+ * without stopping its provider run.* GET /series/:id/autopilot/status → { autopilot, active, start }* (resume / paused UI; `start` is the* in-flight run's start frame, which@@ -235,6 +238,11 @@ router.post('/series/:id/autopilot/cancel', asyncHandler(async (req, res) => {res.json({ canceled });}));+router.post('/series/:id/autopilot/pause', asyncHandler(async (req, res) => {+ const pauseRequested = autopilot.pauseSeriesAutopilot(req.params.id);+ res.json({ pauseRequested });+}));+router.get('/series/:id/autopilot/status', asyncHandler(async (req, res) => {const series = await seriesSvc.getSeries(req.params.id).catch((err) => { throw mapServiceError(err); });res.json({diff --git a/server/routes/pipeline/index.js b/server/routes/pipeline/index.jsindex 0f35be23e8..2f75b720c1 100644--- a/server/routes/pipeline/index.js+++ b/server/routes/pipeline/index.js@@ -24,6 +24,7 @@* POST /series/:id/autopilot/start → { runId, alreadyRunning, mode, sseUrl }* GET /series/:id/autopilot/progress → SSE (text/event-stream)* POST /series/:id/autopilot/cancel → { canceled }+ * POST /series/:id/autopilot/pause → { pauseRequested }* GET /series/:id/autopilot/status → { autopilot, active }* GET /issues/:id/canon-readiness → { referenced, none, thin, ready }* GET /series/:id/canon-readiness → { ready, issues, blockingIssues, undescribed }diff --git a/server/services/pipeline/series.js b/server/services/pipeline/series.jsindex ccfb6ab43e..2a2348a51e 100644--- a/server/services/pipeline/series.js+++ b/server/services/pipeline/series.js@@ -216,12 +216,13 @@ const sanitizeAutopilotResumeOptions = (raw) => {// to each other without settling), `budget` (the daily spend cap was reached// mid-run), `providerFailed` (an LLM repair call failed outright — a provider// timeout, a dead CLI, a rate limit — after the prompt runner's own fallback-// cascade was exhausted). This list must carry EVERY kind the autopilot emits:+// cascade was exhausted), `manual` (the user asked for a graceful pause after+// the active step/transaction). This list must carry EVERY kind the autopilot emits:// sanitizeAutopilot drops an unlisted one to null, which silently strips the// badge the UI would otherwise show.export const AUTOPILOT_PAUSE_KINDS = Object.freeze(['maxRounds', 'divergence', 'regression', 'childFailed', 'checkFindings',- 'inapplicable', 'planningOscillation', 'budget', 'providerFailed',+ 'inapplicable', 'planningOscillation', 'budget', 'providerFailed', 'manual',]);// Bound a marker-borne finding list to the wire shape the UI renders.diff --git a/server/services/pipeline/seriesAutopilot.test.js b/server/services/pipeline/seriesAutopilot.test.jsindex 1ceecf8b2e..aff2ef8220 100644--- a/server/services/pipeline/seriesAutopilot.test.js+++ b/server/services/pipeline/seriesAutopilot.test.js@@ -3152,6 +3152,23 @@ describe('autopilot conductor', () => {expect(writes.some((w) => w.includes('"type":"cancel:acknowledged"'))).toBe(true);});+ it('gracefully pauses without stopping the active provider run', async () => {+ const { seriesId } = await seedComplete();+ const { runId } = await autopilot.startSeriesAutopilot(seriesId, { includeVisual: false });+ const requested = autopilot.pauseSeriesAutopilot(seriesId);+ expect(requested).toBe(true);+ expect(autopilot.__testing.runs.get(seriesId)?.lastPayload).toMatchObject({+ type: 'pause:acknowledged',+ runId,+ });+ await waitFor(runFinished(seriesId));+ const last = autopilot.__testing.runs.get(seriesId)?.lastPayload;+ expect(last).toMatchObject({ type: 'paused', pauseKind: 'manual' });+ expect(last?.reason).toMatch(/paused by user after the active step completed/i);+ const series = await seriesSvc.getSeries(seriesId);+ expect(series.autopilot).toMatchObject({ status: 'paused', pauseKind: 'manual' });+ });+it('drafts cover + interior pages when includeVisual is set', async () => {const { seriesId, issueId } = await seedComplete();await autopilot.startSeriesAutopilot(seriesId, { includeVisual: true });diff --git a/server/services/pipeline/seriesAutopilot/childRuns.js b/server/services/pipeline/seriesAutopilot/childRuns.jsindex c184838f6c..2785608a4f 100644--- a/server/services/pipeline/seriesAutopilot/childRuns.js+++ b/server/services/pipeline/seriesAutopilot/childRuns.js@@ -716,6 +716,17 @@ export async function runFoundationGate(seriesId, record) {}return {};}+ // A graceful pause requested while the judge was working lands only after+ // any pending repair has been accepted or rolled back above. That preserves+ // the foundation transaction boundary while preventing another repair call.+ if (record.pauseRequested) {+ return {+ pause: true,+ pauseKind: 'manual',+ reason: 'paused by user after the active foundation judgment completed',+ residual: residualFindings(snap.dimensions),+ };+ }if (round === maxRounds || !weak) {const floorReason = gate.failingDimensions.length > 0? `Foundation quality left ${gate.failingDimensions.join(', ')} below the ${gate.dimensionFloor} dimension floor after ${maxRounds} round(s). Strengthen those foundations and resume.`diff --git a/server/services/pipeline/seriesAutopilot/orchestrator.js b/server/services/pipeline/seriesAutopilot/orchestrator.jsindex 8cc80f4b28..48a74ba9db 100644--- a/server/services/pipeline/seriesAutopilot/orchestrator.js+++ b/server/services/pipeline/seriesAutopilot/orchestrator.js@@ -134,6 +134,7 @@ export async function startSeriesAutopilot(sId, options = {}) {clients: [],lastPayload: null,cancelRequested: false,+ pauseRequested: false,finished: false,cleanupTimer: null,startedAt: new Date().toISOString(),@@ -322,7 +323,7 @@ export async function startSeriesAutopilot(sId, options = {}) {broadcast(sId, { type: 'note', message: 'Draft visual rendering is not enabled in this build — running to text-ready + editorial review.' });}- while (!record.cancelRequested) {+ while (!record.cancelRequested && !record.pauseRequested) {const series = await getSeries(sId);const issues = await listIssues({ seriesId: sId });const step = resolveNextStep(series, issues, record.runState, runOptions);@@ -448,6 +449,20 @@ export async function startSeriesAutopilot(sId, options = {}) {observeStep(step);}+ if (record.pauseRequested && !record.cancelRequested) {+ const reason = 'paused by user after the active step completed';+ await observerIdle();+ await persistMarker(sId, {+ status: 'paused', runId, currentStep: null, lastError: reason, pauseKind: 'manual',+ });+ broadcast(sId, {+ type: 'paused', runId, reason, pauseKind: 'manual',+ completedAt: new Date().toISOString(),+ });+ console.log(`⏸️ autopilot paused (manual) — series=${sId.slice(0, 12)} after ${ordinal} steps`);+ return;+ }+// Cancelled. No post-mortem (nothing to explain), but an in-flight// observer pass must still land before the terminal frame.await observerIdle();diff --git a/server/services/pipeline/seriesAutopilot/session.js b/server/services/pipeline/seriesAutopilot/session.jsindex c079591d9c..98e8650bb7 100644--- a/server/services/pipeline/seriesAutopilot/session.js+++ b/server/services/pipeline/seriesAutopilot/session.js@@ -65,6 +65,22 @@ export function cancelSeriesAutopilot(seriesId) {return true;}+// Graceful control for quality-first runs: finish the current top-level step+// (and any provisional repair + independent verification transaction inside+// it), then persist a resumable pause. Unlike Cancel this deliberately does not+// stop the active provider run or delegated child.+export function pauseSeriesAutopilot(seriesId) {+ const run = runs.get(seriesId);+ if (!run || run.finished) return false;+ run.pauseRequested = true;+ broadcastSse(run, {+ type: 'pause:acknowledged',+ runId: run.runId,+ requestedAt: new Date().toISOString(),+ });+ return true;+}+export function broadcast(seriesId, payload) {const run = runs.get(seriesId);if (!run) return;diff --git a/server/services/pipeline/seriesAutopilot/state.js b/server/services/pipeline/seriesAutopilot/state.jsindex 677d229c4c..7ca93a1768 100644--- a/server/services/pipeline/seriesAutopilot/state.js+++ b/server/services/pipeline/seriesAutopilot/state.js@@ -10,7 +10,7 @@ import { EventEmitter } from 'events';// warns about.import { diagnosisOptedIn } from './diagnosisCore.js';-// runs: Map<seriesId, { runId, clients[], lastPayload, startPayload, cancelRequested,+// runs: Map<seriesId, { runId, clients[], lastPayload, startPayload, cancelRequested, pauseRequested,// finished, cleanupTimer, startedAt, mode, options, runState, activeChild,// activeLlmRunId }>// `startPayload` is the run's `start` frame, retained so a client attaching