Skip to content

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

feat: optional autopilot pause when editorial checks surface many high findings (#1613)

[._.]/ Adam Eivy2b5c8808ebac
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index db559767e1..21f220c21c 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -25,6 +25,7 @@
- **[issue-1697] Health-panel deep-links now honor the triage's session-local check mute.** Muting a check from the Editorial Findings triage (#1602) hid its findings group but the health panel kept advertising that check/category row as clickable — clicking it scrolled to an empty filtered view. The session mute state (`hiddenCheckIds`) was lifted from `EditorialFindingsTriage` up to `PipelineEditorialChecks`, which now subtracts muted checks from the filterable sets the health panel receives; a category stays clickable only while a non-muted check still contributes an open finding to it. (`client/src/pages/PipelineEditorialChecks.jsx`, `client/src/components/pipeline/editorial/EditorialFindingsTriage.jsx`)
- **[issue-1667] Final-part editorial verdicts no longer lose their carried setup context on a packed last chunk.** The cross-chunk "setup so far" digest normally yields to manuscript coverage — but two whole-story checks (`arc.climax-agency`, `emotion.reaction-proportionality`) gate their verdict to the final part and anchor it on a snippet carried in that digest (the climax candidate / the unprocessed event). When the final chunk packed to within a few hundred chars of the provider window, the digest was silently dropped and the final-only finding was missed. These checks now opt into a `reserveSetupDigest` guarantee that trims the final chunk's manuscript tail to make room for the digest (the inverse of the usual yield), scoped to the final chunk and opt-in checks only — every other chunk and every non-reserving check keeps full manuscript coverage. (`server/lib/editorial/checkRegistry.js`)
+- **[issue-1613] Series Autopilot can now pause when an editorial-checks pass surfaces too many High findings.** Previously the registry-driven editorial-checks step always reported "complete" regardless of finding count — a pass that surfaced 50 High findings looked clean and only the downstream health gate caught it, making the per-step signal misleading. A new, off-by-default **pause threshold** (`pipelineEditorialChecks.checkFindingsPauseThreshold`, also a per-run override and an Options field) makes the run pause for human review when the checks pass finds at least N High findings — gating like the verify/editorial loops, with the High findings carried as residual and a "high findings" badge in the panel. The step's progress frame now also reports the real High count instead of a hardcoded `0`. 0 = off, so existing runs are unchanged. (`server/services/pipeline/seriesAutopilot.js`, `server/services/pipeline/series.js`, `server/lib/validation.js`, `server/routes/pipeline/autopilot.js`, `client/src/components/pipeline/AutopilotPanel.jsx`)
## Internal
diff --git a/client/src/components/pipeline/AutopilotPanel.jsx b/client/src/components/pipeline/AutopilotPanel.jsx
index 1954770d0e..fc436a8c5b 100644
--- a/client/src/components/pipeline/AutopilotPanel.jsx
+++ b/client/src/components/pipeline/AutopilotPanel.jsx
@@ -25,6 +25,17 @@ const ROUND_MAX = 20;
const DEFAULT_ARC_ROUNDS = 3;
const DEFAULT_EDITORIAL_ROUNDS = 2;
const DEFAULT_BEAT_CONTINUITY_ROUNDS = 2;
+// Editorial-checks pause threshold (#1613) — mirror the server default (0 = off).
+// Unlike the round bounds it has no upper cap; a large N is effectively off.
+const DEFAULT_CHECK_PAUSE_THRESHOLD = 0;
+// Clamp the threshold to a non-negative integer. Blank/invalid → 0 (off) — a
+// cleared field disables the gate rather than falling back to a non-zero default.
+const clampThreshold = (n) => {
+ if (n === '' || n === null || n === undefined) return 0;
+ const v = Number(n);
+ if (!Number.isFinite(v)) return 0;
+ return Math.max(0, Math.round(v));
+};
// Editorial-health readiness gate (#1316/#1580) — the "manuscript clean" bar the
// autopilot must clear before visuals. Mirrors READINESS_GATES on the server. The
@@ -93,6 +104,8 @@ const STEP_LABELS = {
scriptVerify: 'Verifying scripts',
editorialReview: 'Editorial review',
reverseOutline: 'Refreshing scene segmentation',
+ editorialChecks: 'Editorial checks',
+ editorialHealthGate: 'Editorial health gate',
canonVerify: 'Checking canon descriptions',
visualDraft: 'Drafting comic art',
};
@@ -179,6 +192,11 @@ export default function AutopilotPanel({ series, onSeriesUpdate, onIssuesUpdate
// option label so the user knows what the fallback is.
const [readinessGate, setReadinessGate] = useState('');
const [savedGate, setSavedGate] = useState('');
+ // Editorial-checks pause threshold (#1613). 0 = off (default): pause the run
+ // when the editorial-checks pass surfaces ≥ N high findings. Persisted like the
+ // round inputs (saved default + per-run override), so a raised value is reused
+ // on Resume.
+ const [checkPauseThreshold, setCheckPauseThreshold] = useState(DEFAULT_CHECK_PAUSE_THRESHOLD);
// Per-field dirty flags. Until a field is edited its input shows a display
// default we must NOT persist (that would clobber a higher saved setting on
// the untouched gate). Tracked per-field so editing one gate never discards
@@ -187,6 +205,7 @@ export default function AutopilotPanel({ series, onSeriesUpdate, onIssuesUpdate
const arcEditedRef = useRef(false);
const editorialEditedRef = useRef(false);
const beatContinuityEditedRef = useRef(false);
+ const checkPauseEditedRef = useRef(false);
const [canon, setCanon] = useState(null);
const [canonLoading, setCanonLoading] = useState(false);
@@ -204,6 +223,7 @@ export default function AutopilotPanel({ series, onSeriesUpdate, onIssuesUpdate
if (!arcEditedRef.current) setArcRounds(Number.isInteger(pec.maxArcVerifyRounds) ? pec.maxArcVerifyRounds : DEFAULT_ARC_ROUNDS);
if (!editorialEditedRef.current) setEditorialRounds(Number.isInteger(pec.maxEditorialRounds) ? pec.maxEditorialRounds : DEFAULT_EDITORIAL_ROUNDS);
if (!beatContinuityEditedRef.current) setBeatContinuityRounds(Number.isInteger(pec.maxBeatContinuityRounds) ? pec.maxBeatContinuityRounds : DEFAULT_BEAT_CONTINUITY_ROUNDS);
+ if (!checkPauseEditedRef.current) setCheckPauseThreshold(Number.isInteger(pec.checkFindingsPauseThreshold) ? pec.checkFindingsPauseThreshold : DEFAULT_CHECK_PAUSE_THRESHOLD);
// Persisted readiness gate — display-only, drives the "saved default" label.
setSavedGate(READINESS_GATE_LABELS[pec.readinessGate] ? pec.readinessGate : '');
})
@@ -231,6 +251,7 @@ export default function AutopilotPanel({ series, onSeriesUpdate, onIssuesUpdate
const editArcRounds = useCallback((v) => { arcEditedRef.current = true; setArcRounds(v); }, []);
const editEditorialRounds = useCallback((v) => { editorialEditedRef.current = true; setEditorialRounds(v); }, []);
const editBeatContinuityRounds = useCallback((v) => { beatContinuityEditedRef.current = true; setBeatContinuityRounds(v); }, []);
+ const editCheckPauseThreshold = useCallback((v) => { checkPauseEditedRef.current = true; setCheckPauseThreshold(v); }, []);
const { latest, frames } = usePipelineProgress(pipelineAutopilotSseUrl, [seriesId], { enabled: active });
@@ -306,6 +327,9 @@ export default function AutopilotPanel({ series, onSeriesUpdate, onIssuesUpdate
if (arcEditedRef.current) roundOverrides.maxArcVerifyRounds = clampRound(arcRounds, DEFAULT_ARC_ROUNDS);
if (editorialEditedRef.current) roundOverrides.maxEditorialRounds = clampRound(editorialRounds, DEFAULT_EDITORIAL_ROUNDS);
if (beatContinuityEditedRef.current) roundOverrides.maxBeatContinuityRounds = clampRound(beatContinuityRounds, DEFAULT_BEAT_CONTINUITY_ROUNDS);
+ // #1613 — the editorial-checks pause threshold persists + overrides like the
+ // round inputs (clamps to a non-negative integer; 0 = off).
+ if (checkPauseEditedRef.current) roundOverrides.checkFindingsPauseThreshold = clampThreshold(checkPauseThreshold);
if (Object.keys(roundOverrides).length) await persistRounds(roundOverrides);
// Per-run readiness-gate override (#1580): send it ONLY when the user picked a
// specific gate. Unlike the round inputs we never persist it — '' leaves the
@@ -321,7 +345,7 @@ export default function AutopilotPanel({ series, onSeriesUpdate, onIssuesUpdate
// effect can reject a stale terminal frame from the previous run.
activeRunIdRef.current = res.runId || null;
setActive(true);
- }, [seriesId, includeVisual, fileGaps, arcRounds, editorialRounds, beatContinuityRounds, readinessGate, persistRounds]);
+ }, [seriesId, includeVisual, fileGaps, arcRounds, editorialRounds, beatContinuityRounds, checkPauseThreshold, readinessGate, persistRounds]);
const cancel = useCallback(async () => {
await cancelPipelineAutopilot(seriesId).catch(() => null);
@@ -445,6 +469,26 @@ export default function AutopilotPanel({ series, onSeriesUpdate, onIssuesUpdate
<p className="text-[11px] text-gray-500">
The editorial-health bar this run must clear before drafting visuals. A per-run choice applies to this run only — it does not change the saved default.
</p>
+ <div className="flex items-center gap-2 pt-1">
+ <label htmlFor="autopilot-check-pause-threshold" className="text-xs text-gray-300">Pause at high findings</label>
+ <input
+ id="autopilot-check-pause-threshold"
+ type="number"
+ min={0}
+ value={checkPauseThreshold}
+ onChange={(e) => editCheckPauseThreshold(e.target.value === '' ? '' : Number(e.target.value))}
+ onBlur={() => {
+ if (!checkPauseEditedRef.current) return;
+ const v = clampThreshold(checkPauseThreshold);
+ setCheckPauseThreshold(v);
+ persistRounds({ checkFindingsPauseThreshold: v });
+ }}
+ className="w-16 px-2 py-1 rounded text-xs bg-port-bg border border-port-border text-gray-200"
+ />
+ </div>
+ <p className="text-[11px] text-gray-500">
+ When the editorial-checks pass surfaces this many High findings (or more), the run pauses for review instead of proceeding. 0 = off. Saved as the default and reused on Resume.
+ </p>
<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>
@@ -528,6 +572,14 @@ export default function AutopilotPanel({ series, onSeriesUpdate, onIssuesUpdate
not converging
</span>
) : null}
+ {ap.status === 'paused' && ap.pauseKind === 'checkFindings' ? (
+ <span
+ className="px-1.5 py-0.5 rounded text-[10px] bg-port-warning/15 text-port-warning border border-port-warning/30"
+ title="Editorial checks surfaced too many High findings — address them (or lower the threshold) and resume"
+ >
+ high findings
+ </span>
+ ) : null}
</div>
{ap.lastError && ap.status !== 'done' ? <p className="text-[11px] text-gray-400 mt-1">{ap.lastError}</p> : null}
<Findings items={ap.residualFindings} />
diff --git a/client/src/components/pipeline/AutopilotPanel.test.jsx b/client/src/components/pipeline/AutopilotPanel.test.jsx
index ef3baf0ed5..c7d7c0cb72 100644
--- a/client/src/components/pipeline/AutopilotPanel.test.jsx
+++ b/client/src/components/pipeline/AutopilotPanel.test.jsx
@@ -182,6 +182,23 @@ describe('AutopilotPanel', () => {
expect(screen.queryByText(/not converging/i)).not.toBeInTheDocument();
});
+ it('flags an editorial-checks pause with a "high findings" badge (#1613)', async () => {
+ renderPanel({
+ id: 's1',
+ targetFormat: 'comic',
+ autopilot: {
+ status: 'paused',
+ currentStep: 'editorialChecks',
+ pauseKind: 'checkFindings',
+ residualFindings: [{ severity: 'high', location: 'ch 1', problem: 'pacing stalls' }],
+ },
+ });
+ await waitFor(() => expect(getPipelineAutopilotStatus).toHaveBeenCalled());
+ expect(screen.getByText(/Paused at Editorial checks/i)).toBeInTheDocument();
+ expect(screen.getByText(/high findings/i)).toBeInTheDocument();
+ expect(screen.getByText(/pacing stalls/i)).toBeInTheDocument();
+ });
+
it('shows the production-ready banner for a clean done marker', async () => {
renderPanel({ id: 's1', targetFormat: 'comic', autopilot: { status: 'done', craftGapIssues: 0 } });
await waitFor(() => expect(getPipelineAutopilotStatus).toHaveBeenCalled());
diff --git a/server/lib/validation.js b/server/lib/validation.js
index 931c5b2f35..b3338f43fc 100644
--- a/server/lib/validation.js
+++ b/server/lib/validation.js
@@ -1117,6 +1117,14 @@ export const pipelineEditorialChecksSettingsSchema = z.object({
// Whole-manuscript beat-continuity convergence (#1510) — same bound + 0-skip
// semantics. Optional + additive so older peers fall through to the default.
maxBeatContinuityRounds: z.number().int().min(0).max(MAX_CONVERGENCE_ROUNDS).optional(),
+ // Editorial-checks pause threshold (#1613). When the registry-driven editorial
+ // checks pass surfaces ≥ N high-severity findings, the autopilot pauses the run
+ // for human review instead of silently proceeding (the downstream health gate is
+ // a backstop, but the per-step signal was misleading — a 50-high-finding pass
+ // looked "complete"). 0 = off (default), so the behavior is opt-in and existing
+ // installs are unchanged. Optional + additive so older peers fall through to off.
+ // No upper bound mirrors the round caps — a large N just means "effectively off".
+ checkFindingsPauseThreshold: z.number().int().min(0).optional(),
}).strict();
// Cursor-context payload for the CD-bridge suggest route — identical shape to
diff --git a/server/lib/validation.test.js b/server/lib/validation.test.js
index 0956d2c890..1cefc3ab81 100644
--- a/server/lib/validation.test.js
+++ b/server/lib/validation.test.js
@@ -882,6 +882,16 @@ describe('validation.js', () => {
expect(editorialCustomCheckUpdateSchema.safeParse({ nope: 1 }).success).toBe(false);
});
+ it('accepts a non-negative integer checkFindingsPauseThreshold and rejects bad shapes (#1613)', () => {
+ expect(pipelineEditorialChecksSettingsSchema.safeParse({ checkFindingsPauseThreshold: 0 }).success).toBe(true);
+ expect(pipelineEditorialChecksSettingsSchema.safeParse({ checkFindingsPauseThreshold: 25 }).success).toBe(true);
+ // additive + optional: omitting it is fine
+ expect(pipelineEditorialChecksSettingsSchema.safeParse({}).success).toBe(true);
+ // negative / non-integer are rejected
+ expect(pipelineEditorialChecksSettingsSchema.safeParse({ checkFindingsPauseThreshold: -1 }).success).toBe(false);
+ expect(pipelineEditorialChecksSettingsSchema.safeParse({ checkFindingsPauseThreshold: 2.5 }).success).toBe(false);
+ });
+
it('the settings slice accepts forward/older-peer custom-check shapes (lenient)', () => {
// A def carrying a future field (or a not-yet-known scope) must not 400 an
// unrelated settings save — runtime buildCustomCheck decides runnability.
diff --git a/server/routes/pipeline/autopilot.js b/server/routes/pipeline/autopilot.js
index cbec2f097a..4e955745c0 100644
--- a/server/routes/pipeline/autopilot.js
+++ b/server/routes/pipeline/autopilot.js
@@ -61,6 +61,12 @@ const autopilotStartSchema = z.object({
// for one run no longer requires editing global settings. Enum shares the
// canonical READINESS_GATES set so the API and the scorer can't drift.
readinessGate: z.enum(READINESS_GATES).optional(),
+ // Per-run editorial-checks pause threshold override (#1613). When the checks
+ // pass surfaces ≥ N high-severity findings, the run pauses for human review
+ // instead of proceeding. When omitted, falls back to the persisted
+ // pipelineEditorialChecks.checkFindingsPauseThreshold, then 0 (off). 0 disables
+ // the gate for this run. No upper bound — a large N is effectively off.
+ checkFindingsPauseThreshold: z.number().int().min(0).optional(),
});
router.post('/series/:id/autopilot/start', asyncHandler(async (req, res) => {
diff --git a/server/services/pipeline/series.js b/server/services/pipeline/series.js
index 61bab19274..3cc9e42e7a 100644
--- a/server/services/pipeline/series.js
+++ b/server/services/pipeline/series.js
@@ -121,7 +121,9 @@ const AUTOPILOT_FINDING_SEVERITIES = ['high', 'medium', 'low'];
// (#1574): `childFailed` (a delegated beats/text run produced no output after
// its retry budget). Lets the UI classify the pause without string-matching the
// reason text. Any other pause (budget, error, a capability gap) leaves this null.
-export const AUTOPILOT_PAUSE_KINDS = Object.freeze(['maxRounds', 'divergence', 'childFailed']);
+// Editorial checks (#1613): `checkFindings` (the editorial-checks pass surfaced ≥
+// the armed high-finding threshold, so the run paused for human review).
+export const AUTOPILOT_PAUSE_KINDS = Object.freeze(['maxRounds', 'divergence', 'childFailed', 'checkFindings']);
export const sanitizeAutopilot = (raw) => {
if (!raw || typeof raw !== 'object') return null;
diff --git a/server/services/pipeline/seriesAutopilot.js b/server/services/pipeline/seriesAutopilot.js
index 3c09c4ed71..3658e510d9 100644
--- a/server/services/pipeline/seriesAutopilot.js
+++ b/server/services/pipeline/seriesAutopilot.js
@@ -160,6 +160,20 @@ export function resolveAutopilotReadinessGate(options = {}, settings = null) {
return readReadinessGate(settings);
}
+// Editorial-checks pause threshold (#1613): pause the run when the checks pass
+// surfaces ≥ N high-severity findings. 0 = off (the default), so the gate is
+// opt-in and existing installs are unchanged. Mirrors resolveAutopilotRounds —
+// per-run option wins, then the persisted setting, then 0. A non-integer at any
+// layer falls through to the next. Stamped onto run options once at start so the
+// loop and a later resume read the same effective threshold.
+export const DEFAULT_CHECK_FINDINGS_PAUSE_THRESHOLD = 0;
+export function resolveAutopilotCheckPauseThreshold(options = {}, settings = null) {
+ if (Number.isInteger(options?.checkFindingsPauseThreshold)) return options.checkFindingsPauseThreshold;
+ const pec = settings?.pipelineEditorialChecks || {};
+ if (Number.isInteger(pec?.checkFindingsPauseThreshold)) return pec.checkFindingsPauseThreshold;
+ return DEFAULT_CHECK_FINDINGS_PAUSE_THRESHOLD;
+}
+
// Per-gate copy for the non-convergence pause — shared by the arc-verify and
// editorial loops so the two messages can't drift.
const PAUSE_GATES = {
@@ -1118,10 +1132,41 @@ async function runEditorialChecksPass(sId, record) {
// can flag a partial failure (no silent "complete").
const { errored, erroredCheckIds } = summarizeCheckErrors(result.perCheck);
erroredCheckIds.forEach((id) => record.runState.editorialCheckErroredIds.add(id));
- broadcast(sId, { type: 'verify:round', scope: 'editorialChecks', round: 1, findings: result.findings.length, blocking: 0, errored, erroredCheckIds });
+ // #1613 — count the high-severity findings this pass surfaced. The round frame
+ // previously hardcoded `blocking: 0`, which made a 50-high-finding pass look
+ // "complete" — the misleading per-step signal the issue calls out. Report the
+ // real high count so the step's `blocking` matches what it found, whether or
+ // not the optional pause gate is armed.
+ const highFindings = result.findings.filter((f) => f.severity === 'high');
+ broadcast(sId, { type: 'verify:round', scope: 'editorialChecks', round: 1, findings: result.findings.length, blocking: highFindings.length, errored, erroredCheckIds });
if (errored) {
console.error(`❌ autopilot: ${errored} editorial check(s) errored — series=${sId.slice(0, 12)} ${erroredCheckIds.join(', ')}`);
}
+ // #1613 — optional gate: when armed (threshold > 0) and the pass surfaced at
+ // least that many high findings, PAUSE for human review instead of silently
+ // proceeding to the health gate. Off by default (threshold 0), so existing
+ // runs are unchanged. Do NOT mark the step reviewed — a resume re-runs the
+ // checks and reconciles (like the health gate), so once the human reduces the
+ // high findings below the threshold (or lowers it) the run continues.
+ const threshold = record.options.checkFindingsPauseThreshold || 0;
+ if (threshold > 0 && highFindings.length >= threshold) {
+ // Editorial findings already carry severity/location/problem (manuscriptReview
+ // sanitizes them), so the residual uses the same shape as the other pauses;
+ // keep checkId so the UI can link a residual back to the check that raised it.
+ const residual = highFindings.map((f) => ({
+ severity: 'high',
+ location: f.location || (f.checkId ? `check ${f.checkId}` : 'manuscript'),
+ problem: f.problem || 'high-severity editorial finding',
+ checkId: f.checkId,
+ }));
+ console.log(`🚦 editorial checks gate — series=${sId.slice(0, 12)} ${highFindings.length} high finding(s) ≥ threshold ${threshold}, pausing for review`);
+ return {
+ pause: true,
+ pauseKind: 'checkFindings',
+ reason: `Editorial checks surfaced ${highFindings.length} high-severity finding(s) (≥ threshold ${threshold}) — paused for review. Address them in the manuscript editor, or lower/disable the editorial-check pause threshold in Options and resume.`,
+ residual,
+ };
+ }
}
record.runState.editorialChecksReviewed = true;
return {};
@@ -1487,10 +1532,14 @@ function buildDryRunPlan(series, issues, options, costContext = {}) {
const checksNote = editorialSubset
? `per-run subset of ${editorialSubset.length} editorial check(s) (#1575)`
: 'enabled editorial checks (#1284)';
+ // Surface the optional pause threshold (#1613) when armed, mirroring how the
+ // readiness gate is exposed below — so a per-run override is visible in the plan.
+ const pauseThreshold = resolveAutopilotCheckPauseThreshold(options);
+ const pauseNote = pauseThreshold > 0 ? ` — pauses at ≥ ${pauseThreshold} high finding(s) (#1613)` : '';
plan.push({
kind: 'editorialChecks',
count: 1,
- note: llmCheckCount > 0 ? `${checksNote} — ~${estLlmCalls} LLM call(s)` : checksNote,
+ note: (llmCheckCount > 0 ? `${checksNote} — ~${estLlmCalls} LLM call(s)` : checksNote) + pauseNote,
estActions: llmCheckCount > 0 ? 1 : 0,
estLlmCalls,
});
@@ -1542,6 +1591,7 @@ export async function startSeriesAutopilot(sId, options = {}) {
...options,
...resolveAutopilotRounds(options, settings),
readinessGate: resolveAutopilotReadinessGate(options, settings),
+ checkFindingsPauseThreshold: resolveAutopilotCheckPauseThreshold(options, settings),
};
if (existing) {
diff --git a/server/services/pipeline/seriesAutopilot.test.js b/server/services/pipeline/seriesAutopilot.test.js
index 1bdedb17fa..9182102071 100644
--- a/server/services/pipeline/seriesAutopilot.test.js
+++ b/server/services/pipeline/seriesAutopilot.test.js
@@ -79,8 +79,11 @@ let reverseOutlineConsumed = false;
// Drives the perCheck array the editorial-checks pass sees, so a test can inject
// an errored check and assert it surfaces in the run summary (#1573).
let editorialChecksPerCheck = [];
+// Drives the findings the editorial-checks pass returns, so a test can inject
+// high-severity findings and assert the optional pause gate fires (#1613).
+let editorialChecksFindings = [];
const checkRunnerSpies = {
- runEditorialChecks: vi.fn(async () => ({ runId: 'ec', findings: [], perCheck: editorialChecksPerCheck, canceled: false })),
+ runEditorialChecks: vi.fn(async () => ({ runId: 'ec', findings: editorialChecksFindings, perCheck: editorialChecksPerCheck, canceled: false })),
buildEditorialCheckPlan: vi.fn(async () => ({ seriesId: 's', checks: [], enabledCount: 0, consumesReverseOutline: reverseOutlineConsumed })),
enabledChecksConsumeReverseOutline: vi.fn(() => reverseOutlineConsumed),
// Real pure impl (the module is fully mocked) so the SUT's error-summarizing
@@ -176,6 +179,7 @@ beforeEach(() => {
reverseOutlineConsumed = false;
reverseOutlineState = { status: 'complete', stale: false };
editorialChecksPerCheck = [];
+ editorialChecksFindings = [];
nextTaskId = 0;
autopilot.__testing.runs.clear();
vi.clearAllMocks();
@@ -281,6 +285,29 @@ describe('resolveNextStep (pure)', () => {
)).toBe('none');
});
+ it('resolveAutopilotCheckPauseThreshold: per-run option wins, else setting, else 0/off (#1613)', () => {
+ const { resolveAutopilotCheckPauseThreshold, DEFAULT_CHECK_FINDINGS_PAUSE_THRESHOLD } = autopilot;
+ expect(DEFAULT_CHECK_FINDINGS_PAUSE_THRESHOLD).toBe(0);
+ // per-run override wins (including an explicit 0 = off)
+ expect(resolveAutopilotCheckPauseThreshold(
+ { checkFindingsPauseThreshold: 0 },
+ { pipelineEditorialChecks: { checkFindingsPauseThreshold: 5 } },
+ )).toBe(0);
+ expect(resolveAutopilotCheckPauseThreshold(
+ { checkFindingsPauseThreshold: 8 },
+ { pipelineEditorialChecks: { checkFindingsPauseThreshold: 5 } },
+ )).toBe(8);
+ // persisted setting fills in when no per-run override
+ expect(resolveAutopilotCheckPauseThreshold({}, { pipelineEditorialChecks: { checkFindingsPauseThreshold: 5 } })).toBe(5);
+ // 0/off when neither is set
+ expect(resolveAutopilotCheckPauseThreshold({}, null)).toBe(0);
+ // a non-integer at any layer falls through to the next
+ expect(resolveAutopilotCheckPauseThreshold(
+ { checkFindingsPauseThreshold: 2.5 },
+ { pipelineEditorialChecks: { checkFindingsPauseThreshold: 'x' } },
+ )).toBe(0);
+ });
+
it('regenerates the arc for an arc-only series with no volumes', () => {
const arcOnly = { targetFormat: 'comic', arc: { logline: 'L', summary: 'S' }, seasons: [] };
expect(resolveNextStep(arcOnly, []).kind).toBe('generateArc');
@@ -409,6 +436,18 @@ describe('resolveNextStep (pure)', () => {
expect(gateNote({ readinessGate: 'bogus' })).toMatch(/gate: noOpenHigh$/);
});
+ it('dry-run plan annotates the editorial-checks step with the pause threshold when armed (#1613)', () => {
+ const series = { targetFormat: 'comic', arc: { logline: 'L', summary: 'S' }, seasons: [{ id: 'se1', number: 1 }] };
+ const issues = [{ id: 'i1', seasonId: 'se1', number: 1, arcPosition: 1, stages: {} }];
+ const noteFor = (opts) => autopilot.__testing.buildDryRunPlan(series, issues, opts)
+ .find((p) => p.kind === 'editorialChecks')?.note;
+ // Off (default / 0) → no pause annotation.
+ expect(noteFor({})).not.toMatch(/pauses at/);
+ expect(noteFor({ checkFindingsPauseThreshold: 0 })).not.toMatch(/pauses at/);
+ // Armed → the threshold is surfaced in the note.
+ expect(noteFor({ checkFindingsPauseThreshold: 5 })).toMatch(/pauses at ≥ 5 high finding/);
+ });
+
it('asks to generate episodes for a season with no issues', () => {
const step = resolveNextStep(comic, []);
expect(step).toMatchObject({ kind: 'generateEpisodes', seasonId: 'se1' });
@@ -1508,6 +1547,48 @@ describe('autopilot conductor', () => {
expect(done?.editorialCheckErroredIds).toEqual([]);
});
+ it('pauses at editorialChecks when high findings ≥ the armed threshold (#1613)', async () => {
+ editorialChecksFindings = [
+ { severity: 'high', checkId: 'pacing', location: 'ch 1', problem: 'pacing stalls' },
+ { severity: 'high', checkId: 'continuity', location: 'ch 2', problem: 'timeline contradiction' },
+ { severity: 'medium', checkId: 'pacing', location: 'ch 3', problem: 'minor lull' },
+ ];
+ const { seriesId } = await seedComplete();
+ await autopilot.startSeriesAutopilot(seriesId, { includeVisual: false, checkFindingsPauseThreshold: 2 });
+ await waitFor(runFinished(seriesId));
+ const last = autopilot.__testing.runs.get(seriesId)?.lastPayload;
+ expect(last?.type).toBe('paused');
+ expect(last?.pauseKind).toBe('checkFindings');
+ expect(last?.scope).toBe('editorialChecks');
+ // Only the two HIGH findings are carried as residual (the medium is excluded).
+ expect(last?.residualFindings).toHaveLength(2);
+ expect(last.residualFindings.every((f) => f.severity === 'high')).toBe(true);
+ const marker = (await seriesSvc.getSeries(seriesId)).autopilot;
+ expect(marker.status).toBe('paused');
+ expect(marker.pauseKind).toBe('checkFindings');
+ });
+
+ it('does NOT pause on high findings when the threshold is off by default (#1613)', async () => {
+ editorialChecksFindings = [
+ { severity: 'high', checkId: 'pacing', location: 'ch 1', problem: 'a' },
+ { severity: 'high', checkId: 'pacing', location: 'ch 2', problem: 'b' },
+ { severity: 'high', checkId: 'pacing', location: 'ch 3', problem: 'c' },
+ ];
+ const { seriesId } = await seedComplete();
+ await autopilot.startSeriesAutopilot(seriesId, { includeVisual: false });
+ await waitFor(runFinished(seriesId));
+ // No threshold → the checks pass stays advisory and the run completes.
+ expect(autopilot.__testing.runs.get(seriesId)?.lastPayload?.type).toBe('complete');
+ });
+
+ it('does NOT pause when high findings fall below the armed threshold (#1613)', async () => {
+ editorialChecksFindings = [{ severity: 'high', checkId: 'pacing', location: 'ch 1', problem: 'a' }];
+ const { seriesId } = await seedComplete();
+ await autopilot.startSeriesAutopilot(seriesId, { includeVisual: false, checkFindingsPauseThreshold: 3 });
+ await waitFor(runFinished(seriesId));
+ expect(autopilot.__testing.runs.get(seriesId)?.lastPayload?.type).toBe('complete');
+ });
+
it('forwards a per-run editorialCheckIds subset to the checks pass + budget gate (#1575)', async () => {
const { seriesId } = await seedComplete();
await autopilot.startSeriesAutopilot(seriesId, { editorialCheckIds: ['pacing'], includeVisual: false });