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
fix: reject arc severity regressions
[._.]/ Adam Eivy7f6ff267de37
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 96635dcee6..8ec9403950 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -24,6 +24,8 @@- **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.+- **Arc rollback now rejects equal-count severity regressions.** The best-draft guard already reverted any auto-resolve candidate that increased the total number of blocking findings, but an unchanged count was always accepted as a potentially narrower restatement. That allowed a resolver to trade a medium continuity gap for a new high-severity canon violation while still reporting the same total. Equal-count candidates are now ordered by severity before they can replace the checkpoint: more high findings, or more medium findings at the same high count, is a regression and is reverted through the same bounded corrective-pass path. The pause message names the severity escalation explicitly instead of presenting two identical counts as if one were numerically larger.+- **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/server/services/pipeline/seriesAutopilot.test.js b/server/services/pipeline/seriesAutopilot.test.jsindex bafa071db0..6bed4d58c4 100644--- a/server/services/pipeline/seriesAutopilot.test.js+++ b/server/services/pipeline/seriesAutopilot.test.js@@ -1498,6 +1498,42 @@ describe('isResolveRegression (pure resolve-round damage check)', () => {});});+describe('isBlockingSetRegression (arc rollback ordering)', () => {+ const { isBlockingSetRegression } = autopilot;+ const f = (severity, problem) => ({ severity, problem, location: 'V1' });++ it('rejects an equal-count candidate whose severity mix got worse', () => {+ expect(isBlockingSetRegression(+ [f('high', 'recovery chronology'), f('medium', 'stale milestone')],+ [f('high', 'new canon violation'), f('high', 'stale milestone')],+ )).toBe(true);+ });++ it('keeps an equal-count candidate whose severity mix improved or held', () => {+ const before = [f('high', 'canon violation'), f('medium', 'stale milestone')];+ expect(isBlockingSetRegression(before, [+ f('medium', 'narrower handoff'), f('medium', 'stale milestone'),+ ])).toBe(false);+ expect(isBlockingSetRegression(before, before)).toBe(false);+ });++ it('preserves blocker count as the primary ordering signal', () => {+ expect(isBlockingSetRegression(+ [f('high', 'one blocker')],+ [f('medium', 'first blocker'), f('medium', 'second blocker')],+ )).toBe(true);+ expect(isBlockingSetRegression(+ [f('medium', 'first blocker'), f('medium', 'second blocker')],+ [f('high', 'one blocker')],+ )).toBe(false);+ });++ it('tolerates missing inputs', () => {+ expect(isBlockingSetRegression(undefined, undefined)).toBe(false);+ expect(isBlockingSetRegression(undefined, [f('high', 'new blocker')])).toBe(true);+ });+});+describe('autopilot conductor', () => {it('rejects start when the cos domain is off (no run created)', async () => {cosMode = 'off';@@ -2176,6 +2212,34 @@ describe('autopilot conductor', () => {expect(last?.residualFindings).toEqual(holes(3, 'initial'));});+ it('reverts an equal-count arc candidate whose findings escalated in severity', async () => {+ const before = [+ { severity: 'high', problem: 'recovery clock is contradictory', location: 'V1 issues 8-9' },+ { severity: 'medium', problem: 'character milestone uses stale timing', location: 'V1 character arc' },+ ];+ const after = [+ { severity: 'high', problem: 'human machinery can open the living gate without consent', location: 'V1 issue 11' },+ { severity: 'high', problem: 'character milestone uses stale timing', location: 'V1 character arc' },+ ];+ arcSpies.verifyArc.mockReset();+ arcSpies.verifyArc+ .mockImplementationOnce(async () => ({ issues: before }))+ .mockImplementationOnce(async () => ({ issues: after }));+ const { seriesId } = await seedComplete();+ await autopilot.startSeriesAutopilot(seriesId, {+ maxArcVerifyRounds: 6,+ maxArcResolveRetries: 0,+ });+ await waitFor(runFinished(seriesId));++ expect(arcSpies.restoreArcState).toHaveBeenCalledTimes(1);+ const last = autopilot.__testing.runs.get(seriesId)?.lastPayload;+ expect(last?.pauseKind).toBe('regression');+ expect(last?.reason).toMatch(/same count but a worse severity mix/);+ expect(last?.residualFindings).toEqual(before);+ expect(last?.discardedFindings).toEqual(after);+ });+it('reverts the same 1 → 3 → 5 divergence when each verify call re-words the finding', async () => {// Same incident as the test above, but replayed the way the verifier// actually behaves: round 2 restates the standing defect in fresh prose at adiff --git a/server/services/pipeline/seriesAutopilot/childRuns.js b/server/services/pipeline/seriesAutopilot/childRuns.jsindex 48cd16d3ed..e3c0cbcba7 100644--- a/server/services/pipeline/seriesAutopilot/childRuns.js+++ b/server/services/pipeline/seriesAutopilot/childRuns.js@@ -25,7 +25,7 @@ import {import {CHILD_POLL_MS, DIVERGENCE_PATIENCE, trackConvergence, convergencePauseReason,divergencePauseReason, foundationPauseReason, foundationDivergenceReason,- regressionPauseReason, sameFinding,+ regressionPauseReason, sameFinding, isBlockingSetRegression,} from './convergence.js';import { broadcast, budgetPause, providerOverrideOpts, providerIdOpts, roleLlm, seasonPreserveOpts } from './session.js';import { requiredScriptStages, textReady } from './stepResolver.js';@@ -154,9 +154,11 @@ export async function runArcVerify(seriesId, record, { spineOnly = false } = {})// finding it was handed and exposed different latent defects. Restore the// best verified state, not merely the immediately previous state; otherwise// a 4 → 2 → 4 → 5 run pauses on 4 and discards the demonstrated 2-blocker- // draft. Checked before maxRounds/divergence so no worse baseline survives.+ // draft. At an equal count, a worse severity mix is also a regression: two+ // mediums becoming one medium plus one high is not a safe tie. Checked+ // before maxRounds/divergence so no worse baseline survives.// Reverting is unconditional; PAUSING is not — see the corrective pass below.- if (lastResolve && blocking.length > lastResolve.blocking.length) {+ if (lastResolve && isBlockingSetRegression(lastResolve.blocking, blocking)) {const rollbackTarget = bestVerified || lastResolve;const rollback = await restoreArcState(seriesId, rollbackTarget.snapshot);const discarded = discardedSet(blocking);@@ -213,16 +215,17 @@ export async function runArcVerify(seriesId, record, { spineOnly = false } = {})lastResolve.blocking.length,blocking.length,rollbackTarget.blocking.length,+ blocking.length === lastResolve.blocking.length,),residual: rollbackTarget.blocking,discarded,};}- // Equal-count drafts may still represent real causal progress: a resolver- // can close broad structural findings and expose the same number of narrower- // handoff problems. Treat the latest verified tie as the checkpoint so a- // later stall never rewinds those repairs. Count growth is still rejected- // above, so this cannot promote a demonstrably worse state.+ // Equal-count drafts may still represent real causal progress when their+ // severity mix is not worse: a resolver can close broad structural findings+ // and expose the same number of narrower handoff problems. Treat that latest+ // verified tie as the checkpoint so a later stall never rewinds those+ // repairs. Count growth and severity escalation are rejected above.const isNewBest = !bestVerified || blocking.length <= bestVerified.blocking.length;// Shared exit for the two bounded stops below: rewind to the checkpoint when// the round they landed on is worse than it, reporting the discarded set thediff --git a/server/services/pipeline/seriesAutopilot/convergence.js b/server/services/pipeline/seriesAutopilot/convergence.jsindex d88e74c3cb..f6743567ef 100644--- a/server/services/pipeline/seriesAutopilot/convergence.js+++ b/server/services/pipeline/seriesAutopilot/convergence.js@@ -205,14 +205,35 @@ export function isResolveRegression(before, after) {return targeted.some((t) => current.some((c) => sameFinding(t, c)));}+// The arc rollback guard's operational ordering. Total blockers remain the+// primary signal: accepting a larger set is what caused the original runaway+// repair loop. When the totals tie, severity is the tiebreaker so a resolver+// cannot trade a medium finding for a high one and call the unchanged count+// safe. Unknown severities do not need a bucket here — with equal totals, any+// movement into high/medium/low is already reflected by the known buckets.+export function isBlockingSetRegression(before, after) {+ const prior = Array.isArray(before) ? before : [];+ const current = Array.isArray(after) ? after : [];+ if (current.length !== prior.length) return current.length > prior.length;+ const count = (findings, severity) => findings.filter((finding) => finding?.severity === severity).length;+ for (const severity of ['high', 'medium', 'low']) {+ const delta = count(current, severity) - count(prior, severity);+ if (delta !== 0) return delta > 0;+ }+ return false;+}+// Pause reason for a gate whose auto-resolve round was reverted — distinct from// both "ran out of rounds" and "stopped converging": the state the user is being// handed is the one from BEFORE the round, and saying so is the difference// between a trustworthy pause and an unexplained rewind.-export function regressionPauseReason(gate, beforeCount, afterCount, bestCount = beforeCount) {+export function regressionPauseReason(gate, beforeCount, afterCount, bestCount = beforeCount, severityEscalated = false) {const { label, fix } = PAUSE_GATES[gate];+ const outcome = severityEscalated+ ? `came back with the same count but a worse severity mix (${afterCount} total)`+ : `came back with ${afterCount}`;return `${label} auto-resolve made the draft worse — the round it ran on ${beforeCount} blocking finding(s) `- + `came back with ${afterCount}, so its edits were reverted regardless of how the verifier reworded the findings. `+ + `${outcome}, so its edits were reverted regardless of how the verifier reworded the findings. `+ `Paused for review with the best verified ${bestCount}-finding state from this gate. ${fix}, then resume.`;}