Skip to content

test(#782): validate #761 AC-9 — real window rejections carry rateLimitType/resetsAt - #805

Merged
admarble merged 3 commits into
mainfrom
feature/782-validate-761-ac-9-confirm-real-window-exhausti
Jul 25, 2026
Merged

admarble merged 3 commits into
mainfrom
feature/782-validate-761-ac-9-confirm-real-window-exhausti

Conversation

@admarble

Copy link
Copy Markdown
Contributor

Summary

The post-hoc validation #761 AC-9 asked for. #782 was parked on 2026-07-18 for want of a real captured rejection; 30 minutes later, one arrived. Two run logs from that day record startCommit: b1bedbc — the PR #781 merge commit itself — so the structured errorContext persistence #761 added was live when they were written.

The load-bearing assumption is validated: real window exhaustion does arrive on the structured rate_limit_event channel with rateLimitType and resetsAt populated.

Docs + tests only. No behavior change, no threshold change (honors the issue's Non-Goals).

AC Verification

AC Description Status Evidence
AC-1 Record which channel fired + whether rateLimitType/resetsAt populated ✅ Implemented docs/incidents/782/validation.md; errorMetadata.assistantError absent ⇒ structured rate_limit_event, not the bare fallback — structurally decisive per buildStructuredError. rateLimitType: "five_hour", resetsAt: 1784392200 → 16:30Z, matching the CLI's own resets 11:30am line.
AC-2 Confirm the intended branch fired ⚠️ Partial — recorded as such See below.
AC-3 File a metadata-free-heuristic follow-up if rejections routinely lack metadata ✅ Correctly not triggered The AC is explicitly conditional. Metadata was present on both captures, so no follow-up is filed — filing one would contradict the AC's literal text.

AC-2 in detail — what the artifacts actually show

Outcome
MCP fallback skipped ✅ failureIsBilling gate; no "retrying without MCP" noise
Non-retryable classification held ✅ isRetryable: false persisted
"Window exhausted, skipping retries" printed ⚠️ No
Cold-start retries skipped ⚠️ No — they ran

The rejection also carried overageDisabledReason: "out_of_credits", so isBillingFailure() won and createRateLimitError() returned a BillingError, not a RateLimitError. isWindowExhaustedRateLimit() opens with if (!(error instanceof RateLimitError)) return false, so the window path was unreachable.

The counterfactual is decisive, though: at phase start the reset was 24.8 minutes out — well past the 5-minute threshold. Absent the credits flag, this exact payload takes the window branch. The metadata was sufficient to drive it; only the billing classifier took precedence. That counterfactual is now pinned by a test.

Cold-start retries running on the sub-60s billing path is known, intended behavior — the comment above the capped early return says so explicitly. Recorded for completeness, not filed as a bug.

Residual, stated plainly: a pure RateLimitError window rejection — limit hit while credits remain — is still unwitnessed. The metadata channel is proven; the specific branch is proven only by counterfactual.

Changes

Why the test, given "no design changes"

Existing coverage for isWindowExhaustedRateLimit is entirely synthetic. This test reads the committed capture files and replays them through createRateLimitError / isWindowExhaustedRateLimit, so the doc artifact and the test cannot drift apart. It pins the real field names and units — a renamed resetsAt, a changed unit, or a dropped rateLimitType breaks a test instead of silently disabling the #761 branch. It adds no behavior and changes no threshold.

Test plan

  • npm run build — clean
  • npm run lint — clean (0 errors, 0 warnings, --max-warnings 0)
  • phase-executor + batch-executor suites — 200/200 pass
  • Full suite (excl. integration) — 151 files, 3505 passed, 1 expected fail, 2 skipped
  • Mutation-verified non-tautological — stripping rateLimitType and shortening resetsAt to 1 min out fails all 3 assertions, including the counterfactual failing expected false to be true (proving isWindowExhaustedRateLimit is genuinely exercised). Capture restored byte-identical afterward.

Note for #804 (--auto-wait)

#804 flags this validation as load-bearing. Answer: resetsAt is present on the structured channel, so auto-wait can compute a real wait target on the real path. Caveat worth carrying into that design — the observed rejection was credits exhaustion, where waiting doesn't help. Auto-wait should gate on RateLimitError, not on the presence of resetsAt alone, since BillingError carries a resetsAt too.

Closes #782

admarble added 2 commits July 25, 2026 00:18
…itType/resetsAt

Post-hoc validation #761 AC-9 asked for. Two real rate-limit rejections
captured 2026-07-18 (startCommit b1bedbc — the PR #781 merge commit itself,
so the structured errorContext persistence was live) settle the load-bearing
assumption: window exhaustion DOES arrive on the structured rate_limit_event
channel with rateLimitType and resetsAt populated.

AC-1: channel = rate_limit_event, not bare assistant.error (errorMetadata
      .assistantError absent — structurally decisive per buildStructuredError).
      rateLimitType "five_hour", resetsAt 1784392200 -> 16:30Z, matching the
      CLI's own "resets 11:30am" line.
AC-2: partial, and recorded as such. MCP fallback correctly skipped and the
      non-retryable classification held, but the "window exhausted" line did
      not print — credits were also exhausted, so isBillingFailure won and the
      error was a BillingError, which the predicate excludes by design. The
      counterfactual is decisive: the reset was 24.8 min out, well past the
      5-min threshold, so the same payload without the credits flag would have
      taken the branch. Cold-start retries were NOT skipped (known, intended —
      see the comment above the capped early return).
AC-3: not triggered. The AC is conditional on rejections arriving WITHOUT
      metadata; metadata was present, so no follow-up issue is filed.

Adds a production-sample regression test that replays the committed captures
through createRateLimitError and isWindowExhaustedRateLimit, including the
counterfactual. Existing coverage is entirely synthetic; this pins the real
field names and units so SDK drift breaks a test instead of silently disabling
the #761 branch. Verified non-tautological by mutation.

Docs + tests only — no behavior change, no threshold change (issue Non-Goals).
…vidence row

Two QA findings on my own first commit.

1. Cross-file sibling site (QA §5). batch-executor's isBillingOrWindowHalt
   (#799) consumes the same classifier as the #761 window branch, and its
   coverage is also entirely synthetic. The captured payload is a valid input,
   so replay it there too: if SDK drift changed the shape, the predicate would
   silently stop halting the -Q loop and #799's "QA completed without a
   parseable verdict" mislabel would return. Also pins billingHaltReason.

2. Overclaim in validation.md. The "MCP fallback skipped" row cited "no
   retrying without MCP line" as if it were observed in the capture. It is not:
   stdoutTail/stderrTail carry the driver's stdoutBuffer (agent output), while
   that line comes from the executor's own bracketedConsoleLog — so it would
   not appear in these artifacts either way. The skip is a code-level guarantee
   via the failureIsBilling gate, not a log observation. The evidence table now
   carries a "kind of evidence" column separating observed from inferred from
   code-level across all four rows.

Still docs + tests only.
…ignored and rotating

Second-look findings on the validation record.

1. Perishable, unverifiable evidence. validation.md cited
   ".sequant/metrics.json" as independent corroboration for AC-1, but
   .sequant/ is gitignored (.gitignore:52) — so no reader could check that
   claim. Worse, run-log rotation is capped at maxFiles: 100 and is actively
   evicting: the directory was observed dropping 100 -> 99 while this was being
   written, so the cited originals are on their way out. The two matching
   metrics entries are now excerpted verbatim into the captures directory, and
   the doc explains why the artifacts are copied rather than referenced. This
   also retroactively justifies committing the run logs — that was load-bearing
   preservation, not tidiness.

2. Understated the cold-start finding. It was labelled "arithmetic inference,
   not measurement". The attempt COUNT is in fact provable: cumulative phase
   time is 17.47s, so every attempt ran under 60s, and at sub-60s a
   BillingError can take no early exit from the ladder (not capped; not a
   RateLimitError, so both the window and transient-backoff branches are
   skipped; duration < threshold) — leaving only the cold-start fall-through.
   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.

No test or behavior change; 201 tests still pass.
@admarble
admarble merged commit c347b12 into main Jul 25, 2026
5 checks passed
@admarble
admarble deleted the feature/782-validate-761-ac-9-confirm-real-window-exhausti branch July 25, 2026 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

validate(#761 AC-9): confirm real window-exhaustion rejections carry rateLimitType/resetsAt (post-hoc capture)

1 participant