Skip to content

fix(#1248): Codex usage-limit tests no longer read the real clock - #1251

Merged
admarble merged 2 commits into
mainfrom
feature/1248-fix-test-codex-usage-limit-tests-read-the-real-clo
Oct 1, 2026
Merged

admarble merged 2 commits into
mainfrom
feature/1248-fix-test-codex-usage-limit-tests-read-the-real-clo

Conversation

@admarble

@admarble admarble commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • CodexRunOutcome gains an optional now?: number, threaded into classifyCodexTurnFailure inside evaluateCodexRun. Production (:now unset) keeps Date.now() via the existing default parameter.
  • driver-conformance.test.ts's codexOutcome() helper and batch-executor.test.ts's inline evaluateCodexRun() call now pin now to 2026-09-01, well before the fixture's 2026-10-16 reset enters the 7-day RateLimitError horizon — the tests no longer flip to RateLimitError when the wall clock crosses 2026-10-09.
  • codex.test.ts gets a new case that parses the real codex-turn-failed-usage-limit.jsonl fixture through evaluateCodexRun with now set inside the 7-day horizon (2026-10-10), asserting RateLimitError with the correct resetsAt epoch — so that branch is covered on purpose, not by the calendar.

Mutation verification (AC-3)

Reverted driver-conformance.test.ts's PINNED_NOW to 2026-10-10 (inside the horizon), ran the file, confirmed the BillingError assertion failed as expected, then restored the pin.

Mutation-verified: AC-3 — set PINNED_NOW to 2026-10-10 (inside the fixture's 7-day horizon); src/lib/workflow/drivers/__tests__/driver-conformance.test.ts > driver conformance > codex > errors > map the verbatim #1087 usage-limit turn failure to BillingError failed; restored.

Test plan

  • npx vitest run src/lib/workflow/drivers/__tests__/driver-conformance.test.ts src/lib/workflow/batch-executor.test.ts src/lib/workflow/drivers/codex.test.ts — 190 passed
  • npm run build — passes
  • Mutation check above confirms the pin is load-bearing

Pre-PR AC Verification

AC Description Status Evidence
AC-1 Both tests independent of wall clock ✅ Implemented now pinned in codexOutcome() (driver-conformance.test.ts) and inline call (batch-executor.test.ts)
AC-2 Horizon branch covered on purpose ✅ Implemented New case in codex.test.ts using the real fixture, now inside the window
AC-3 Mutation check proves pin is load-bearing ✅ Implemented See mutation record above

Runner verification (head e7fb33d)

  • Ran every test file that names evaluateCodexRun, classifyCodexTurnFailure or the usage-limit fixture (grep -rlE … --include='*.test.ts' | xargs npx vitest run). Result: 3 files, 190 passed.
  • The literal AC-3 mutation: I dropped now: PINNED_NOW from codexOutcome() and faked the system clock to 2026-10-10 (vi.useFakeTimers({toFake:["Date"]}) + vi.setSystemTime). Exactly one test failed, the one named below. Restored.
  • Control: with the pin kept and the clock still faked to 2026-10-10, all 34 tests pass. So the pin holds on the dates when main would have gone red.
  • Production default: with outcome.now undefined, classifyCodexTurnFailure(msg, undefined) falls back to the Date.now() default parameter, so runtime behaviour is unchanged.
  • Fixed QA's one gap: added the missing CHANGELOG ### Fixed entry (e7fb33d).

Mutation-verified: AC-3 — removed now: PINNED_NOW from codexOutcome() and set the system time to 2026-10-10; src/lib/workflow/drivers/__tests__/driver-conformance.test.ts > driver conformance > codex > errors > map the verbatim #1087 usage-limit turn failure to BillingError failed; restored.

Closes #1248

🤖 Generated with Claude Code

Pin now in the Codex usage-limit tests so BillingError assertions
stop depending on the wall clock crossing the fixture's 7-day
RateLimitError horizon on 2026-10-09.

Entire-Checkpoint: 7b779d204ec5
@admarble
admarble merged commit 397c126 into main Oct 1, 2026
7 checks passed
@admarble
admarble deleted the feature/1248-fix-test-codex-usage-limit-tests-read-the-real-clo branch October 1, 2026 03:18
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.

fix(test): Codex usage-limit tests read the real clock — main goes red 2026-10-09 → 10-16 when the fixture's reset enters the 7-day horizon

1 participant