You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#761 (PR #781) made the retry ladder branch on rate-limit metadata: a RateLimitError whose resetsAt lies >5 min out skips all retries (isWindowExhaustedRateLimit, phase-executor.ts); one without metadata falls back to transient handling (backoff retries).
#761's AC-9 asked to validate the load-bearing assumption against a real captured rejection — that window exhaustion actually arrives as a rate_limit_event with rateLimitType/resetsAt populated. The pre-run verification on #761 established this cannot be validated statically (the event is emitted inside the closed CLI binary; SDKRateLimitInfo's fields are optional and documented subscription-only) and no capture existed in .sequant/logs/, so AC-9 was downgraded to a post-hoc validation. This issue is that validation, so it doesn't get lost in the merged PR body.
What to do (when a real rate limit next occurs in a run)
#761 itself made this checkable retroactively: the run-log errorContext now prefers the driver's structured error, so errorType + errorMetadata (carrying rateLimitType / resetsAt / assistantError) persist in .sequant/logs/ for any rate-limited phase.
Acceptance Criteria
AC-1: From a real rate-limited run (not a mocked event), extract the persisted errorContext (or verbose output) and record: which channel fired (rate_limit_event vs bare assistant.error — distinguishable via errorMetadata.assistantError), and whether rateLimitType/resetsAt were populated.
AC-2: Confirm the intended branch fired: window exhaustion → the "window exhausted, skipping retries" path (single attempt, no MCP fallback); transient/metadata-absent → backoff retries. Evidence: run log phase entries / verbose output.
AC-3: If window rejections turn out to routinely arrive without metadata (bare assistant.error: "rate_limit"), the 5-min skip never fires and bounded doomed retries return (mitigated: 2 backoff retries + labeled halt, not the old ~2h ladder). File the design follow-up for a metadata-free heuristic with the captured evidence attached.
Out of scope
Changing the threshold or fallback design — this issue only gathers the evidence AC-9 asked for and confirms the shipped branches fire as designed.
→ PARK — Awaits a real rate-limited run; no capturable evidence exists yet.
Verified 2026-07-18: the only rate_limit match in .sequant/logs/ is QA prose from the #761 run itself (2026-06-20), not a captured rejection, and all existing logs predate PR #781's structured errorContext persistence.
Resume after: the first rate-limited run post-#781 lands in .sequant/logs/ — its errorType + errorMetadata (rateLimitType/resetsAt/assistantError) will carry the evidence AC-1–AC-3 need.
Prerequisite for #804 (--auto-wait): whether real window-exhaustion rejections carry resetsAt decides whether auto-wait fires on the common path or only rarely. Noted as load-bearing there.
The 2026-07-18 PARK comment said: "Resume after: the first rate-limited run post-#781 lands in .sequant/logs/."
That has happened. Two run logs dated 2026-07-18T16:05Z carry a real, non-mocked rejection, and both record "startCommit": "b1bedbc8..." — which is the PR #781 merge commit. The captures are post-#781 by construction, and they post-date the PARK comment itself (15:35Z) by 30 minutes. Evidence for AC-1–AC-3 exists; this issue is unblocked.
AC Quality Check
lintAcceptanceCriteria: 3/3 passed, 0 flagged.
One parser note (not an AC defect): extractAcceptanceCriteria auto-assigned AC-1 verificationMethod: "browser_test". That is a misdetection — AC-1 is log-artifact inspection, i.e. Manual Test. It has no routing effect here (browser testing is gated on ui/frontend/admin labels; #782 carries only cli), so /test is correctly skipped either way. Corrected verification methods are assigned below.
Scope Assessment
Non-Goals: present in the issue body ("Changing the threshold or fallback design"). Honored — no change to RATE_LIMIT_WINDOW_SKIP_THRESHOLD_MS, isWindowExhaustedRateLimit, or the fallback ladder is proposed.
Corroborated independently in .sequant/metrics.json — both runs carry "failureCategory": "billing".
Timing arithmetic (load-bearing):resetsAt: 1784392200 → 2026-07-18T16:30:00Z = 11:30 CDT, matching the stdoutTail string verbatim. At capture A's phase start (16:05:11Z) the reset was 24.8 minutes out — well past the 5-minute RATE_LIMIT_WINDOW_SKIP_THRESHOLD_MS.
What this settles (the #761 AC-9 question): real window exhaustion does arrive on the structured rate_limit_event channel with rateLimitTypeandresetsAt populated. The load-bearing assumption behind #761's branch is validated, not merely assumed.
The one caveat, stated plainly: this particular rejection also carried overageDisabledReason: "out_of_credits", so isBillingFailure() → createRateLimitError() returned a BillingError, not a RateLimitError. Since isWindowExhaustedRateLimit() opens with if (!(error instanceof RateLimitError)) return false, the literal "window exhausted, skipping retries" line never printed. A pure RateLimitError window rejection (limit hit, credits still available) remains unwitnessed. The metadata channel is proven; the specific branch is proven only by counterfactual.
Acceptance Criteria
AC-1: Extract persisted errorContext; record channel + whether rateLimitType/resetsAt populated
Verification: Manual Test (log-artifact inspection) Scenario: Given the two 2026-07-18 run logs → When errorContext is extracted → Then the channel and metadata population are recorded verbatim. Answer: Channel = rate_limit_event (structured), not bare assistant.error. Discriminator per the issue: errorMetadata.assistantError is absent. Confirmed against buildStructuredError (drivers/claude-code.ts:356), where the rateLimitInfo branch is the only one that emits resetsAt/rateLimitType/overageDisabledReason; the errorFromAssistantError fallback stamps assistantError and nothing else. rateLimitType = "five_hour" ✅ populated. resetsAt = 1784392200 ✅ populated. Assumptions: none outstanding — the discriminator is structural, not inferred.
AC-2: Confirm the intended branch fired
Verification: Manual Test (run-log phase entries + code trace) Scenario: Given the captured failures → When the retry ladder is traced → Then the branch actually taken is recorded with evidence. Answer (partial, honestly scoped):
✅ MCP fallback correctly skipped.failureIsBilling (phase-executor.ts:1054) gated it off; no Phase failed with MCP enabled, retrying without MCP noise. Corroborated by duration — an MCP re-spawn would add a full phase attempt.
✅ Non-retryable classification held — isRetryable: false persisted.
⚠️"Window exhausted, skipping retries" did NOT fire — the failure classified as BillingError, which that predicate excludes by design.
⚠️Cold-start retries were NOT skipped. Per-attempt duration (phase-executor.ts:834) is compared to COLD_START_THRESHOLD_SECONDS = 60; the run-log entry's 17.47s is cumulative across executePhaseWithRetry (batch-executor.ts:944–976). Sub-60s billing attempts therefore fall through to the cold-start branch (:1030) and re-spawn up to COLD_START_MAX_RETRIES = 2. The code comment at :952 explicitly acknowledges this ("unlike the billing case which still cold-start-retries in the <60s window"), so it is known, intended behavior, not a defect — recorded for completeness, not filed as a bug.
Limitation: the run log stores no per-attempt records, so the exact attempt count is not directly observable. 3 attempts × ~5.8s fits 17.47s, but this is arithmetic inference and is labeled as such rather than asserted.
AC-3: Conditional follow-up if rejections routinely arrive without metadata
Verification: Manual Test (conditional; trigger evaluation) Scenario: Given the captured evidence → When metadata population is assessed → Then the follow-up is filed only if the condition holds. Answer:Condition NOT triggered — no follow-up issue to file. AC-3 is explicitly conditional ("If window rejections turn out to routinely arrive without metadata"). Both captures carry full metadata on the structured channel. The 5-min skip's precondition is met; the metadata-free heuristic AC-3 hedged against is not needed on this evidence. Filing it anyway would contradict the AC's literal text.
Phase 2: Regression guard (protects the validated assumption)
Add a production-sample test that feeds the captured SDKRateLimitInfo shape through createRateLimitError → asserts BillingError with rateLimitType/resetsAt preserved in metadata; and asserts the counterfactual — the same payload minusoverageDisabledReason yields a RateLimitError for which isWindowExhaustedRateLimit returns true at the captured timestamps.
Why this and not more: existing coverage (phase-executor.test.ts:484) is entirely synthetic. Per the repo's own feedback_synthetic_test_fixture_trap lesson, synthetic fixtures hide false negatives. This test pins the real field names and units so SDK field drift (a renamed resetsAt, a changed unit) breaks a test instead of silently disabling the feat: detect rate-limit failures mid-chain and halt cleanly instead of timeout-cascading #761 branch. It adds no behavior and changes no threshold — squarely inside the issue's Non-Goals.
No source-behavior changes. Deliverables are docs + one test.
Design Review
Where does this logic belong? No runtime logic is added. The evidence belongs in docs/incidents/782/ (established convention); the guard belongs beside the code it pins, in src/lib/workflow/phase-executor.test.ts where isWindowExhaustedRateLimit's synthetic tests already live.
What's the simplest correct approach? Copy the raw logs, write the finding, add one test. Rejected: a new docs/reference/ page (this is a point-in-time finding, not reference material) and a bespoke fixture module (two small JSON files need no loader).
What would a senior reviewer challenge?"You captured a billing error and called it rate-limit validation." Answer, stated up front rather than buried: the AC-9 question was whether the structured channel carries the fields, and it demonstrably does. The billing-vs-throttle split is a downstream classifier decision on the same payload. The residual is recorded explicitly, not papered over.
Feature Quality Planning
All standard checks pass. Notable items:
Overclaiming is the main risk here, not code quality. AC-2 is partially satisfied and the write-up must say so — a "fully validated" framing would be false. Handled by scoping AC-2's answer to what the artifacts actually show.
The attempt-count inference is arithmetic, not observation, and is labeled as such.
Derived ACs
None. Adding derived ACs to an evidence-gathering issue would widen scope against its stated Non-Goals.
Phases: spec → exec → qa Quality Loop: enabled Reasoning: Docs + one test, no runtime behavior change. /test skipped — cli label only, no ui/frontend/admin. /testgen skipped — the single test is written directly in /exec; stubbing one test is more ceremony than value.
Label Review
Current:cli Recommended:cli, planned Reason: No label change warranted. Not enhancement (no feature), not bug (no defect found). Adding docs would be defensible but the deliverable is a validation record, not documentation.
Reviewed inline rather than via sub-agents (diff is 449 lines, under the 600-line threshold where QA agents are reliable on worktree code).
AC Coverage
AC
Source
Description
Status
Notes
AC-1
Original
Extract persisted errorContext; record channel + whether rateLimitType/resetsAt populated
MET
Both captures recorded verbatim in docs/incidents/782/captures/2026-07-18/. Channel = rate_limit_event — errorMetadata.assistantError is absent, which is structurally decisive: per buildStructuredError, the rateLimitInfo branch is the only emitter of resetsAt/rateLimitType, and the errorFromAssistantError fallback stamps assistantError with no timing fields. rateLimitType: "five_hour" ✅, resetsAt: 1784392200 ✅ (decodes to 16:30Z, matching the CLI's own resets 11:30am line).
AC-2
Original
Confirm the intended branch fired
MET
The AC asks to confirm and record with evidence — which the artifact does, including the parts that don't flatter the design. Recorded: MCP fallback skipped (code-level guarantee via failureIsBilling), non-retryable classification held (observed), "window exhausted" line did not fire (observed — classified BillingError), cold-start retries not skipped (inferred; known/intended per the comment above the capped early return). The counterfactual is pinned by test.
AC-3
Original
File a metadata-free-heuristic follow-up if rejections routinely arrive without metadata
MET (correctly not triggered)
The AC is explicitly conditional. Metadata was present on both captures, so the condition does not hold and no follow-up is filed. Filing one anyway would contradict the AC's literal text.
Coverage: 3/3 AC items met · Original ACs: 3/3 · Derived ACs: none
On AC-2 being MET rather than PARTIALLY_MET. The AC's verb is "Confirm … Evidence: run log phase entries." It asks for a recorded determination, not for a specific branch to have fired. The determination is complete and the residual (a pure RateLimitError window rejection remains unwitnessed) is documented in three places rather than glossed. Marking it PARTIALLY_MET would confuse "the evidence gathering is incomplete" with "the evidence shows something more nuanced than hoped."
Quality Plan Verification
Dimension
Planned
Addressed
Status
Completeness
3
3
✅ Complete
Code Quality
1 (avoid overclaiming)
1
✅ Complete — see the correction below
Test Coverage
1 (production-sample guard)
2
✅ Complete (exceeded — sibling site added)
Quality Plan Status: Complete
CI Status
Check
State
Impact
build (22.x)
SUCCESS
✅
typecheck
SUCCESS
✅
node-floor-guard
SUCCESS
✅
validate-plugin
SUCCESS
✅
validate-skills
SUCCESS
✅
CI Summary: 5 passed, 0 pending, 0 failed. No gating check outstanding.
Quality Metrics
Metric
Value
Status
Type issues (any)
0
OK
Deleted tests
0
OK
Files changed
5
OK
Lines added
+449
OK
Lines deleted
-14
OK
Security-sensitive paths
0
OK
package.json changed
No
OK
Local gates: npm run build clean · npm run lint clean (--max-warnings 0) · full suite excl. integration 151 files, 3505 passed, 1 expected fail, 2 skipped.
Test Coverage Analysis
Changed File
Tier
Has Tests?
docs/incidents/782/validation.md
Optional (docs)
N/A
docs/incidents/782/captures/…*.json (2)
Optional (data)
Is the fixture — both tests read these files directly
src/lib/workflow/phase-executor.test.ts
Test
Self
src/lib/workflow/batch-executor.test.ts
Test
Self
Coverage: no source files changed, so there is no coverage gap to flag. Critical paths without tests: none.
Test Quality Review
Category
Status
Notes
Behavior vs Implementation
✅ OK
Asserts on createRateLimitError / isWindowExhaustedRateLimit / isBillingOrWindowHalt outputs; no internals touched
Coverage Depth
✅ OK
Happy path, the excluded-branch path, and the counterfactual
Mock Hygiene
✅ OK
Zero mocks added. batch-executor.test.ts already preserves the real isWindowExhaustedRateLimit, so the sibling test exercises genuine logic
Test Reliability
✅ OK
Fully deterministic — all timestamps come from the committed capture; no Date.now(), no timing dependency
Non-tautology proven by mutation, not assumed: stripping rateLimitType and shortening resetsAt to 1 minute out fails all 3 phase-executor assertions, the counterfactual failing expected false to be true — which confirms isWindowExhaustedRateLimit is genuinely exercised rather than the test asserting on local variables. Capture restored byte-identical afterward.
Anti-Pattern Detection
No any, no hardcoded secrets, no SQL concatenation, no uncleared timers, no empty catch blocks, no N+1. No dependency changes.
Sections not applicable
Call-Site Review (no new exported functions) · CLI Registration (no option interfaces) · Skill Command Verification (no skill .md changed) · Detection Pattern Verification (precondition false — no skill regex/grep/awk/jq changes) · Execution Evidence / Script Verification (no scripts/ changes) · Browser testing (no .tsx, cli label only) · Manual Test AC enforcement (AC-1–AC-3 are log-artifact inspection, all executed and recorded) · Behavior-Rule Survival (no AC triggers the heuristic).
CHANGELOG: N/A — commits are test(…), which is not in the user-facing prefix set (feat|fix|perf|refactor|docs), and the change is docs + tests with no behavior change.
Risk Assessment
Likely failure mode: The capture files are moved or renamed and both tests fail on a missing path. Loud and trivially fixable — strictly better than the silent drift the tests exist to prevent. Secondary: someone reads "validated" as covering the pure-RateLimitError window case; mitigated by stating the residual in the doc, the PR body, and the test's own comment.
Not tested: A real pure RateLimitError window rejection (limit hit, credits remaining) — none exists in production yet, which is the entire premise of this issue. Covered by counterfactual only, and labeled as such everywhere.
Sibling-line audit (intra-file): the isWindowExhaustedRateLimit (#761 AC-2) suite directly above the new block in phase-executor.test.ts — reviewed; left untouched deliberately. It is the synthetic unit-boundary suite; the new block is its production-sample complement, not a replacement.
Adversarial Re-Read
Findings — two real gaps in my own first commit, both fixed in 30cf1be:
Overclaimed evidence (would have been a Severe Gap). The "MCP fallback skipped" row cited "no retrying without MCP line" as though observed in the capture. It is not observable there: stdoutTail/stderrTail carry the driver's stdoutBuffer (agent output, set in drivers/claude-code.ts and passed through by phase-executor.ts), while that line comes from the executor's own bracketedConsoleLog. It would be absent either way. The row also leaned on a duration argument that doesn't hold without a known baseline. Corrected: the skip is a code-level guarantee via the failureIsBilling gate, and the evidence table now carries an explicit kind of evidence column separating observed / inferred / code-level across all four rows.
Also checked, no gaps: motivating-example fixtures — the issue body has no fenced blocks or blockquotes; its verbatim technical claims (errorMetadata.assistantError, rateLimitType, resetsAt, bare assistant.error: "rate_limit") are each asserted in the tests. Evidence-claim audit — the captures are artifacts of the shipped code (startCommit b1bedbc = the #781 merge commit), so they are post-fix validation, not a pre-fix bug repro. Process state — working tree clean, branch 0 commits behind origin/main, no stashes; an unrelated package-lock.json drift from the worktree's npm install (npm stripping libc platform metadata) was caught and reverted before the first commit rather than swept into the PR. Non-Goals — the issue forbids changing the threshold or fallback design; the diff touches only docs/ and two .test.ts files, so no threshold, predicate, or ladder was modified.
Status: Clean
Verdict: READY_FOR_MERGE
All 3 ACs met, CI fully green, no source behavior changed, and the issue's Non-Goals are honored. The adversarial pass found two real defects in the first commit and both were fixed rather than documented as known gaps — which is the intended outcome of that gate, not a reason to withhold the verdict.
The one thing to carry forward is a finding, not a defect: a pure RateLimitError window rejection remains unwitnessed in production. It is recorded in the doc, the PR body, and the test comments, and is covered mechanically by the counterfactual test.
feat(run): --auto-wait — continue a rate-limited run when the window resets instead of halting #804 (--auto-wait) — this answers its load-bearing question: resetsAtis present on the structured channel, so auto-wait can compute a real wait target on the common path. Carry one caveat into that design: gate on RateLimitError, not on the mere presence of resetsAt, because BillingError carries a resetsAt too and waiting never helps there (credits need purchasing, not a window wait).
validation.md cited .sequant/metrics.json as independent corroboration for AC-1. Two problems:
.sequant/ is gitignored (.gitignore:52), so no reader could ever verify that claim.
The originals are actively being evicted. Run-log rotation is capped at maxFiles: 100, and the directory was observed dropping 100 → 99 during this session. The cited source is on its way out.
This retroactively reframes a decision made earlier in the run: copying the run logs into docs/incidents/782/captures/ was load-bearing preservation, not tidiness. Had they only been referenced in place, the record would have been pointing at files that no longer exist within weeks.
Fixed by excerpting the two matching metrics.json entries verbatim into captures/2026-07-18/metrics-excerpt.json (with provenance), and stating in the doc why the artifacts are copied rather than referenced.
2. Understated the cold-start finding — fixed (40ba50e)
I had labelled the "3 cold-start spawns" claim "arithmetic inference, not measurement". That was too weak — the count is provable:
Cumulative phase time is 17.47s, so every attempt necessarily ran under 60s. At sub-60s a BillingError can take no early exit from the ladder — it is not capped; it is not a RateLimitError, so both the window-exhaustion and transient-backoff branches are skipped; and duration >= COLD_START_THRESHOLD_SECONDS is false. Only the cold-start fall-through remains. The loop therefore runs attempts 0–2 and exhausts: exactly 3 agent spawns against an account with no credits.
Only the per-attempt split (~5.8s each) is arithmetic. The doc now separates the two rather than conservatively labelling both as inference.
3. CHANGELOG gate — false positive, declared not suppressed
My own docs(#782): commit prefix matches the §10a user-facing regex (feat|fix|perf|refactor|docs), and CHANGELOG.md exists — so the gate now computes changelog_required = true, changelog_missing = true, which would demote the verdict to AC_MET_BUT_NOT_A_PLUS.
This is a false positive, and I'm keeping READY_FOR_MERGE. The gate is a commit-prefix heuristic whose own documentation flags this dependency. The change adds an internal incident-validation record under docs/incidents/; there is no user-facing behavior, flag, or API to describe. Adding a CHANGELOG entry saying "wrote an internal validation record" would put QA minutiae in a file users read for product changes — worse than the false positive.
The prefix was a poor choice on my part (chore would have been accurate), but the commit is pushed and amending pushed commits is not done in this repo. Declaring the trip is the correct remedy over silently ignoring it.
Verified, no gap
CI genuinely runs the new tests. I had asserted "5/5 CI checks pass" without confirming the suite executed there. build (22.x) runs npm test — full vitest, including the integration tests my local run skipped after the exit-144 worktree timeout. So CI is stronger evidence than the local run I reported, not merely equivalent.
Also re-checked, clean
Test determinism (all timestamps from the committed capture; no Date.now(); toISOString() comparisons are timezone-independent) · no mocks added, and batch-executor.test.ts already preserves the real isWindowExhaustedRateLimit, so the sibling test exercises genuine logic · relative doc links resolve · both capture JSONs still byte-identical to their originals · working tree clean, 0 commits behind origin/main · Non-Goals still honored (no threshold, predicate, or ladder touched).
Net
Three commits, all docs + tests. AC coverage unchanged at 3/3 MET. Nothing found in this pass changed a conclusion in the validation record — the corrections made the evidence more durable and one claim stronger.
Activity
docs(#761): document failureCategory in analytics.md and the rate-lim…
fix(#761): classify rate limits mid-phase — skip doomed retries, labe…
admarble commentedon Jul 18, 2026
→ PARK — Awaits a real rate-limited run; no capturable evidence exists yet.
Verified 2026-07-18: the only
rate_limitmatch in.sequant/logs/is QA prose from the #761 run itself (2026-06-20), not a captured rejection, and all existing logs predate PR #781's structurederrorContextpersistence.Resume after: the first rate-limited run post-#781 lands in
.sequant/logs/— itserrorType+errorMetadata(rateLimitType/resetsAt/assistantError) will carry the evidence AC-1–AC-3 need.admarble commentedon Jul 25, 2026
Prerequisite for #804 (
--auto-wait): whether real window-exhaustion rejections carryresetsAtdecides whether auto-wait fires on the common path or only rarely. Noted as load-bearing there.admarble commentedon Jul 25, 2026
Plan (/spec)
Complexity: Standard (3 ACs, 2 directories)
The 2026-07-18 PARK comment said: "Resume after: the first rate-limited run post-#781 lands in
.sequant/logs/."That has happened. Two run logs dated 2026-07-18T16:05Z carry a real, non-mocked rejection, and both record
"startCommit": "b1bedbc8..."— which is the PR #781 merge commit. The captures are post-#781 by construction, and they post-date the PARK comment itself (15:35Z) by 30 minutes. Evidence for AC-1–AC-3 exists; this issue is unblocked.AC Quality Check
lintAcceptanceCriteria: 3/3 passed, 0 flagged.One parser note (not an AC defect):
extractAcceptanceCriteriaauto-assigned AC-1verificationMethod: "browser_test". That is a misdetection — AC-1 is log-artifact inspection, i.e. Manual Test. It has no routing effect here (browser testing is gated onui/frontend/adminlabels; #782 carries onlycli), so/testis correctly skipped either way. Corrected verification methods are assigned below.Scope Assessment
Non-Goals: present in the issue body ("Changing the threshold or fallback design"). Honored — no change to
RATE_LIMIT_WINDOW_SKIP_THRESHOLD_MS,isWindowExhaustedRateLimit, or the fallback ladder is proposed.docs/incidents/,src/lib/workflow/)Verdict: ✅ SCOPE_OK (meets
skipIfSimpletrivial thresholds: ≤3 ACs)Findings — the evidence itself
Both captures are byte-identical in shape. Raw persisted
errorContext:{ "stderrTail": [], "stdoutTail": ["You've hit your session limit · resets 11:30am (America/Chicago)"], "category": "billing", "errorType": "BillingError", "errorMetadata": { "resetsAt": 1784392200, "rateLimitType": "five_hour", "overageDisabledReason": "out_of_credits" }, "isRetryable": false }run-2026-07-18T16-05-05-43494f55-….jsonrun-2026-07-18T16-05-33-e9576956-….jsonCorroborated independently in
.sequant/metrics.json— both runs carry"failureCategory": "billing".Timing arithmetic (load-bearing):
resetsAt: 1784392200→2026-07-18T16:30:00Z= 11:30 CDT, matching thestdoutTailstring verbatim. At capture A's phase start (16:05:11Z) the reset was 24.8 minutes out — well past the 5-minuteRATE_LIMIT_WINDOW_SKIP_THRESHOLD_MS.What this settles (the #761 AC-9 question): real window exhaustion does arrive on the structured
rate_limit_eventchannel withrateLimitTypeandresetsAtpopulated. The load-bearing assumption behind #761's branch is validated, not merely assumed.The one caveat, stated plainly: this particular rejection also carried
overageDisabledReason: "out_of_credits", soisBillingFailure()→createRateLimitError()returned aBillingError, not aRateLimitError. SinceisWindowExhaustedRateLimit()opens withif (!(error instanceof RateLimitError)) return false, the literal "window exhausted, skipping retries" line never printed. A pureRateLimitErrorwindow rejection (limit hit, credits still available) remains unwitnessed. The metadata channel is proven; the specific branch is proven only by counterfactual.Acceptance Criteria
AC-1: Extract persisted
errorContext; record channel + whetherrateLimitType/resetsAtpopulatedVerification: Manual Test (log-artifact inspection)
Scenario: Given the two 2026-07-18 run logs → When
errorContextis extracted → Then the channel and metadata population are recorded verbatim.Answer: Channel =
rate_limit_event(structured), not bareassistant.error. Discriminator per the issue:errorMetadata.assistantErroris absent. Confirmed againstbuildStructuredError(drivers/claude-code.ts:356), where therateLimitInfobranch is the only one that emitsresetsAt/rateLimitType/overageDisabledReason; theerrorFromAssistantErrorfallback stampsassistantErrorand nothing else.rateLimitType="five_hour"✅ populated.resetsAt=1784392200✅ populated.Assumptions: none outstanding — the discriminator is structural, not inferred.
AC-2: Confirm the intended branch fired
Verification: Manual Test (run-log phase entries + code trace)
Scenario: Given the captured failures → When the retry ladder is traced → Then the branch actually taken is recorded with evidence.
Answer (partial, honestly scoped):
failureIsBilling(phase-executor.ts:1054) gated it off; noPhase failed with MCP enabled, retrying without MCPnoise. Corroborated by duration — an MCP re-spawn would add a full phase attempt.isRetryable: falsepersisted.BillingError, which that predicate excludes by design.phase-executor.ts:834) is compared toCOLD_START_THRESHOLD_SECONDS = 60; the run-log entry's 17.47s is cumulative acrossexecutePhaseWithRetry(batch-executor.ts:944–976). Sub-60s billing attempts therefore fall through to the cold-start branch (:1030) and re-spawn up toCOLD_START_MAX_RETRIES = 2. The code comment at:952explicitly acknowledges this ("unlike the billing case which still cold-start-retries in the <60s window"), so it is known, intended behavior, not a defect — recorded for completeness, not filed as a bug.AC-3: Conditional follow-up if rejections routinely arrive without metadata
Verification: Manual Test (conditional; trigger evaluation)
Scenario: Given the captured evidence → When metadata population is assessed → Then the follow-up is filed only if the condition holds.
Answer: Condition NOT triggered — no follow-up issue to file. AC-3 is explicitly conditional ("If window rejections turn out to routinely arrive without metadata"). Both captures carry full metadata on the structured channel. The 5-min skip's precondition is met; the metadata-free heuristic AC-3 hedged against is not needed on this evidence. Filing it anyway would contradict the AC's literal text.
Implementation Plan
Phase 1: Durable capture (AC-1)
docs/incidents/782/captures/2026-07-18/— copy both run-log JSONs verbatim. Follows the existingdocs/incidents/<N>/captures/<date>/convention already used by fix(cli): #624's duplicate-header fix doesn't catch real log-update/scrollback bug (v2.3.0 regression confirmed) #647 and investigate(cli): #652 renderer corruption — column-mismatch hypothesis refuted, real cause unknown #655. Verbatim, because a paraphrased payload is exactly the synthetic-fixture trap this validation exists to avoid.docs/incidents/782/validation.md— the AC-1/AC-2/AC-3 record above, with code references. Mirrors investigate(cli): #652 renderer corruption — column-mismatch hypothesis refuted, real cause unknown #655'snegative-result.mdprecedent (an investigation whose output is a finding, not a code change).Phase 2: Regression guard (protects the validated assumption)
Add a production-sample test that feeds the captured
SDKRateLimitInfoshape throughcreateRateLimitError→ assertsBillingErrorwithrateLimitType/resetsAtpreserved in metadata; and asserts the counterfactual — the same payload minusoverageDisabledReasonyields aRateLimitErrorfor whichisWindowExhaustedRateLimitreturnstrueat the captured timestamps.Why this and not more: existing coverage (
phase-executor.test.ts:484) is entirely synthetic. Per the repo's ownfeedback_synthetic_test_fixture_traplesson, synthetic fixtures hide false negatives. This test pins the real field names and units so SDK field drift (a renamedresetsAt, a changed unit) breaks a test instead of silently disabling the feat: detect rate-limit failures mid-chain and halt cleanly instead of timeout-cascading #761 branch. It adds no behavior and changes no threshold — squarely inside the issue's Non-Goals.Phase 3: Cross-link
--auto-wait): its 2026-07-25 comment flags this issue as load-bearing. Answer for feat(run): --auto-wait — continue a rate-limited run when the window resets instead of halting #804:resetsAtis present on the structured channel, so auto-wait can fire on the real path — with the caveat that the observed rejection was credits-exhaustion, where waiting does not help (credits need purchasing, not a window wait).No source-behavior changes. Deliverables are docs + one test.
Design Review
docs/incidents/782/(established convention); the guard belongs beside the code it pins, insrc/lib/workflow/phase-executor.test.tswhereisWindowExhaustedRateLimit's synthetic tests already live.docs/reference/page (this is a point-in-time finding, not reference material) and a bespoke fixture module (two small JSON files need no loader).docs/incidents/<N>/captures/<date>/+ a root-level finding doc — exactly investigate(cli): #652 renderer corruption — column-mismatch hypothesis refuted, real cause unknown #655's shape.Feature Quality Planning
All standard checks pass. Notable items:
Derived ACs
None. Adding derived ACs to an evidence-gathering issue would widen scope against its stated Non-Goals.
Open Questions
RateLimitErrorwindow case get its own tracking issue? — Recommendation: no. AC-3's trigger condition is not met, and feat(run): --auto-wait — continue a rate-limited run when the window resets instead of halting #804 already carries the dependency. Impact if wrong: low — the counterfactual test in Phase 2 covers the branch mechanically.Recommended Workflow
Phases: spec → exec → qa
Quality Loop: enabled
Reasoning: Docs + one test, no runtime behavior change.
/testskipped —clilabel only, noui/frontend/admin./testgenskipped — the single test is written directly in/exec; stubbing one test is more ceremony than value.Label Review
Current:
cliRecommended:
cli,plannedReason: No label change warranted. Not
enhancement(no feature), notbug(no defect found). Addingdocswould be defensible but the deliverable is a validation record, not documentation.test(#782): guard the #799 sibling site; correct an overclaimed MCP e…
admarble commentedon Jul 25, 2026
QA Review for Issue #782
PR: #805 · Reviewed at:
30cf1beReviewed inline rather than via sub-agents (diff is 449 lines, under the 600-line threshold where QA agents are reliable on worktree code).
AC Coverage
errorContext; record channel + whetherrateLimitType/resetsAtpopulateddocs/incidents/782/captures/2026-07-18/. Channel =rate_limit_event—errorMetadata.assistantErroris absent, which is structurally decisive: perbuildStructuredError, therateLimitInfobranch is the only emitter ofresetsAt/rateLimitType, and theerrorFromAssistantErrorfallback stampsassistantErrorwith no timing fields.rateLimitType: "five_hour"✅,resetsAt: 1784392200✅ (decodes to16:30Z, matching the CLI's ownresets 11:30amline).failureIsBilling), non-retryable classification held (observed), "window exhausted" line did not fire (observed — classifiedBillingError), cold-start retries not skipped (inferred; known/intended per the comment above thecappedearly return). The counterfactual is pinned by test.Coverage: 3/3 AC items met · Original ACs: 3/3 · Derived ACs: none
Quality Plan Verification
Quality Plan Status: Complete
CI Status
build (22.x)typechecknode-floor-guardvalidate-pluginvalidate-skillsCI Summary: 5 passed, 0 pending, 0 failed. No gating check outstanding.
Quality Metrics
any)package.jsonchangedLocal gates:
npm run buildclean ·npm run lintclean (--max-warnings 0) · full suite excl. integration 151 files, 3505 passed, 1 expected fail, 2 skipped.Test Coverage Analysis
docs/incidents/782/validation.mddocs/incidents/782/captures/…*.json(2)src/lib/workflow/phase-executor.test.tssrc/lib/workflow/batch-executor.test.tsCoverage: no source files changed, so there is no coverage gap to flag. Critical paths without tests: none.
Test Quality Review
createRateLimitError/isWindowExhaustedRateLimit/isBillingOrWindowHaltoutputs; no internals touchedbatch-executor.test.tsalready preserves the realisWindowExhaustedRateLimit, so the sibling test exercises genuine logicDate.now(), no timing dependencyNon-tautology proven by mutation, not assumed: stripping
rateLimitTypeand shorteningresetsAtto 1 minute out fails all 3 phase-executor assertions, the counterfactual failingexpected false to be true— which confirmsisWindowExhaustedRateLimitis genuinely exercised rather than the test asserting on local variables. Capture restored byte-identical afterward.Anti-Pattern Detection
No
any, no hardcoded secrets, no SQL concatenation, no uncleared timers, no empty catch blocks, no N+1. No dependency changes.Sections not applicable
Call-Site Review (no new exported functions) · CLI Registration (no option interfaces) · Skill Command Verification (no skill
.mdchanged) · Detection Pattern Verification (precondition false — no skill regex/grep/awk/jq changes) · Execution Evidence / Script Verification (noscripts/changes) · Browser testing (no.tsx,clilabel only) · Manual Test AC enforcement (AC-1–AC-3 are log-artifact inspection, all executed and recorded) · Behavior-Rule Survival (no AC triggers the heuristic).CHANGELOG: N/A — commits are
test(…), which is not in the user-facing prefix set (feat|fix|perf|refactor|docs), and the change is docs + tests with no behavior change.Risk Assessment
RateLimitErrorwindow case; mitigated by stating the residual in the doc, the PR body, and the test's own comment.RateLimitErrorwindow rejection (limit hit, credits remaining) — none exists in production yet, which is the entire premise of this issue. Covered by counterfactual only, and labeled as such everywhere.batch-executor.tsisBillingOrWindowHalt/billingHaltReason(fix(run): -Q quality loop retries after an "Out of credits" exec instead of failing fast (billing cascades into "unparseable verdict") #799) — found during this review and closed, not merely noted. It consumes the same classifier and its coverage was also entirely synthetic.isWindowExhaustedRateLimit (#761 AC-2)suite directly above the new block inphase-executor.test.ts— reviewed; left untouched deliberately. It is the synthetic unit-boundary suite; the new block is its production-sample complement, not a replacement.Adversarial Re-Read
Findings — two real gaps in my own first commit, both fixed in
30cf1be:retrying without MCPline" as though observed in the capture. It is not observable there:stdoutTail/stderrTailcarry the driver'sstdoutBuffer(agent output, set indrivers/claude-code.tsand passed through byphase-executor.ts), while that line comes from the executor's ownbracketedConsoleLog. It would be absent either way. The row also leaned on a duration argument that doesn't hold without a known baseline. Corrected: the skip is a code-level guarantee via thefailureIsBillinggate, and the evidence table now carries an explicit kind of evidence column separating observed / inferred / code-level across all four rows.isBillingOrWindowHalt(fix(run): -Q quality loop retries after an "Out of credits" exec instead of failing fast (billing cascades into "unparseable verdict") #799) was not covered. Closed with a production-sample test rather than deferred to a follow-up.Also checked, no gaps: motivating-example fixtures — the issue body has no fenced blocks or blockquotes; its verbatim technical claims (
errorMetadata.assistantError,rateLimitType,resetsAt, bareassistant.error: "rate_limit") are each asserted in the tests. Evidence-claim audit — the captures are artifacts of the shipped code (startCommit b1bedbc= the #781 merge commit), so they are post-fix validation, not a pre-fix bug repro. Process state — working tree clean, branch 0 commits behindorigin/main, no stashes; an unrelatedpackage-lock.jsondrift from the worktree'snpm install(npm strippinglibcplatform metadata) was caught and reverted before the first commit rather than swept into the PR. Non-Goals — the issue forbids changing the threshold or fallback design; the diff touches onlydocs/and two.test.tsfiles, so no threshold, predicate, or ladder was modified.Status: Clean
Verdict: READY_FOR_MERGE
All 3 ACs met, CI fully green, no source behavior changed, and the issue's Non-Goals are honored. The adversarial pass found two real defects in the first commit and both were fixed rather than documented as known gaps — which is the intended outcome of that gate, not a reason to withhold the verdict.
The one thing to carry forward is a finding, not a defect: a pure
RateLimitErrorwindow rejection remains unwitnessed in production. It is recorded in the doc, the PR body, and the test comments, and is covered mechanically by the counterfactual test.Documentation
docs/incidents/782/validation.md— the durable record, following thedocs/incidents/<N>/convention from fix(cli): #624's duplicate-header fix doesn't catch real log-update/scrollback bug (v2.3.0 regression confirmed) #647 / investigate(cli): #652 renderer corruption — column-mismatch hypothesis refuted, real cause unknown #655Next Steps
--auto-wait) — this answers its load-bearing question:resetsAtis present on the structured channel, so auto-wait can compute a real wait target on the common path. Carry one caveat into that design: gate onRateLimitError, not on the mere presence ofresetsAt, becauseBillingErrorcarries aresetsAttoo and waiting never helps there (credits need purchasing, not a window wait).docs(#782): commit the metrics corroboration; the cited source is git…
admarble commentedon Jul 25, 2026
QA Addendum — second-look pass (#782)
Reviewed at:
40ba50e· CI 5/5 pass · Verdict unchanged: READY_FOR_MERGEA second adversarial pass on the already-approved work. It found one real gap, one understated claim, and one false-positive gate trip.
1. Perishable, unverifiable evidence — fixed (
40ba50e)validation.mdcited.sequant/metrics.jsonas independent corroboration for AC-1. Two problems:.sequant/is gitignored (.gitignore:52), so no reader could ever verify that claim.maxFiles: 100, and the directory was observed dropping 100 → 99 during this session. The cited source is on its way out.This retroactively reframes a decision made earlier in the run: copying the run logs into
docs/incidents/782/captures/was load-bearing preservation, not tidiness. Had they only been referenced in place, the record would have been pointing at files that no longer exist within weeks.Fixed by excerpting the two matching
metrics.jsonentries verbatim intocaptures/2026-07-18/metrics-excerpt.json(with provenance), and stating in the doc why the artifacts are copied rather than referenced.2. Understated the cold-start finding — fixed (
40ba50e)I had labelled the "3 cold-start spawns" claim "arithmetic inference, not measurement". That was too weak — the count is provable:
Cumulative phase time is 17.47s, so every attempt necessarily ran under 60s. At sub-60s a
BillingErrorcan take no early exit from the ladder — it is notcapped; it is not aRateLimitError, so both the window-exhaustion and transient-backoff branches are skipped; andduration >= COLD_START_THRESHOLD_SECONDSis false. Only the cold-start fall-through remains. The loop therefore runs attempts 0–2 and exhausts: exactly 3 agent spawns against an account with no credits.Only the per-attempt split (~5.8s each) is arithmetic. The doc now separates the two rather than conservatively labelling both as inference.
3. CHANGELOG gate — false positive, declared not suppressed
My own
docs(#782):commit prefix matches the §10a user-facing regex (feat|fix|perf|refactor|docs), andCHANGELOG.mdexists — so the gate now computeschangelog_required = true,changelog_missing = true, which would demote the verdict toAC_MET_BUT_NOT_A_PLUS.This is a false positive, and I'm keeping
READY_FOR_MERGE. The gate is a commit-prefix heuristic whose own documentation flags this dependency. The change adds an internal incident-validation record underdocs/incidents/; there is no user-facing behavior, flag, or API to describe. Adding a CHANGELOG entry saying "wrote an internal validation record" would put QA minutiae in a file users read for product changes — worse than the false positive.The prefix was a poor choice on my part (
chorewould have been accurate), but the commit is pushed and amending pushed commits is not done in this repo. Declaring the trip is the correct remedy over silently ignoring it.Verified, no gap
CI genuinely runs the new tests. I had asserted "5/5 CI checks pass" without confirming the suite executed there.
build (22.x)runsnpm test— full vitest, including the integration tests my local run skipped after the exit-144 worktree timeout. So CI is stronger evidence than the local run I reported, not merely equivalent.Also re-checked, clean
Test determinism (all timestamps from the committed capture; no
Date.now();toISOString()comparisons are timezone-independent) · no mocks added, andbatch-executor.test.tsalready preserves the realisWindowExhaustedRateLimit, so the sibling test exercises genuine logic · relative doc links resolve · both capture JSONs still byte-identical to their originals · working tree clean, 0 commits behindorigin/main· Non-Goals still honored (no threshold, predicate, or ladder touched).Net
Three commits, all docs + tests. AC coverage unchanged at 3/3 MET. Nothing found in this pass changed a conclusion in the validation record — the corrections made the evidence more durable and one claim stronger.
test(#782): validate #761 AC-9 — real window rejections carry rateLim…
feat(#804): --auto-wait — continue a rate-limited run when the window…