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

address review (codex): exempt the self-gating reverse-outline refresh from the pre-dispatch budget pause (#1575)

[._.]/ Adam Eivy520521d39702
diff --git a/server/services/pipeline/seriesAutopilot.js b/server/services/pipeline/seriesAutopilot.js
index 2db3d84bbd..b7921a0525 100644
--- a/server/services/pipeline/seriesAutopilot.js
+++ b/server/services/pipeline/seriesAutopilot.js
@@ -1552,7 +1552,13 @@ export async function startSeriesAutopilot(sId, options = {}) {
// complete a text-ready series even with the budget exhausted. The
// editorialHealthGate (#1316) is likewise exempt — it's a pure read +
// score with no LLM cost, so a budget-exhausted run can still produce its
- // readiness verdict (and pause on the findings, not the budget). A gate
+ // readiness verdict (and pause on the findings, not the budget). The
+ // reverseOutline refresh is exempt for the SAME reason as editorialChecks:
+ // runReverseOutlineRefresh self-gates (it only calls budgetPause + bills
+ // when it will actually regenerate), and it no-ops when no enabled check —
+ // narrowed to this run's #1575 subset — consumes the outline. A blanket
+ // pre-dispatch pause here would wrongly stall a deterministic-only subset
+ // (whose refresh is a guaranteed no-op) on an exhausted budget. A gate
// whose resolved rounds is 0 ("skip") is also exempt: runArcVerify /
// runEditorial short-circuit with no LLM spend, so "0 skips the gate" must
// hold even when the budget is exhausted (otherwise the run pauses on
@@ -1560,7 +1566,10 @@ export async function startSeriesAutopilot(sId, options = {}) {
const zeroRoundSkip = (step.kind === 'verifyArc' && runOptions.maxArcVerifyRounds === 0)
|| (step.kind === 'beatContinuity' && runOptions.maxBeatContinuityRounds === 0)
|| (step.kind === 'editorialReview' && runOptions.maxEditorialRounds === 0);
- if (step.kind !== 'editorialChecks' && step.kind !== 'editorialHealthGate' && !zeroRoundSkip) {
+ const selfGatingStep = step.kind === 'editorialChecks'
+ || step.kind === 'editorialHealthGate'
+ || step.kind === 'reverseOutline';
+ if (!selfGatingStep && !zeroRoundSkip) {
const budget = await getDomainBudgetStatus('cos');
if (!budget.withinBudget) {
await persistMarker(sId, { status: 'paused', runId, currentStep: step.kind, lastError: `daily cos ${budget.exceeded} budget reached` });
diff --git a/server/services/pipeline/seriesAutopilot.test.js b/server/services/pipeline/seriesAutopilot.test.js
index b7d0e0ed40..1836311780 100644
--- a/server/services/pipeline/seriesAutopilot.test.js
+++ b/server/services/pipeline/seriesAutopilot.test.js
@@ -951,6 +951,28 @@ describe('autopilot conductor', () => {
expect(generateReverseOutline).not.toHaveBeenCalled();
});
+ it('a budget-exhausted run does not pause at the no-op reverse-outline refresh (#1575 self-gating exemption)', async () => {
+ // A subset run whose checks don't consume the outline makes the refresh a
+ // guaranteed no-op. Budget goes exhausted right after the editorial-review
+ // pass spends its last action, so the NEXT step (reverseOutline) sees no
+ // budget. The pre-dispatch gate must NOT pause there — the refresh self-gates
+ // and would bill nothing — so the run reaches completion (editorialChecks +
+ // healthGate are exempt too) instead of a spurious budget pause.
+ reverseOutlineConsumed = false; // subset skips every outline-consuming check
+ reverseOutlineState = { status: 'complete', stale: true }; // stale, but unused
+ getDomainBudgetStatus.mockImplementation(async () => (
+ arcSpies.analyzeManuscriptCompleteness.mock.calls.length >= 1
+ ? { withinBudget: false, exceeded: 'actions' }
+ : { withinBudget: true, exceeded: null }
+ ));
+ const { seriesId } = await seedComplete();
+ await autopilot.startSeriesAutopilot(seriesId, { editorialCheckIds: ['naming'], includeVisual: false });
+ await waitFor(runFinished(seriesId));
+ const last = autopilot.__testing.runs.get(seriesId)?.lastPayload;
+ expect(last?.type).toBe('complete');
+ expect(generateReverseOutline).not.toHaveBeenCalled();
+ });
+
it('skips the reverse-outline refresh when nothing is drafted yet (#1349)', async () => {
reverseOutlineConsumed = true;
reverseOutlineState = { status: 'no-content' }; // gate 2: no manuscript to segment