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
report every arc-spine resolver attempt with what it actually wrote
[._.]/ Adam Eivy81ca5d78a7c5
diff --git a/.changelog/next/fixed-agent-0774b6bf.md b/.changelog/next/fixed-agent-0774b6bf.mdnew file mode 100644index 0000000000..8ebc5d6fe1--- /dev/null+++ b/.changelog/next/fixed-agent-0774b6bf.md@@ -0,0 +1 @@+- Arc-verify telemetry now reports every resolver attempt with what it actually wrote — per-record mutation counts plus a categorical reason when nothing changed — so a spine round's edits are no longer invisible behind episodesEdited: 0diff --git a/client/src/components/pipeline/AutopilotPanel.jsx b/client/src/components/pipeline/AutopilotPanel.jsxindex c68d144f85..ee2e2414e7 100644--- a/client/src/components/pipeline/AutopilotPanel.jsx+++ b/client/src/components/pipeline/AutopilotPanel.jsx@@ -295,6 +295,28 @@ const STEP_LABELS = {const stepLabel = (kind) => STEP_LABELS[kind] || kind;+// The record kinds one auto-resolve round can rewrite, in the order a reader+// scans them: the arc first, then down to the episodes.+const MUTATION_LABELS = [+ ['arcFieldsEdited', 'arc field'],+ ['volumesEdited', 'volume'],+ ['characterArcsEdited', 'character arc'],+ ['episodesEdited', 'episode'],+];++// Plain English for the resolver's categorical no-change reasons (the server's+// RESOLVE_NO_CHANGE_REASONS). An unmapped value falls through to the raw token+// rather than vanishing — a reason nobody can read still beats none at all.+const NO_CHANGE_LABELS = {+ 'no-findings': 'there was nothing to resolve',+ 'isolated-candidate-rejected': 'the candidate was too broad to be an isolated repair',+ 'exact-edits-rejected': 'its exact text edits no longer matched the draft',+ 'edits-matched-existing': 'it re-authored text the plan already had',+ 'edits-out-of-scope': 'it answered at an altitude this gate cannot apply',+ 'edits-named-no-finding': 'its edits named none of the findings it was given',+ 'no-edits-returned': 'it proposed no edits at all',+};+// Turn an SSE frame into a one-line status string.function frameLabel(f) {if (!f) return null;@@ -305,6 +327,21 @@ function frameLabel(f) {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)${f.errored > 0 ? ` · ⚠️ ${f.errored} errored` : ''}`;+ // What the auto-resolve round actually wrote. An episode count alone was+ // meaningless at the arc-spine gate (whose resolver may not touch episodes),+ // so name every record kind that moved — and when nothing moved, say why+ // rather than falling through to a raw `resolve:no-change` frame type.+ case 'resolve:round':+ case 'resolve:no-change': {+ const wrote = MUTATION_LABELS+ .filter(([key]) => f[key])+ .map(([key, noun]) => `${f[key]} ${noun}(s)`);+ const lead = `${f.scope} auto-resolve${f.retry ? ' (retry)' : ''} round ${f.round}`;+ if (wrote.length) return `${lead} — rewrote ${wrote.join(', ')}`;+ const why = f.noChangeReason ? ` — ${NO_CHANGE_LABELS[f.noChangeReason] || f.noChangeReason}` : '';+ const rejected = f.rejectedExactEdits ? ` · ${f.rejectedExactEdits} exact text edit(s) rejected` : '';+ return `${lead} — wrote nothing${why}${rejected}`;+ }// An auto-resolve round that left the draft worse was undone — say so live,// or the round's edits appear to still be in place while the run pauses.// A revert is not necessarily the end of the gate: when a corrective pass isdiff --git a/data.reference/prompts/stages/pipeline-observer.md b/data.reference/prompts/stages/pipeline-observer.mdindex 463d35ca45..2330acf2ae 100644--- a/data.reference/prompts/stages/pipeline-observer.md+++ b/data.reference/prompts/stages/pipeline-observer.md@@ -53,6 +53,8 @@ The telemetry frames in this observation window, in order:## How to read the telemetry- `verify:round` / `resolve:round` — a convergence loop iterating. Rounds whose `blocking` count doesn't fall (or rises) mean the auto-fix pass isn't fixing what the verify pass finds.+- `resolve:round` / `resolve:no-change` / `resolve:isolate` — one resolver ATTEMPT and what it wrote. `arcFieldsEdited` / `volumesEdited` / `characterArcsEdited` / `episodesEdited` count the records it rewrote, so read all four: `episodesEdited: 0` is EXPECTED at the `arcSpine` scope, whose resolver may only patch the arc and volumes, and calling that round a no-op on the episode count alone is a misreading. (The `beatContinuity` scope is the exception — its resolver only rewrites episode beats, so `episodesEdited` there is the whole account.)+- `noChangeReason` — on an attempt that wrote nothing, WHICH kind of nothing, and they call for different fixes: `exact-edits-rejected` (its anchors no longer matched the text), `edits-out-of-scope` (it answered at an altitude the gate cannot apply), `edits-named-no-finding` (its edits named none of the findings it was handed), `edits-matched-existing` (it re-authored text the plan already held), `isolated-candidate-rejected` (a per-finding attempt too broad to be one), `no-findings` (there was nothing to resolve), `no-edits-returned` (it proposed nothing at all — a content-level refusal more rounds will not fix).- `check:complete` with `error` — an editorial check **threw**. That dimension was never evaluated, so a "clean" verdict is not actually clean. This is nearly always a code defect.- `child:retry` / `child:escalate` — a delegated child runner (volume beats, text stages) finished with its target stage still empty and had to be retried or escalated.- `step:skip` — a step declined to run. The `reason` says whether that was a legitimate no-op or a swallowed failure.diff --git a/data.reference/prompts/stages/pipeline-self-improve.md b/data.reference/prompts/stages/pipeline-self-improve.mdindex 80000874c7..d06628c642 100644--- a/data.reference/prompts/stages/pipeline-self-improve.md+++ b/data.reference/prompts/stages/pipeline-self-improve.md@@ -44,6 +44,8 @@ The run's retained telemetry frames, in order:## How to read the telemetry- `verify:round` / `resolve:round` — a convergence loop iterating. Rounds whose `blocking` count doesn't fall (or rises) mean the auto-fix pass isn't fixing what the verify pass finds.+- `resolve:round` / `resolve:no-change` / `resolve:isolate` — one resolver ATTEMPT and what it wrote. `arcFieldsEdited` / `volumesEdited` / `characterArcsEdited` / `episodesEdited` count the records it rewrote, so read all four: `episodesEdited: 0` is EXPECTED at the `arcSpine` scope, whose resolver may only patch the arc and volumes, and calling that round a no-op on the episode count alone is a misreading. (The `beatContinuity` scope is the exception — its resolver only rewrites episode beats, so `episodesEdited` there is the whole account.)+- `noChangeReason` — on an attempt that wrote nothing, WHICH kind of nothing, and they call for different fixes: `exact-edits-rejected` (its anchors no longer matched the text), `edits-out-of-scope` (it answered at an altitude the gate cannot apply), `edits-named-no-finding` (its edits named none of the findings it was handed), `edits-matched-existing` (it re-authored text the plan already held), `isolated-candidate-rejected` (a per-finding attempt too broad to be one), `no-findings` (there was nothing to resolve), `no-edits-returned` (it proposed nothing at all — a content-level refusal more rounds will not fix).- `check:complete` with `error` — an editorial check **threw**. That dimension was never evaluated, so a "clean" verdict is not actually clean. This is nearly always a code defect.- `child:retry` / `child:escalate` — a delegated child runner (volume beats, text stages) finished with its target stage still empty and had to be retried or escalated.- `step:skip` — a step declined to run. The `reason` says whether that was a legitimate no-op or a swallowed failure.diff --git a/scripts/migrations/266-resolve-outcome-telemetry-legend.js b/scripts/migrations/266-resolve-outcome-telemetry-legend.jsnew file mode 100644index 0000000000..a2e27708a8--- /dev/null+++ b/scripts/migrations/266-resolve-outcome-telemetry-legend.js@@ -0,0 +1,39 @@+/**+ * Teach the two pipeline-diagnosis prompts to read a resolver attempt's outcome.+ *+ * The arc gate now emits one retained frame per resolver call (`resolve:round`+ * for an attempt that wrote something, `resolve:no-change` for one that did+ * not), carrying per-record mutation counts and a categorical `noChangeReason`.+ * Without this legend the diagnosis keeps making the two misreadings the frames+ * were added to prevent: treating `episodesEdited: 0` as "the resolver did+ * nothing" — it is the EXPECTED report at the arc-spine altitude, whose resolver+ * may only patch the arc and volumes — and treating a stall as one undifferentiated+ * failure when the reason separates a rejected exact-text patch from an+ * out-of-scope answer from an honest content-level refusal.+ */++import { makePromptReplaceMigration } from './_lib.js';++export const ACCEPTED_OLD_MD5 = {+ 'pipeline-observer.md': ['f3dc51ac077050a887c2161ee7438181'],+ 'pipeline-self-improve.md': ['ed0b0df42e0690d515b8dd88911931e4'],+};++export const NEW_SHIPPED_MD5 = {+ 'pipeline-observer.md': '29e0212d2252b1be3278f20e2959eb8e',+ 'pipeline-self-improve.md': '95b378832ff78e5976a6a63fcf328090',+};++const { applyMigration, up } = makePromptReplaceMigration({+ accepted: ACCEPTED_OLD_MD5,+ current: NEW_SHIPPED_MD5,+ label: 'resolve-outcome telemetry legend',+ customizedHint: (filename) =>+ ` To upgrade it manually, diff data.reference/prompts/stages/${filename}\n` ++ ` against data/prompts/stages/${filename} and add the resolve:round /\n` ++ ` resolve:no-change bullet describing the per-record mutation counts and\n` ++ ` the noChangeReason values.`,+});++export { applyMigration };+export default { up };diff --git a/scripts/migrations/266-resolve-outcome-telemetry-legend.test.js b/scripts/migrations/266-resolve-outcome-telemetry-legend.test.jsnew file mode 100644index 0000000000..b4c8b5e485--- /dev/null+++ b/scripts/migrations/266-resolve-outcome-telemetry-legend.test.js@@ -0,0 +1,31 @@+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 './266-resolve-outcome-telemetry-legend.js';++describe('migration 266 — resolve-outcome telemetry legend', () => {+ runPromptMigrationTests({+ migration,+ applyMigration,+ ACCEPTED_OLD_MD5,+ NEW_SHIPPED_MD5,+ prefix: 'migration-266-resolve-outcome-telemetry-legend-',+ });++ for (const filename of ['pipeline-observer.md', 'pipeline-self-improve.md']) {+ it(`${filename} explains what a resolver attempt's outcome frame carries`, () => {+ const prompt = readFileSync(`${repoRoot}/data.reference/prompts/stages/${filename}`, 'utf8');+ expect(prompt).toContain('resolve:no-change');+ expect(prompt).toContain('noChangeReason');+ // The misreading the frames exist to prevent: a spine round's resolver+ // cannot touch episodes, so a zero there is not evidence of a no-op.+ expect(prompt).toContain('arcSpine');+ expect(prompt).toContain('no-edits-returned');+ });+ }+});diff --git a/scripts/setup-data-drift.test.js b/scripts/setup-data-drift.test.jsindex 212a5bfc95..b1fdadd4e6 100644--- a/scripts/setup-data-drift.test.js+++ b/scripts/setup-data-drift.test.js@@ -52,6 +52,8 @@ const EXPECTED_STAGE_OLD = {'pipeline-series-generate.md': ['bc72731124a2bd6304362f4402c6305d'],'pipeline-character-foundation.md': ['f1c0b75a8161c0bc7f26752d148a5c1c', 'cda34127b40754ddbcc8544e3d82572b', 'd6c449c06de73a0868141c899b26e52c', '04419e382f3b46ed92bfaaa1d4f39e13'],'pipeline-judge-foundation.md': ['74c0244e641dcf7a73e9c83123ebdee9', '4c0bd349ff4d329048c9f4ac068745d4', 'edf7850d0c724c63761bc9fb667227d9', '02a8e9215ba534b333f3a29f11f3ac4f'],+ 'pipeline-observer.md': ['f3dc51ac077050a887c2161ee7438181'],+ 'pipeline-self-improve.md': ['ed0b0df42e0690d515b8dd88911931e4'],};const EXPECTED_STAGE_NEW = {'pipeline-idea-expansion.md': 'd6fa86a435f978336661dcabca67258f',@@ -82,6 +84,8 @@ const EXPECTED_STAGE_NEW = {'pipeline-series-generate.md': '21352c21ed6d4edb7a4b7c32704eff55','pipeline-character-foundation.md': 'b7d2bac347e11171606f4c6acfcd32e1','pipeline-judge-foundation.md': 'e44b6c50d741bbd21fc86f481684c410',+ 'pipeline-observer.md': '29e0212d2252b1be3278f20e2959eb8e',+ 'pipeline-self-improve.md': '95b378832ff78e5976a6a63fcf328090',};const EXPECTED_PARTIAL_OLD = {'bible-deference.md': ['218f0e85643609ed85a12b1ccc7b5a8d'],diff --git a/server/services/pipeline/arcPlanner.test.js b/server/services/pipeline/arcPlanner.test.jsindex 9ae3b0bff8..1fce308bce 100644--- a/server/services/pipeline/arcPlanner.test.js+++ b/server/services/pipeline/arcPlanner.test.js@@ -1,3 +1,4 @@+import { readFileSync } from 'fs';import { describe, it, expect, vi, beforeEach } from 'vitest';import { mockNoPeerSync, mockNoPeers } from '../../lib/mockPathsDataRoot.js';@@ -961,6 +962,97 @@ describe('arcPlanner — resolveVerifyIssues', () => {expect(out.applied).toBe(false);expect(out.rejectedExactEdits).toBe(1);expect(out.series.seasons[0].endingHook).toBe(originalHook);+ // Categorical, so the stall diagnosis can tell a patch whose anchors no+ // longer match from a resolver that declined to propose anything.+ expect(out.noChangeReason).toBe('exact-edits-rejected');+ expect(out.mutations).toEqual({ arcFieldsEdited: 0, volumesEdited: 0, characterArcsEdited: 0, episodesEdited: 0 });+ });++ it('counts what a spine-scope resolve wrote, per record kind (#3843)', async () => {+ // An arc-spine resolver may not touch episodes at all, so `episodesEdited`+ // is 0 on every one of its rounds — the gate reported that alone and a+ // round that rewrote the arc and two volumes read as a no-op.+ const s = await setupSeries();+ await seriesSvc.updateSeries(s.id, { arc: { logline: 'old logline', summary: 'old summary' } });+ const v1 = await seasonsSvc.createSeason(s.id, { number: 1, title: 'Vol 1', synopsis: 'v1 old', episodeCountTarget: 3 });+ const v2 = await seasonsSvc.createSeason(s.id, { number: 2, title: 'Vol 2', synopsis: 'v2 old', episodeCountTarget: 3 });++ stageRunnerSpy = vi.fn(async () => ({+ content: {+ arc: { resolves: ['f1'], logline: 'old logline', summary: 'new summary' },+ seasons: [+ { resolves: ['f1'], id: v1.id, synopsis: 'v1 new' },+ { resolves: ['f1'], id: v2.id, synopsis: 'v2 new' },+ ],+ notes: '',+ },+ runId: 'r-spine', providerId: 'p', model: 'm',+ }));++ const out = await planner.resolveVerifyIssues(s.id, {+ spineOnly: true,+ findings: [{ id: 'f1', severity: 'high', problem: 'the vow is never paid off', suggestion: 'pay it off in V2' }],+ });++ expect(out.applied).toBe(true);+ // One arc field moved (`summary`); `logline` came back identical and is not+ // counted as a rewrite.+ expect(out.mutations).toEqual({ arcFieldsEdited: 1, volumesEdited: 2, characterArcsEdited: 0, episodesEdited: 0 });+ expect(out.noChangeReason).toBeNull();+ });++ it('names the reason when a spine resolve answers with episode edits it may not apply (#3843)', async () => {+ const s = await setupSeries();+ await seriesSvc.updateSeries(s.id, { arc: { logline: 'L' } });+ const v1 = await seasonsSvc.createSeason(s.id, { number: 1, title: 'Vol 1', episodeCountTarget: 1 });+ await issuesSvc.createIssue({ seriesId: s.id, seasonId: v1.id, title: 'Pilot' });++ stageRunnerSpy = vi.fn(async () => ({+ content: {+ episodes: [{ resolves: ['f1'], seasonNumber: 1, episodeNumber: 1, synopsis: 'a rewritten synopsis' }],+ notes: '',+ },+ runId: 'r-out-of-scope', providerId: 'p', model: 'm',+ }));++ const out = await planner.resolveVerifyIssues(s.id, {+ spineOnly: true,+ findings: [{ id: 'f1', severity: 'high', problem: 'the pilot contradicts the volume', suggestion: 'fix it' }],+ });++ expect(out.applied).toBe(false);+ // Not "the resolver did nothing" — it answered at an altitude this gate+ // forbids, which is a different defect with a different fix.+ expect(out.noChangeReason).toBe('edits-out-of-scope');+ });++ it('documents every no-change reason in the prompts that are handed one (#3843)', () => {+ // The reasons only earn their keep if the diagnosis can read them. A value+ // the legend never explains reaches the model as an unglossed token, which+ // is the misreading this telemetry exists to end.+ const legends = ['pipeline-observer.md', 'pipeline-self-improve.md'].map((file) => readFileSync(+ new URL(`../../../data.reference/prompts/stages/${file}`, import.meta.url),+ 'utf8',+ ));+ for (const reason of planner.RESOLVE_NO_CHANGE_REASONS) {+ for (const legend of legends) expect(legend).toContain(`\`${reason}\``);+ }+ });++ it('reports a resolver that proposed nothing at all as a content-level refusal (#3843)', async () => {+ const s = await setupSeries();+ await seriesSvc.updateSeries(s.id, { arc: { logline: 'L' } });+ stageRunnerSpy = vi.fn(async () => ({+ content: { notes: 'I cannot resolve this without inventing canon.' },+ runId: 'r-refusal', providerId: 'p', model: 'm',+ }));++ const out = await planner.resolveVerifyIssues(s.id, {+ findings: [{ id: 'f1', severity: 'high', problem: 'the vow is never paid off', suggestion: 'pay it off' }],+ });++ expect(out.applied).toBe(false);+ expect(out.noChangeReason).toBe('no-edits-returned');});it('re-runs verify when no findings are supplied and short-circuits on a clean arc', async () => {diff --git a/server/services/pipeline/arcPlanner/arcCore.js b/server/services/pipeline/arcPlanner/arcCore.jsindex 52cb08ebf9..983f48d904 100644--- a/server/services/pipeline/arcPlanner/arcCore.js+++ b/server/services/pipeline/arcPlanner/arcCore.js@@ -534,6 +534,73 @@ const SEASON_LONG_FIELDS = Object.freeze([['endingHook', 'endingHookEdits', ARC_LIMITS.SEASON_ENDING_HOOK_MAX],]);+// ---------------------------------------------------------------------------+// Resolve-outcome accounting (#3843). `applied` says a pass wrote SOMETHING; it+// never said what, and the gate's telemetry reported only `episodesEdited` — a+// count the arc-SPINE resolver can never move, because that altitude may not+// touch episodes at all. A spine round that rewrote the arc and two volumes and+// took the blocking set from 5 to 2 therefore reported `episodesEdited: 0`,+// indistinguishable from a round that wrote nothing. These supply the missing+// halves: per-record counts of what landed, and a categorical reason when+// nothing did. Numbers and enum values only — it rides into the retained+// diagnosis log, which must never carry manuscript text or resolver prose.+// ---------------------------------------------------------------------------++// The arc surface a resolve pass can rewrite — derived from the two lists the+// isolated-candidate bound already keeps in step with the appliers, so a newly+// patchable field is counted the moment it is accepted rather than after+// someone remembers a third list. `readerMap` / `tickingClock` / `status` are+// absent by construction: the resolver never authors them.+const RESOLVE_ARC_FIELDS = Object.freeze([...ARC_SHORT_FIELDS, ...ARC_LONG_FIELDS.map(([direct]) => direct)]);++const changedFieldCount = (next, prev, fields) => fields+ .filter((field) => !sameStored(next?.[field], prev?.[field])).length;++// Entries in `next` that match no entry in `prev` — i.e. minted or rewritten.+// Deletion is not reachable on either list this counts (volumes ride through as+// a sparse patch, character arcs merge in place), so added/changed is a complete+// account of the pass's writes.+const changedEntryCount = (next, prev) => {+ const before = new Set((prev || []).map((entry) => JSON.stringify(entry)));+ return (next || []).filter((entry) => !before.has(JSON.stringify(entry))).length;+};++const NO_MUTATIONS = Object.freeze({+ arcFieldsEdited: 0, volumesEdited: 0, characterArcsEdited: 0, episodesEdited: 0,+});++/**+ * Why a resolve pass wrote nothing, as ONE of these values. Categorical so the+ * stall diagnosis can separate the cases it kept conflating: the resolver+ * answered but its anchors no longer matched (`exact-edits-rejected`), it+ * answered at an altitude this gate forbids (`edits-out-of-scope`), or it+ * declined to propose anything at all (`no-edits-returned`) — a content-level+ * refusal no amount of extra rounds will fix. Exported because the diagnosis+ * prompts have to explain every value they can be handed; the contract test in+ * `arcPlanner.test.js` fails when a value is missing from that legend.+ */+export const RESOLVE_NO_CHANGE_REASONS = Object.freeze([+ 'no-findings',+ 'isolated-candidate-rejected',+ 'exact-edits-rejected',+ 'edits-matched-existing',+ 'edits-out-of-scope',+ 'edits-named-no-finding',+ 'no-edits-returned',+]);++const noChangeReasonFor = (edits, rejectedExactEdits) => {+ if (rejectedExactEdits > 0) return 'exact-edits-rejected';+ const proposed = (edits.arc ? 1 : 0) + edits.characterArcs.length + edits.seasons.length + edits.episodes.length;+ // Something survived selection and was applied, yet the store did not move:+ // the resolver re-authored text the plan already held.+ if (proposed > 0) return 'edits-matched-existing';+ if (edits.episodesOutOfScope > 0) return 'edits-out-of-scope';+ const dropped = (edits.arcDropped ? 1 : 0) + edits.characterArcsDropped + edits.seasonsDropped + edits.episodesDropped;+ if (dropped > 0) return 'edits-named-no-finding';+ return 'no-edits-returned';+};+// How many stored values a patch would actually change. Echoed fields that// already match the record do not count: the resolve prompt asks for `id` and// `number` to be repeated, so "field present" is not "field changed". Exact-text@@ -698,7 +765,14 @@ export async function resolveVerifyIssues(seriesId, options = {}) {const fresh = await verifyArc(seriesId, { ...options, preloadedWorld: world });findings = fresh.issues || [];if (!findings.length) {- return { series, applied: false, notes: 'No findings to resolve', findings: [] };+ return {+ series,+ applied: false,+ notes: 'No findings to resolve',+ findings: [],+ mutations: NO_MUTATIONS,+ noChangeReason: 'no-findings',+ };}}@@ -777,6 +851,8 @@ export async function resolveVerifyIssues(seriesId, options = {}) {patchMode: exactTextMode ? 'exact-text-v1' : null,rejectedExactEdits: 0,episodesResolved: [],+ mutations: NO_MUTATIONS,+ noChangeReason: 'isolated-candidate-rejected',...runMeta,};}@@ -910,12 +986,28 @@ export async function resolveVerifyIssues(seriesId, options = {}) {console.log(`⚠️ arc-resolve: response made no applicable change after ${rejectedExactEdits} exact text edit(s) were rejected`);}+ // What this pass actually wrote, per record kind — the whole account in one+ // place, so a fifth record kind is added here and nowhere else. `series.*` is+ // the state as it stood BEFORE the commit above, so these describe this call's+ // writes and nothing else, and the two `*Changed` flags gate the counting: a+ // pass that moved nothing needs no per-record comparison to prove it.+ // Episodes ride the same manifest the rollback is driven by, so an edit that+ // was skipped or failed is never counted as written.+ const mutations = {+ arcFieldsEdited: arcOrSeasonsChanged ? changedFieldCount(arc, series.arc, RESOLVE_ARC_FIELDS) : 0,+ volumesEdited: arcOrSeasonsChanged ? changedEntryCount(seasons, series.seasons) : 0,+ characterArcsEdited: characterArcsChanged ? changedEntryCount(characterArcs, updated.characterArcs) : 0,+ episodesEdited: resolvedEpisodeEdits({ episodesResolved }).length,+ };+return {series: resolvedSeries,applied,patchMode: exactTextMode ? 'exact-text-v1' : null,rejectedExactEdits,episodesResolved,+ mutations,+ noChangeReason: applied ? null : noChangeReasonFor(edits, rejectedExactEdits),...runMeta,};}diff --git a/server/services/pipeline/seriesAutopilot.test.js b/server/services/pipeline/seriesAutopilot.test.jsindex ed03419e8f..d9d48ec75e 100644--- a/server/services/pipeline/seriesAutopilot.test.js+++ b/server/services/pipeline/seriesAutopilot.test.js@@ -2852,6 +2852,90 @@ describe('autopilot conductor', () => {expect(series.autopilot?.pauseKind).not.toBe('regression');});+ it('reports every arc-spine resolver attempt with what it actually wrote (#3843)', async () => {+ // The 2026-08-13 verifyArcSpine pause, replayed: 5 blockers → 2 → 2 → 2,+ // stopping on "no net progress over 2 consecutive rounds of auto-resolve".+ // Its retained telemetry was 4 `verify:round` frames and ONE `resolve:round`+ // reporting `episodesEdited: 0` — so a reader could see neither that the+ // first round's arc + volume edits are what took 5 to 2 (a spine resolver+ // may not touch episodes at all, so that zero was expected), nor that the+ // two rounds it paused over had attempted anything whatsoever.+ const blockers = (n) => Array.from({ length: n }, (_, i) => ({+ severity: 'high', problem: `spine gap ${i}`, location: `V${i + 1}`,+ }));+ arcSpies.verifyArc.mockReset();+ arcSpies.verifyArc+ .mockImplementationOnce(async () => ({ issues: blockers(5) }))+ .mockImplementationOnce(async () => ({ issues: blockers(2) }));+ arcSpies.resolveVerifyIssues+ .mockImplementationOnce(async () => ({+ applied: true,+ runId: 'arc-spine-1',+ mutations: { arcFieldsEdited: 1, volumesEdited: 2, characterArcsEdited: 0, episodesEdited: 0 },+ }))+ // The two attempts the pause was counting. Both wrote nothing, for+ // different reasons — which is exactly the distinction the gate could not+ // report before.+ .mockImplementationOnce(async () => ({+ applied: false, runId: 'arc-spine-2', rejectedExactEdits: 3, noChangeReason: 'exact-edits-rejected',+ }))+ .mockImplementationOnce(async () => ({+ applied: false, runId: 'arc-spine-3', noChangeReason: 'no-edits-returned',+ }));+ const { seriesId } = await seedComplete();+ const frames = [];+ const handler = (p) => frames.push(p);+ autopilot.autopilotEvents.on(seriesId, handler);+ await autopilot.startSeriesAutopilot(seriesId, { maxArcVerifyRounds: 6 });+ await waitFor(runFinished(seriesId));+ autopilot.autopilotEvents.off(seriesId, handler);++ // Four rounds, three resolver attempts, and an outcome frame for each one.+ expect(frames.filter((f) => f.type === 'verify:round' && f.scope === 'arcSpine')).toHaveLength(4);+ const attempts = frames.filter((f) => f.type === 'resolve:round' || f.type === 'resolve:no-change');+ expect(attempts).toHaveLength(3);+ // Round 1 wrote the spine. `episodesEdited: 0` stays for existing readers,+ // but it is no longer the only thing the frame says.+ expect(attempts[0]).toMatchObject({+ type: 'resolve:round',+ scope: 'arcSpine',+ round: 1,+ applied: true,+ arcFieldsEdited: 1,+ volumesEdited: 2,+ episodesEdited: 0,+ noChangeReason: null,+ });+ expect(attempts[1]).toMatchObject({+ type: 'resolve:no-change',+ round: 2,+ applied: false,+ arcFieldsEdited: 0,+ volumesEdited: 0,+ episodesEdited: 0,+ rejectedExactEdits: 3,+ noChangeReason: 'exact-edits-rejected',+ });+ expect(attempts[2]).toMatchObject({+ type: 'resolve:no-change',+ round: 3,+ applied: false,+ rejectedExactEdits: 0,+ noChangeReason: 'no-edits-returned',+ });+ // Every frame stays numeric/enum — the diagnosis log must never carry+ // manuscript text or the resolver's own prose.+ for (const frame of attempts) {+ expect(frame).not.toHaveProperty('notes');+ expect(frame).not.toHaveProperty('findings');+ }+ // A round whose resolver wrote nothing re-uses its verification instead of+ // billing another arc + per-volume pass.+ expect(arcSpies.verifyArc).toHaveBeenCalledTimes(2);+ const last = autopilot.__testing.runs.get(seriesId)?.lastPayload;+ expect(last?.pauseKind).toBe('divergence');+ });+it('carries a rejected candidate\'s findings past its corrective retry into the next ordinary resolve', async () => {// The 2026-08-12 verifyArcSpine stall, replayed: 2 blockers → 1, a rewrite// back to 5 (reverted), the corrective retry back to 1, then straight backdiff --git a/server/services/pipeline/seriesAutopilot/childRuns.js b/server/services/pipeline/seriesAutopilot/childRuns.jsindex bbb82241d2..cc83b35040 100644--- a/server/services/pipeline/seriesAutopilot/childRuns.js+++ b/server/services/pipeline/seriesAutopilot/childRuns.js@@ -86,12 +86,25 @@ async function resolveArcFindings(seriesId, record, { findings, avoid, spineOnlyreturn resolved;}-// Episode synopses one resolve pass actually rewrote, for the telemetry frames.-// Read off the same mutation manifest the rollback is driven by, so-// `episodesEdited` and `episodesReverted` cannot describe different sets:-// counting every reported entry included the ones the applier SKIPPED (locked-// stage, no matching episode, failed write) as edits.-const editedCount = (resolved) => resolvedEpisodeEdits(resolved).length;+// A resolver result carrying no counts (a test double, or a peer running an+// older build) reports zeros rather than a frame with holes in it.+const ZERO_MUTATIONS = Object.freeze({+ arcFieldsEdited: 0, volumesEdited: 0, characterArcsEdited: 0, episodesEdited: 0,+});++// What ONE resolver call did, as every telemetry frame reports it (#3843). Each+// attempt gets one — an applied round, a corrective retry, an isolated attempt,+// and a pass that wrote nothing — because the stall diagnosis counts resolver+// ATTEMPTS and used to be handed frames for only some of them. The per-record+// counts come from the resolver, the only layer holding both the pre- and+// post-commit state; `episodesEdited` among them is retained unchanged for+// existing consumers, but it was never a description of an arc-SPINE resolve.+const resolveOutcome = (resolved) => ({+ applied: resolved?.applied !== false,+ ...(resolved?.mutations || ZERO_MUTATIONS),+ rejectedExactEdits: resolved?.rejectedExactEdits || 0,+ noChangeReason: resolved?.noChangeReason || null,+});// A resolver's provider run is only a TECHNICAL success until the next// independent arc verification decides whether its candidate remains in the@@ -289,9 +302,9 @@ async function isolateArcFindings(seriesId, record, { scope, round, spineOnly, bbroadcast(seriesId, {type: 'resolve:isolate', scope, round, attempt: attempts,target: targetLabel ?? '',- before, after: before, kept: false, episodesEdited: 0,+ before, after: before, kept: false,reason: resolved.reason || 'the resolver applied nothing',- rejectedExactEdits: resolved.rejectedExactEdits || 0,+ ...resolveOutcome(resolved),});continue;}@@ -330,7 +343,8 @@ async function isolateArcFindings(seriesId, record, { scope, round, spineOnly, bbroadcast(seriesId, {type: 'resolve:isolate', scope, round, attempt: attempts,target: targetLabel ?? '',- before, after: verified.blocking.length, kept, episodesEdited: editedCount(resolved),+ before, after: verified.blocking.length, kept,+ ...resolveOutcome(resolved),});}return { accepted, attempts, verified: standing };@@ -525,7 +539,7 @@ async function runArcVerifyRounds(seriesId, record, { spineOnly = false, bank })exactTextMode: retried?.patchMode === 'exact-text-v1',};broadcast(seriesId, {- type: 'resolve:round', scope, round, retry: true, episodesEdited: editedCount(retried),+ type: 'resolve:round', scope, round, retry: true, ...resolveOutcome(retried),});continue;}@@ -643,8 +657,7 @@ async function runArcVerifyRounds(seriesId, record, { spineOnly = false, bank }));seededVerify = verified;broadcast(seriesId, {- type: 'resolve:no-change', scope, round,- rejectedExactEdits: resolved.rejectedExactEdits || 0,+ type: 'resolve:no-change', scope, round, ...resolveOutcome(resolved),});continue;}@@ -656,7 +669,7 @@ async function runArcVerifyRounds(seriesId, record, { spineOnly = false, bank })exactTextMode: resolved?.patchMode === 'exact-text-v1',};broadcast(seriesId, {- type: 'resolve:round', scope, round, episodesEdited: editedCount(resolved),+ type: 'resolve:round', scope, round, ...resolveOutcome(resolved),});}return {};@@ -713,6 +726,10 @@ export async function runBeatContinuity(seriesId, record) {if (beforeResolve) return beforeResolve;const resolved = await resolveBeatContinuity(seriesId, { findings: blocking, ...providerOverrideOpts(record) });await recordDomainUsage('cos', { actions: 1 });+ // No per-record counts here, and none missing: this resolver rewrites+ // episode beats and nothing else, so `episodesEdited` IS the whole account+ // of what it wrote — unlike the arc gate, whose resolver spans the arc,+ // volumes, character arcs and episodes (#3843).broadcast(seriesId, {type: 'resolve:round', scope: 'beatContinuity', round,episodesEdited: Array.isArray(resolved?.episodesResolved)diff --git a/server/services/pipeline/seriesAutopilot/observer.test.js b/server/services/pipeline/seriesAutopilot/observer.test.jsindex cde8323c58..d7d19f1465 100644--- a/server/services/pipeline/seriesAutopilot/observer.test.js+++ b/server/services/pipeline/seriesAutopilot/observer.test.js@@ -84,6 +84,18 @@ describe('signal retention for observer-only runs', () => {expect(noteSignal(run, { type: 'child:retry' })).toBe(true);expect(run.signals).toHaveLength(1);});++ it('retains a resolver attempt that wrote nothing (#3843)', () => {+ // The convergence guard counts an attempt that wrote nothing exactly like+ // one that did, so dropping this frame paused runs on "no net progress over+ // 2 rounds of auto-resolve" while retaining no evidence those rounds ran.+ const run = makeRun();+ expect(noteSignal(run, { type: 'resolve:no-change', noChangeReason: 'no-edits-returned' })).toBe(true);+ // The retention set is still a filter, not a pass-through: the happy-path+ // step frames it deliberately excludes stay excluded.+ expect(noteSignal(run, { type: 'step:start' })).toBe(false);+ expect(run.signals).toHaveLength(1);+ });});describe('trigger/retention alignment', () => {diff --git a/server/services/pipeline/seriesAutopilot/state.js b/server/services/pipeline/seriesAutopilot/state.jsindex b252732cc4..a991eb8bbd 100644--- a/server/services/pipeline/seriesAutopilot/state.js+++ b/server/services/pipeline/seriesAutopilot/state.js@@ -52,8 +52,15 @@ export const AUTOPILOT_TERMINAL_TYPES = new Set(['complete', 'paused', 'canceled// terminal frames (`complete` / `paused` / `error`) are excluded too: the// diagnosis runs BEFORE them, and their content reaches it as the `outcome` +// `reason` arguments instead.+// `resolve:no-change` is here for the same reason the loop emits it at all: the+// convergence guard counts a resolver attempt that wrote nothing exactly like+// one that did, so a pause reading "no net progress over 2 rounds of+// auto-resolve" was handed a log with no frame for those rounds — the diagnosis+// could see the attempts had happened only by inference. Bounded by the gate's+// round cap, and it carries counts + an enum, so retaining it costs one small+// frame per attempt.export const SIGNAL_FRAME_TYPES = Object.freeze(new Set([- 'note', 'step:skip', 'verify:round', 'resolve:round', 'resolve:rollback', 'resolve:isolate', 'check:complete',+ 'note', 'step:skip', 'verify:round', 'resolve:round', 'resolve:no-change', 'resolve:rollback', 'resolve:isolate', 'check:complete','foundation:round', 'foundation:fix', 'foundation:rollback', 'canon:repair', 'child:retry', 'child:escalate','revision:cycle', 'revision:converged', 'gap:filed',]));