fix(auto): dispatch retry after verification gate failure (#998)

When the verification gate fails with retries remaining, handleAgentEnd
sets pendingVerificationRetry and deletes the completion key, but then
returns early without calling dispatchNextUnit. This leaves auto-mode
active but permanently stalled — no new unit is ever dispatched because
the dispatch chain is broken.

Fix: call dispatchNextUnit immediately after setting up the retry state,
with a fallback to the dispatch gap watchdog if dispatch throws.
This commit is contained in:
Jeremy McSpadden 2026-03-17 18:20:29 -05:00 committed by GitHub
parent f85c41c693
commit 642323a489

View file

@ -1526,6 +1526,15 @@ export async function handleAgentEnd(
// Remove completion key so dispatchNextUnit re-dispatches this unit
s.completedKeySet.delete(completionKey);
removePersistedKey(s.basePath, completionKey);
// Dispatch retry immediately — without this, handleAgentEnd returns
// without calling dispatchNextUnit, leaving auto-mode stalled (#978).
try {
await dispatchNextUnit(ctx, pi);
} catch (retryDispatchErr) {
const msg = retryDispatchErr instanceof Error ? retryDispatchErr.message : String(retryDispatchErr);
ctx.ui.notify(`Verification retry dispatch error: ${msg}`, "error");
startDispatchGapWatchdog(ctx, pi);
}
return; // ← Critical: exit before DB dual-write and post-unit hooks
} else {
// Gate failed, retries exhausted (or auto-fix disabled) — pause for human review