Repository navigation
fix(#799): fail-fast the -Q quality loop on billing / rate-limit-window failures - #800
Merged
admarble merged 3 commits intoJul 24, 2026
Conversation
…ow failures The outer -Q quality loop in batch-executor only halted on the #739 turn-cap case. A billing / out-of-credits failure (or a window-exhausted rate limit) still spawned /loop and burned the remaining iterations — none of which could succeed — and the doomed retries surfaced as a misleading "QA completed without a parseable verdict" instead of the real cause. Mirror the haltedByCap (#739) machinery with a haltedByBilling flag driven by a shared isBillingOrWindowHalt() predicate (BillingError, or a window-exhausted rate limit via the existing isWindowExhaustedRateLimit). The failed-event now names the real cause + reset time (billingHaltReason), and the run ends resumable (in_progress, no spurious AC_NOT_MET) with failureCategory = billing/rate_limit already wired via deriveFailureCategory. - AC-1/AC-2: halt before /loop on billing and window-exhausted rate limit; transient/metadata-absent rate limit keeps today's behavior. - AC-3: phase-failed + summary state the real cause; metrics category correct. - AC-4: state stays resumable. - AC-5: regression tests for the billing halt, the rate-limit-window variant, and the transient-not-halted fallback.
5 tasks
QA second-look caught a real defect: for a window-exhausted rate limit the
driver already formats the reset time INTO result.error ("Rate limited —
resets at 07-24 14:32", via formatRateLimitMessage). billingHaltReason then
re-appended a second, timezone-inconsistent copy from the structuredError
metadata ("… — resets at 2026-…Z"). The original test only matched /resets at/i
so it passed despite the duplication.
Surface result.error verbatim instead — it is already the driver's canonical
"real cause + reset time" message. Drops the now-unused resetsAtToMs import.
Also strengthen the regression tests:
- rate-limit variant now asserts the exact message and exactly one "resets at"
occurrence (locks the no-double-reset fix).
- billing test now drives a spy StateManager and asserts AC-4 concretely:
final status is "in_progress" (resumable) and never "ready_for_merge".
…ccuracy Spec-phase sibling site: the early spec block mirrored the #739 capped message but not billing. It already early-returns on any failure (no /loop, no cascade), so this is a message/fallback symmetry fix, not a behavior change — route its non-capped failure through billingHaltReason so a billing/window spec failure names the real cause and falls back to "Out of credits" instead of "unknown". Adds a spec-phase billing regression test (only spec runs, failureCategory "billing"). Docs: docs/reference/run-command.md described the rate-limit fail-fast as skipping "all phase retries" — accurate for the inner #761 ladder but not for the outer -Q quality loop, which cascaded before this fix. Note billing explicitly and that the -Q loop now honors the halt (no /loop on a closed window), matching the documented single-line "resets at <local time>" summary.
admarble
deleted the
feature/799-fix-run-q-quality-loop-retries-after-an-out-of
branch
July 24, 2026 14:05
Closed
10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #799. The outer
-Qquality loop inbatch-executor.tsonly failed fast on the #739 turn-cap case. A billing / "Out of credits" failure (or a window-exhausted rate limit) still spawned/loopand burned the remaining iterations — none of which could succeed while credits/window were exhausted — and the doomed retries surfaced as a misleadingQA completed without a parseable verdictinstead of the real cause.Changes
Mirrors the existing
haltedByCap(#739) machinery with ahaltedByBillingflag driven by a sharedisBillingOrWindowHalt()predicate:isBillingOrWindowHalt(result)— true for aBillingErroror a window-exhausted rate limit (reuses the existingisWindowExhaustedRateLimitfromphase-executor.ts). Transient / metadata-absent rate limits return false and keep today's retry/loop behavior.billingHaltReason(result)— surfaces the driver's real cause and appends the reset time when present, so the phase-failed event (and thus the run summary viarun-renderer'sfailureReason) names the actual cause.&& !haltedByBilling; break guard is nowif (haltedByCap || haltedByBilling).failureCategoryisbilling/rate_limit— already wired viaderiveFailureCategory. The run ends resumable (in_progress, no spuriousAC_NOT_MET).AC Coverage
/loop; no further iterations.resetsAt;failureCategory=billing/rate_limit./loop→in_progress, noAC_NOT_MET; re-run resumes the link.Testing
batch-executor.test.ts— 55 passed (4 new tests for fix(run): -Q quality loop retries after an "Out of credits" exec instead of failing fast (billing cascades into "unparseable verdict") #799)phase-executor.test.ts— 138 passed (reused helper)tsc --noEmit,eslint,npm run build— all cleanRisk Assessment
structuredErrorfor billing (only stderr text), the predicate wouldn't fire — but that's the pre-existing feat(driver): surface structured rate-limit/credits errors from SDK message stream (replaces #592 fallback noise) #732/feat: detect rate-limit failures mid-chain and halt cleanly instead of timeout-cascading #761 signal path, unchanged here.executePhaseWithRetryboundary).Closes #799