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

fix: resolve the arc-spine gate at arc/volume scope, not episode scope

[._.]/ Adam Eivyb134ff0c20a0
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index eec160a0a6..96635dcee6 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -22,6 +22,8 @@
## Fixed
+- **The pre-episode arc-spine check now resolves at the altitude it judged at.** That checkpoint deliberately verifies the arc spine with the episode lineup hidden — no episodes have been planned in earnest yet, so it only asks whether the premise, principals, engine, and volume allocation are safe to expand. The auto-resolver behind it, though, was still handed the full episode lineup and the general "correct an episode synopsis when the contradiction originates there" instruction, so it answered spine findings by rewriting episode synopses the gate had never read. Those edits could not close what was flagged, the arc and volume text stayed unfixed, and the next spine verification came back with twice the blockers — a round that got reverted wholesale and paused the run. (Observed on a run that went in with 3 blocking findings, spent its round editing 3 episode synopses, and came back with 6.) Spine rounds now render the resolver the same episode-empty plan the verifier saw, tell it to fix the arc and volumes only, and discard any episode edits it returns anyway, so a customized or stale installed prompt can't re-open the blast radius. Nothing changes for the full arc gate that runs after episodes exist: it still verifies and repairs episode synopses, which is the only place an episode-scoped contradiction can converge. Sparse finding-keyed patches and the blocker-count rollback are untouched.
+
- **A reverted arc auto-resolve round no longer ends the whole run on its first bad attempt.** Arc verification correctly refuses to keep a resolver rewrite that raises the blocking-finding count — but it then stopped the run and asked you to fix the arc by hand, and resuming just re-ran the identical prompt against the identical restored plan, so the gate could regress the same way forever. (Observed on a spine check that went in with 3 blockers, came back with 6, and paused on round 2 of 3.) The revert still happens exactly as before; what follows it is now one bounded corrective pass. The resolver is re-run from the restored best plan, handed the findings that plan actually has, plus — this is the new information — the problems its own discarded attempt just authored, named explicitly as the failure mode to avoid rather than as more work to close. Only when that second attempt also regresses does the gate pause for review, with the same best-state residual and discarded set it reported before. A retry is never spent on the final round (nothing would verify it), it is budget-checked and billed like any other resolve, and `maxArcResolveRetries: 0` restores the previous stop-on-first-regression behavior per run. The live status line now distinguishes a rollback that is retrying from one that is about to pause.
- **A provider outage no longer hands a CoS task's model pin to a provider that can't run it.** A task pinned to Antigravity with `gemini-3.6-flash` hit an auth outage on that provider; the fallback chain correctly swapped it onto the Claude CLI but carried the Antigravity model id along, so every retry spawned `claude --model gemini-3.6-flash` and died in ~1.5s ("There's an issue with the selected model") until the task exhausted its retries and blocked. The pass-through exemption that let it through is deliberate — it exists so an explicit pin isn't silently downgraded to the provider's heaviest default just because the provider's `models` list spells an alias differently — but it only makes sense on the provider the pin was chosen *for*. A `metadata.model` pin is provider-scoped (the task form picks a provider, then a model from that provider's catalog), so a fallback swap now drops it back to the new provider's own default unless that provider actually lists it, logging the substitution rather than doing it silently. A swap between siblings that both serve the pinned id (claude-code ↔ claude-code-tui) still keeps it, and a run with no swap at all is untouched. The check also covers a fallback provider that enumerates no models, which the existing model-list validation could not inspect at all.
diff --git a/data.reference/prompts/stages/pipeline-arc-resolve.md b/data.reference/prompts/stages/pipeline-arc-resolve.md
index acb40cef18..dfe914bbb0 100644
--- a/data.reference/prompts/stages/pipeline-arc-resolve.md
+++ b/data.reference/prompts/stages/pipeline-arc-resolve.md
@@ -68,6 +68,18 @@ When rewriting the arc + volume synopses, preserve the picked shape — do not c
{{seasonsTreeJson}}
```
+{{#arcSpineOnly}}
+This is the pre-episode **arc-spine checkpoint**. The episode arrays are
+intentionally empty — no episode lineup exists yet, and the verification pass
+that produced the findings below judged this same episode-free plan. Resolve
+every finding by editing the **arc and the volumes only**. Do **not** return an
+`episodes[]` array: the server discards it here, so an episode rewrite spends
+the round without closing anything. Every instruction below about anchoring in
+per-episode synopses, or about correcting an episode whose own content caused a
+finding, describes the later full-arc gate and does not apply at this
+checkpoint.
+{{/arcSpineOnly}}
+
## Structural recommendation
The recommended structure for this issue budget is **{{recommendedStructure}}** ({{recommendedSeasonCount}} volumes, per-volume counts {{recommendedPerSeasonJson}}). Comic-as-TV industry norm is 6–10 issues per volume; deviate from this only if a finding explicitly demands it.
diff --git a/scripts/migrations/005-shape-aware-arc-prompts.js b/scripts/migrations/005-shape-aware-arc-prompts.js
index b9dba2aeab..edb611f350 100644
--- a/scripts/migrations/005-shape-aware-arc-prompts.js
+++ b/scripts/migrations/005-shape-aware-arc-prompts.js
@@ -53,7 +53,7 @@ export const NEW_SHIPPED_MD5 = {
'pipeline-arc-verify.md': '83347e7d923580a3062033ab39b3c14b', // post-250 arc spine checkpoint
'pipeline-volume-verify.md': '49458d36700cb94e34806d536ffe2940', // post-019
'pipeline-season-episodes.md': 'a88e8e78a949b7aaf500d03314e2ea0b', // post-172 (structure rules)
- 'pipeline-arc-resolve.md': '0787128babf3c4c50e2f2cdb60214030', // post-252 (corrective-pass avoid list)
+ 'pipeline-arc-resolve.md': '0611db539437083621e19bb88b005e8d', // post-253 (spine-scoped rounds)
};
const { applyMigration, up } = makePromptReplaceMigration({
diff --git a/scripts/migrations/019-arc-volume-prompts-canon-context.js b/scripts/migrations/019-arc-volume-prompts-canon-context.js
index 6d45d5e062..f2a26332a0 100644
--- a/scripts/migrations/019-arc-volume-prompts-canon-context.js
+++ b/scripts/migrations/019-arc-volume-prompts-canon-context.js
@@ -62,7 +62,7 @@ export const ACCEPTED_OLD_MD5 = {
export const NEW_SHIPPED_MD5 = {
'pipeline-arc-overview.md': '5ed760caaf3cf88916ec28b220e2f590', // post-250 arc spine checkpoint
'pipeline-arc-verify.md': '83347e7d923580a3062033ab39b3c14b', // post-250 arc spine checkpoint
- 'pipeline-arc-resolve.md': '0787128babf3c4c50e2f2cdb60214030', // post-252 (corrective-pass avoid list)
+ 'pipeline-arc-resolve.md': '0611db539437083621e19bb88b005e8d', // post-253 (spine-scoped rounds)
'pipeline-volume-verify.md': '49458d36700cb94e34806d536ffe2940', // post-019
};
diff --git a/scripts/migrations/023-resolve-prompt-episode-anchor.js b/scripts/migrations/023-resolve-prompt-episode-anchor.js
index f47c82c7ed..7b32b9361e 100644
--- a/scripts/migrations/023-resolve-prompt-episode-anchor.js
+++ b/scripts/migrations/023-resolve-prompt-episode-anchor.js
@@ -40,7 +40,7 @@ export const ACCEPTED_OLD_MD5 = {
// drift-catch test stays green against the live data.reference sample; a fresh
// install at the pre-123 hash still advances cleanly via the accepted-OLD list.
export const NEW_SHIPPED_MD5 = {
- 'pipeline-arc-resolve.md': '0787128babf3c4c50e2f2cdb60214030', // post-252 (corrective-pass avoid list)
+ 'pipeline-arc-resolve.md': '0611db539437083621e19bb88b005e8d', // post-253 (spine-scoped rounds)
};
const { applyMigration, up } = makePromptReplaceMigration({
diff --git a/scripts/migrations/245-arc-resolve-finding-keyed-patches.js b/scripts/migrations/245-arc-resolve-finding-keyed-patches.js
index 45d59c9045..436042b490 100644
--- a/scripts/migrations/245-arc-resolve-finding-keyed-patches.js
+++ b/scripts/migrations/245-arc-resolve-finding-keyed-patches.js
@@ -28,7 +28,7 @@ export const ACCEPTED_OLD_MD5 = {
};
export const NEW_SHIPPED_MD5 = {
- 'pipeline-arc-resolve.md': '0787128babf3c4c50e2f2cdb60214030', // post-252 (corrective-pass avoid list)
+ 'pipeline-arc-resolve.md': '0611db539437083621e19bb88b005e8d', // post-253 (spine-scoped rounds)
};
const { applyMigration, up } = makePromptReplaceMigration({
diff --git a/scripts/migrations/251-arc-resolve-field-sparsity.js b/scripts/migrations/251-arc-resolve-field-sparsity.js
index 8a792cf022..a8bb639e79 100644
--- a/scripts/migrations/251-arc-resolve-field-sparsity.js
+++ b/scripts/migrations/251-arc-resolve-field-sparsity.js
@@ -12,7 +12,7 @@ export const ACCEPTED_OLD_MD5 = {
};
export const NEW_SHIPPED_MD5 = {
- 'pipeline-arc-resolve.md': '0787128babf3c4c50e2f2cdb60214030', // post-252 (corrective-pass avoid list)
+ 'pipeline-arc-resolve.md': '0611db539437083621e19bb88b005e8d', // post-253 (spine-scoped rounds)
};
const { applyMigration, up } = makePromptReplaceMigration({
diff --git a/scripts/migrations/252-arc-resolve-avoid-list.js b/scripts/migrations/252-arc-resolve-avoid-list.js
index 843f3cd3e7..deee0b1339 100644
--- a/scripts/migrations/252-arc-resolve-avoid-list.js
+++ b/scripts/migrations/252-arc-resolve-avoid-list.js
@@ -14,7 +14,7 @@ export const ACCEPTED_OLD_MD5 = {
};
export const NEW_SHIPPED_MD5 = {
- 'pipeline-arc-resolve.md': '0787128babf3c4c50e2f2cdb60214030',
+ 'pipeline-arc-resolve.md': '0611db539437083621e19bb88b005e8d', // post-253 (spine-scoped rounds)
};
const { applyMigration, up } = makePromptReplaceMigration({
diff --git a/scripts/migrations/253-arc-resolve-spine-scope.js b/scripts/migrations/253-arc-resolve-spine-scope.js
new file mode 100644
index 0000000000..75ed775dc5
--- /dev/null
+++ b/scripts/migrations/253-arc-resolve-spine-scope.js
@@ -0,0 +1,32 @@
+/**
+ * Keep the arc auto-resolve prompt at the altitude the verifier judged.
+ *
+ * The pre-episode arc-spine checkpoint verifies an episode-empty plan, but the
+ * resolver was handed the full episode lineup and answered spine findings with
+ * episode-synopsis rewrites the gate never evaluated — a round that could not
+ * close what it was given and got reverted for growing the blocker count. This
+ * adds the `{{#arcSpineOnly}}` section that scopes those rounds to arc/volume
+ * edits; the server discards any `episodes[]` they return regardless.
+ */
+
+import { makePromptReplaceMigration } from './_lib.js';
+
+export const ACCEPTED_OLD_MD5 = {
+ 'pipeline-arc-resolve.md': ['0787128babf3c4c50e2f2cdb60214030'],
+};
+
+export const NEW_SHIPPED_MD5 = {
+ 'pipeline-arc-resolve.md': '0611db539437083621e19bb88b005e8d', // post-253 (spine-scoped rounds)
+};
+
+const { applyMigration, up } = makePromptReplaceMigration({
+ accepted: ACCEPTED_OLD_MD5,
+ current: NEW_SHIPPED_MD5,
+ label: 'arc-resolve spine-scoped rounds',
+ customizedHint: (filename) =>
+ ` To upgrade it manually, diff data.reference/prompts/stages/${filename}\n` +
+ ` against data/prompts/stages/${filename} and add the {{#arcSpineOnly}} section that scopes the pre-episode round to arc + volume edits.`,
+});
+
+export { applyMigration };
+export default { up };
diff --git a/scripts/migrations/253-arc-resolve-spine-scope.test.js b/scripts/migrations/253-arc-resolve-spine-scope.test.js
new file mode 100644
index 0000000000..8a6bc01cf1
--- /dev/null
+++ b/scripts/migrations/253-arc-resolve-spine-scope.test.js
@@ -0,0 +1,38 @@
+import { readFileSync } from 'fs';
+import { describe, expect, it } from 'vitest';
+
+import { repoRoot, runPromptMigrationTests } from './_testHelpers.js';
+import migration, {
+ ACCEPTED_OLD_MD5,
+ NEW_SHIPPED_MD5,
+ applyMigration,
+} from './253-arc-resolve-spine-scope.js';
+
+describe('migration 253 — arc-resolve spine-scoped rounds', () => {
+ runPromptMigrationTests({
+ migration,
+ applyMigration,
+ ACCEPTED_OLD_MD5,
+ NEW_SHIPPED_MD5,
+ prefix: 'migration-253-arc-resolve-spine-',
+ });
+
+ it('scopes the pre-episode round to arc + volume edits', () => {
+ const prompt = readFileSync(
+ `${repoRoot}/data.reference/prompts/stages/pipeline-arc-resolve.md`,
+ 'utf8',
+ );
+ // Gated on the same flag buildVerifyContext sets for the verifier, so the
+ // full arc gate (after episodes exist) renders none of this and keeps its
+ // episode-correction capability.
+ expect(prompt).toContain('{{#arcSpineOnly}}');
+ expect(prompt).toContain('{{/arcSpineOnly}}');
+ // The section has to say the episode arrays are empty BY DESIGN — a
+ // resolver that reads them as missing data invents an episode lineup.
+ expect(prompt).toMatch(/intentionally empty/);
+ expect(prompt).toMatch(/arc and the volumes only/);
+ expect(prompt).toMatch(/Do \*\*not\*\* return an\s+`episodes\[\]` array/);
+ // Rule 8 (episode corrections) still ships for the full gate.
+ expect(prompt).toMatch(/Correct an episode synopsis when the contradiction/);
+ });
+});
diff --git a/scripts/setup-data-drift.test.js b/scripts/setup-data-drift.test.js
index 98a738ba1d..128db7b542 100644
--- a/scripts/setup-data-drift.test.js
+++ b/scripts/setup-data-drift.test.js
@@ -33,7 +33,7 @@ const EXPECTED_STAGE_OLD = {
'pipeline-arc-overview.md': ['6a3ecab43d1f46b7ef9aab6c69ea0326', 'd34d72b8e49ba303d38607845dd87f1c', '0a1f6ffa6908522e3690c5e9e53a6ee0', '612f8b04950e2ff26dd350dd76a062fe', '74d6c26548660d85fc345b2099c63b6c', '648e11352cd1565aee490de1f662bef0'],
'pipeline-arc-verify.md': ['52e31abc93e3105176236fcaa5d1575a', 'ff56d8387162017e08d5d0491060ddd6', '36aa70cdfc25d7549573a4d556e7702c'],
'pipeline-volume-verify.md': ['03f3c874cb80e1c98abcf03168fa7a92', 'c6ea28e972ad6e229bafb2d602b4dda3'],
- 'pipeline-arc-resolve.md': ['5b340885c6e8f8afc63424d6b5bc7eb7', '87bc5c01f1a8a97b681727a38b05edc6', '8bb134554c122d1583c479ab3010e53d', '8e348f3d1894382889f9f0ee7d5c6792', '96f73a7e90526d65ef2bb100fb1cd4bf', 'a8677bbe1eb38f871fb152a5b0fec7c6', 'cc27b4da1d1a13c35e35d1c2d6183815'],
+ 'pipeline-arc-resolve.md': ['0787128babf3c4c50e2f2cdb60214030', '5b340885c6e8f8afc63424d6b5bc7eb7', '87bc5c01f1a8a97b681727a38b05edc6', '8bb134554c122d1583c479ab3010e53d', '8e348f3d1894382889f9f0ee7d5c6792', '96f73a7e90526d65ef2bb100fb1cd4bf', 'a8677bbe1eb38f871fb152a5b0fec7c6', 'cc27b4da1d1a13c35e35d1c2d6183815'],
'pipeline-script-verify.md': ['ed6c8101644cfe56a100eb6bfe3587f3'],
'pipeline-extract-scenes.md': ['59fa5ee305ce53d91eb15224d8b546d3', 'c51fb208568d0d903eb43b437478b0ba'],
'writers-room-places.md': ['24a33628cc94d80fa5ca60831d973daf', '7f1f80eb63d67a21161994cde115045e'],
@@ -63,7 +63,7 @@ const EXPECTED_STAGE_NEW = {
'pipeline-arc-overview.md': '5ed760caaf3cf88916ec28b220e2f590',
'pipeline-arc-verify.md': '83347e7d923580a3062033ab39b3c14b',
'pipeline-volume-verify.md': '49458d36700cb94e34806d536ffe2940',
- 'pipeline-arc-resolve.md': '0787128babf3c4c50e2f2cdb60214030',
+ 'pipeline-arc-resolve.md': '0611db539437083621e19bb88b005e8d',
'pipeline-script-verify.md': '722c62462d05462603cf67ca0ed1dee8',
'pipeline-extract-scenes.md': '9f404b0c4721b23932a6d2dcfc1fba43',
'writers-room-places.md': 'a7f68e51dd6b4421d20f5bd9d855d9b4',
diff --git a/server/services/pipeline/arcPlanner.test.js b/server/services/pipeline/arcPlanner.test.js
index 3e82bf647d..650b4bba74 100644
--- a/server/services/pipeline/arcPlanner.test.js
+++ b/server/services/pipeline/arcPlanner.test.js
@@ -1196,6 +1196,67 @@ describe('arcPlanner — resolveVerifyIssues', () => {
expect(updated.stages.idea.input).toBe('corrected — the Atrium is NOT convened here');
});
+ // The pre-episode arc-spine gate verifies an episode-EMPTY plan (#3789). A
+ // resolver handed the full lineup answered spine findings with episode
+ // rewrites the gate never read: they could not close what was flagged, and
+ // the round got reverted for doubling the blocker count. Both halves of the
+ // loop have to see the same plan.
+ it('renders the resolve prompt with empty episode arrays in spineOnly mode', async () => {
+ const s = await setupSeries();
+ await seriesSvc.updateSeries(s.id, { arc: { logline: 'L' } });
+ const season = await seasonsSvc.createSeason(s.id, { title: 'Vol 1', episodeCountTarget: 1 });
+ const issue = await issuesSvc.createIssue({ seriesId: s.id, seasonId: season.id, title: 'Ep' });
+ await issuesSvc.updateStage(issue.id, 'idea', { input: 'seeded episode synopsis', status: 'empty' });
+
+ stageRunnerSpy = vi.fn(async () => ({
+ content: { arc: { logline: 'L2', summary: 'S', themes: [], protagonistArc: '' }, seasons: [], notes: '' },
+ runId: 'r', providerId: 'p', model: 'm',
+ }));
+
+ await planner.resolveVerifyIssues(s.id, {
+ spineOnly: true,
+ findings: [{ severity: 'high', problem: 'spine problem', suggestion: 'fix the arc' }],
+ });
+
+ const ctx = stageRunnerSpy.mock.calls[0][1];
+ expect(ctx.arcSpineOnly).toBe(true);
+ expect(JSON.parse(ctx.seasonsTreeJson)[0].episodes).toEqual([]);
+ expect(ctx.seasonsTreeJson).not.toContain('seeded episode synopsis');
+ });
+
+ it('discards episode edits in spineOnly mode and leaves the planned synopses untouched', async () => {
+ const s = await setupSeries();
+ await seriesSvc.updateSeries(s.id, { arc: { logline: 'L' } });
+ const season = await seasonsSvc.createSeason(s.id, { title: 'Vol 1', episodeCountTarget: 1 });
+ const issue = await issuesSvc.createIssue({ seriesId: s.id, seasonId: season.id, title: 'Ep' });
+ await issuesSvc.updateStage(issue.id, 'idea', { input: 'original episode synopsis', status: 'empty' });
+ const fresh = await issuesSvc.getIssue(issue.id);
+
+ stageRunnerSpy = vi.fn(async () => ({
+ content: {
+ arc: { resolves: ['f1'], logline: 'L2', summary: 'S', themes: [], protagonistArc: '' },
+ seasons: [],
+ // A stale/customized installed prompt can still return these — the
+ // server drops them rather than trusting the template alone.
+ episodes: [{ resolves: ['f1'], seasonNumber: season.number, episodeNumber: fresh.number, synopsis: 'out-of-scope rewrite' }],
+ notes: '',
+ },
+ runId: 'r', providerId: 'p', model: 'm',
+ }));
+
+ const out = await planner.resolveVerifyIssues(s.id, {
+ spineOnly: true,
+ findings: [{ severity: 'high', problem: 'spine problem', suggestion: 'fix the arc' }],
+ });
+
+ // The arc/volume half of the patch still lands — this scopes the round, it
+ // does not disable it.
+ expect(out.series.arc.logline).toBe('L2');
+ expect(out.episodesResolved).toEqual([]);
+ const untouched = await issuesSvc.getIssue(issue.id);
+ expect(untouched.stages.idea.input).toBe('original episode synopsis');
+ });
+
it('clears stale beats when correcting an episode that was already expanded', async () => {
const s = await setupSeries();
await seriesSvc.updateSeries(s.id, { arc: { logline: 'L' } });
@@ -1331,6 +1392,31 @@ describe('selectFindingKeyedEdits (pure resolve-edit filter, #3724)', () => {
.toMatchObject({ legacy: false, seasonsDropped: 1 });
});
+ // #3789 — a spine round's findings were produced against an episode-empty
+ // plan, so every episode edit is out of scope no matter which finding it
+ // names. Counted apart from `episodesDropped` (a different diagnosis) and
+ // applied even to a legacy unkeyed response, which is the one an install with
+ // a pre-#3789 prompt will send.
+ it('drops every episode edit in spineOnly mode, keyed or not', () => {
+ const spine = (content) => planner.selectFindingKeyedEdits(content, findings, { spineOnly: true });
+ const keyed = spine({
+ arc: { resolves: ['f1'], logline: 'x' },
+ seasons: [{ resolves: ['f1'] }],
+ episodes: [{ resolves: ['f1'] }, { resolves: ['f2'] }],
+ });
+ expect(keyed.arc?.logline).toBe('x');
+ expect(keyed.seasons).toHaveLength(1);
+ expect(keyed.episodes).toEqual([]);
+ expect(keyed.episodesOutOfScope).toBe(2);
+ expect(keyed.episodesDropped).toBe(0);
+ expect(spine({ episodes: [{ synopsis: 'y' }] }))
+ .toMatchObject({ legacy: true, episodes: [], episodesOutOfScope: 1 });
+ // Full-arc rounds are untouched — episode corrections are how an
+ // episode-scoped finding converges there.
+ expect(select({ episodes: [{ resolves: ['f1'] }] }))
+ .toMatchObject({ episodesOutOfScope: 0 });
+ });
+
it('tolerates a missing/garbage response', () => {
expect(select(null)).toMatchObject({ legacy: true, arc: null, seasons: [], episodes: [] });
expect(select({ arc: 'not an object', seasons: 'nope', episodes: [null, 3] }))
diff --git a/server/services/pipeline/arcPlanner/arcCore.js b/server/services/pipeline/arcPlanner/arcCore.js
index 4a9e2cf96b..800b526cd1 100644
--- a/server/services/pipeline/arcPlanner/arcCore.js
+++ b/server/services/pipeline/arcPlanner/arcCore.js
@@ -363,7 +363,15 @@ export async function verifyVolume(seriesId, seasonId, options = {}) {
* `resolves: ["f2", …]` naming at least one input finding — an edit that names
* none can't be closing anything, so applying it is all blast radius and no
* benefit. Returns `{ legacy, arc, arcDropped, seasons, seasonsDropped,
- * episodes, episodesDropped }`.
+ * episodes, episodesDropped, episodesOutOfScope }`.
+ *
+ * `spineOnly` drops every episode edit regardless of what it names (#3789): a
+ * spine round is judged against an episode-empty plan, so an episode rewrite
+ * cannot close the finding it declares — it only mutates records the gate never
+ * read. Counted separately from `episodesDropped` because the two are different
+ * diagnoses (wrong scope vs. named no finding), and enforced here rather than
+ * trusting the prompt alone so a customized/stale installed template can't
+ * re-open the blast radius.
*
* `legacy` is the escape hatch for an install whose `pipeline-arc-resolve.md`
* was customized before #3724 and therefore never got the migration: when NOT
@@ -374,7 +382,7 @@ export async function verifyVolume(seriesId, seasonId, options = {}) {
* old full-list rewrite) and logged. A response that keys SOME of its edits is
* on the new contract, so its unkeyed entries are genuine drops.
*/
-export function selectFindingKeyedEdits(content, findings) {
+export function selectFindingKeyedEdits(content, findings, { spineOnly = false } = {}) {
const validIds = findingIdSet(findings);
const isEdit = (e) => !!e && typeof e === 'object';
const arcEdit = isEdit(content?.arc) ? content.arc : null;
@@ -384,7 +392,7 @@ export function selectFindingKeyedEdits(content, findings) {
.some((e) => e && matchResolvedFindings(e, validIds).declared);
const targeted = (raw) => legacy || matchResolvedFindings(raw, validIds).matched.length > 0;
const seasons = seasonsRaw.filter(targeted);
- const episodes = episodesRaw.filter(targeted);
+ const episodes = spineOnly ? [] : episodesRaw.filter(targeted);
return {
legacy,
arc: arcEdit && targeted(arcEdit) ? arcEdit : null,
@@ -392,7 +400,8 @@ export function selectFindingKeyedEdits(content, findings) {
seasons,
seasonsDropped: seasonsRaw.length - seasons.length,
episodes,
- episodesDropped: episodesRaw.length - episodes.length,
+ episodesDropped: spineOnly ? 0 : episodesRaw.length - episodes.length,
+ episodesOutOfScope: spineOnly ? episodesRaw.length : 0,
};
}
@@ -404,7 +413,15 @@ export function selectFindingKeyedEdits(content, findings) {
// everything it returns. `options.avoid` is the optional "a previous attempt at
// these same findings authored THESE and was reverted" list (see
// buildResolveContext) — set only by a corrective pass.
+// `options.spineOnly` mirrors verifyArc's pre-episode arc-spine mode: the
+// resolver sees the same episode-empty plan and may only patch the arc +
+// volumes (#3789). It is a PAIRING constraint, not an independent knob — it
+// must match the verify that produced `options.findings`, or the resolver
+// answers at an altitude the gate never judged. Episode-synopsis corrections
+// stay available for the later full arc gate, which runs after episodes exist
+// and actually judges them.
export async function resolveVerifyIssues(seriesId, options = {}) {
+ const spineOnly = options.spineOnly === true;
const series = await getSeries(seriesId);
if (!series.arc) {
throw new ServerError(
@@ -428,6 +445,9 @@ export async function resolveVerifyIssues(seriesId, options = {}) {
let findings = shapeFindings(options.findings);
if (!findings.length) {
+ // The spread is load-bearing: it carries `spineOnly` into the refresh, which
+ // is the one path where the verify and the resolve it feeds are the same
+ // call and so must not drift apart in altitude.
const fresh = await verifyArc(seriesId, { ...options, preloadedWorld: world });
findings = fresh.issues || [];
if (!findings.length) {
@@ -438,7 +458,7 @@ export async function resolveVerifyIssues(seriesId, options = {}) {
// `options.avoid` carries the findings a reverted earlier attempt at these
// same findings authored, so a corrective pass is told what NOT to re-create
// instead of re-running the identical prompt and regressing identically.
- const ctx = await buildResolveContext(series, findings, world, { avoid: options.avoid });
+ const ctx = await buildResolveContext(series, findings, world, { avoid: options.avoid, spineOnly });
const { content, runId, providerId, model } = await runStagedLLM(
'pipeline-arc-resolve',
ctx,
@@ -459,7 +479,7 @@ export async function resolveVerifyIssues(seriesId, options = {}) {
// untargeted rewrite is pure blast radius: it can't close anything, and every
// volume it touches is a chance to author the contradiction the next verify
// files as a brand-new blocker.
- const edits = selectFindingKeyedEdits(content, findings);
+ const edits = selectFindingKeyedEdits(content, findings, { spineOnly });
// Only worth saying when there is actually something to apply unkeyed — a
// response that proposed NO edits reads as legacy too, and warning about a
// stale prompt there would be a lie.
@@ -472,6 +492,9 @@ export async function resolveVerifyIssues(seriesId, options = {}) {
if (edits.seasonsDropped || edits.episodesDropped) {
console.log(`⚠️ arc-resolve: dropped ${edits.seasonsDropped} volume + ${edits.episodesDropped} episode edit(s) naming no input finding`);
}
+ if (edits.episodesOutOfScope) {
+ console.log(`⚠️ arc-resolve: discarded ${edits.episodesOutOfScope} episode edit(s) — the arc-spine gate resolves at arc/volume scope only`);
+ }
const arc = sanitizeArc({
logline: edits.arc?.logline || series.arc.logline || '',
diff --git a/server/services/pipeline/arcPlanner/context.js b/server/services/pipeline/arcPlanner/context.js
index c4dc84d880..13250d128d 100644
--- a/server/services/pipeline/arcPlanner/context.js
+++ b/server/services/pipeline/arcPlanner/context.js
@@ -509,11 +509,14 @@ export function groupIssuesBySeasonTree(seasons, issues, { renderLeaf, seasonFie
export async function buildVerifyContext(series, preloadedWorld, { spineOnly = false } = {}) {
const seasons = sanitizeSeasonList(series.seasons || []);
const [issues, base, canon] = await Promise.all([
- listIssues({ seriesId: series.id }),
+ // Spine mode renders no episode leaves, so don't pay for the load — every
+ // issue's full record (stage run history included) fetched and sanitized to
+ // be thrown away one line later.
+ spineOnly ? [] : listIssues({ seriesId: series.id }),
buildArcBaseContext(series, preloadedWorld),
getSeriesPlanningCanon(series),
]);
- const tree = groupIssuesBySeasonTree(seasons, spineOnly ? [] : issues, {
+ const tree = groupIssuesBySeasonTree(seasons, issues, {
// `synopsis` key (not `beats`) so it matches the prompt's existing
// language; sourced from idea.input which carries the LLM's logline+synopsis.
renderLeaf: (iss) => ({
@@ -712,9 +715,14 @@ export function matchResolvedFindings(raw, validIds) {
* `findingsJson`: asking the resolver to close a problem the plan no longer has
* is how a corrective pass invents a fresh contradiction. Absent/empty on a
* first attempt, which leaves the prompt section out entirely.
+ *
+ * `options.spineOnly` renders the same episode-empty plan the pre-episode
+ * checkpoint's verify saw, and sets the `arcSpineOnly` flag the prompt gates
+ * its scope prohibition on — see `resolveVerifyIssues` for why the two halves
+ * have to agree (#3789).
*/
export async function buildResolveContext(series, findings, preloadedWorld, options = {}) {
- const ctx = await buildVerifyContext(series, preloadedWorld);
+ const ctx = await buildVerifyContext(series, preloadedWorld, { spineOnly: options.spineOnly === true });
const structure = recommendStructure(series.issueCountTarget);
const avoid = shapeFindings(options.avoid);
return {
diff --git a/server/services/pipeline/seriesAutopilot.test.js b/server/services/pipeline/seriesAutopilot.test.js
index d3838d5d49..bafa071db0 100644
--- a/server/services/pipeline/seriesAutopilot.test.js
+++ b/server/services/pipeline/seriesAutopilot.test.js
@@ -1598,6 +1598,30 @@ describe('autopilot conductor', () => {
});
});
+ // The resolver has to plan at the altitude the verifier judged at (#3789).
+ it('scopes the arc-spine gate\'s resolver to spineOnly', async () => {
+ verifyFindings = [{ severity: 'high', problem: 'plot hole', location: 'V1' }];
+ const { seriesId } = await seedComplete();
+ await autopilot.startSeriesAutopilot(seriesId, { maxArcVerifyRounds: 2 });
+ await waitFor(runFinished(seriesId));
+ expect(autopilot.__testing.runs.get(seriesId)?.lastPayload?.scope).toBe('verifyArcSpine');
+ expect(arcSpies.resolveVerifyIssues).toHaveBeenCalledTimes(1);
+ expect(arcSpies.resolveVerifyIssues.mock.calls[0][1]).toMatchObject({ spineOnly: true });
+ });
+
+ it('leaves the full arc gate\'s resolver able to correct episodes', async () => {
+ // Spine passes on round 1 (no arc findings), so the pause below comes from
+ // the post-episode full gate — where episode corrections are the only way
+ // an episode-scoped finding can converge.
+ volumeVerifyFindings = [{ severity: 'high', problem: 'the midpoint promise never pays off', location: 'issue 3' }];
+ const { seriesId } = await seedComplete();
+ await autopilot.startSeriesAutopilot(seriesId, { maxArcVerifyRounds: 2 });
+ await waitFor(runFinished(seriesId));
+ expect(autopilot.__testing.runs.get(seriesId)?.lastPayload?.scope).toBe('verifyArc');
+ expect(arcSpies.resolveVerifyIssues).toHaveBeenCalledTimes(1);
+ expect(arcSpies.resolveVerifyIssues.mock.calls[0][1]).toMatchObject({ spineOnly: false });
+ });
+
// Foundation-quality gate (#2176).
it('foundation gate: a clean foundation (default mock ≥ threshold) passes through to completion', async () => {
foundationScore = 10;
diff --git a/server/services/pipeline/seriesAutopilot/childRuns.js b/server/services/pipeline/seriesAutopilot/childRuns.js
index 67989a7412..48cd16d3ed 100644
--- a/server/services/pipeline/seriesAutopilot/childRuns.js
+++ b/server/services/pipeline/seriesAutopilot/childRuns.js
@@ -76,6 +76,11 @@ export async function runArcVerify(seriesId, record, { spineOnly = false } = {})
record.runState[spineOnly ? 'arcSpineVerified' : 'arcVerified'] = true;
return {};
}
+ // One label for every frame this gate emits. The two gates now RESOLVE
+ // differently, not just verify differently, so a resolve frame labelled `arc`
+ // from a spine round misreports the failure to both the status line and the
+ // stall-diagnosis prompt that replays these frames.
+ const scope = spineOnly ? 'arcSpine' : 'arc';
let convergence = { best: null, sinceBest: 0 };
let changed = false;
// Lowest verified blocker set seen in this gate, paired with the exact arc /
@@ -129,7 +134,7 @@ export async function runArcVerify(seriesId, record, { spineOnly = false } = {})
const findings = [...arcFindings, ...volumeFindings];
const blocking = findings.filter((finding) => record.options.blockingSets.arc.has(finding.severity));
broadcast(seriesId, {
- type: 'verify:round', scope: spineOnly ? 'arcSpine' : 'arc', round, findings: findings.length,
+ type: 'verify:round', scope, round, findings: findings.length,
blocking: blocking.length, volumesChecked: spineOnly ? 0 : (series.seasons || []).length,
});
if (blocking.length === 0) {
@@ -160,7 +165,7 @@ export async function runArcVerify(seriesId, record, { spineOnly = false } = {})
// checks, and would fall out of the loop past every `return` below.
const canRetry = retriesLeft > 0 && round < maxRounds;
broadcast(seriesId, {
- type: 'resolve:rollback', scope: 'arc', round,
+ type: 'resolve:rollback', scope, round,
before: lastResolve.blocking.length, after: blocking.length,
best: rollbackTarget.blocking.length,
reverted: rollback.restored,
@@ -184,6 +189,7 @@ export async function runArcVerify(seriesId, record, { spineOnly = false } = {})
const retried = await resolveVerifyIssues(seriesId, {
findings: rollbackTarget.blocking,
avoid: discarded,
+ spineOnly,
...providerOverrideOpts(record),
...seasonPreserveOpts(record),
});
@@ -194,7 +200,7 @@ export async function runArcVerify(seriesId, record, { spineOnly = false } = {})
lastResolve = rollbackTarget;
await recordDomainUsage('cos', { actions: 1 });
broadcast(seriesId, {
- type: 'resolve:round', scope: 'arc', round, retry: true,
+ type: 'resolve:round', scope, round, retry: true,
episodesEdited: Array.isArray(retried?.episodesResolved) ? retried.episodesResolved.length : 0,
});
continue;
@@ -252,8 +258,13 @@ export async function runArcVerify(seriesId, record, { spineOnly = false } = {})
// equal counts can reflect different, narrower findings after real repairs.
const snapshot = await snapshotArcState(seriesId);
if (isNewBest) bestVerified = { blocking, snapshot };
+ // Resolve at the altitude this gate verified at: the spine round judged an
+ // episode-empty plan, so its resolver may only patch the arc + volumes
+ // (#3789). The later full arc gate keeps episode corrections, which is the
+ // only place they can actually close a finding.
const resolved = await resolveVerifyIssues(seriesId, {
findings: blocking,
+ spineOnly,
...providerOverrideOpts(record),
...seasonPreserveOpts(record),
});
@@ -261,7 +272,7 @@ export async function runArcVerify(seriesId, record, { spineOnly = false } = {})
lastResolve = { blocking, snapshot };
await recordDomainUsage('cos', { actions: 1 });
broadcast(seriesId, {
- type: 'resolve:round', scope: 'arc', round,
+ type: 'resolve:round', scope, round,
episodesEdited: Array.isArray(resolved?.episodesResolved) ? resolved.episodesResolved.length : 0,
});
}