Skip to content

fix(codex): keep a settled reset-credit entry until its credit expires - #35

Merged
vadymhimself merged 1 commit into
release/2.65.0-vadymhimself.15from
gauge/reset-credit-prune
Nov 17, 2026
Merged

vadymhimself merged 1 commit into
release/2.65.0-vadymhimself.15from
gauge/reset-credit-prune

Conversation

@vadymhimself

Copy link
Copy Markdown
Collaborator

What

The reset-credit journal prune dropped a settled entry as soon as its last update was more than a week old, even when the credit that entry records had not expired yet.

The prune now keeps a settled entry while now < max(updatedAt + 7 days, expiresAt):

  • Unsettled entries are always kept, as before.
  • If expiresAt cannot be parsed, only the one-week rule applies.

Follow-up promised in the review of #28.

Tests

  • tests/codex-integration/codex-reset-credit-auto-redeem.test.ts: new test "a settled entry is kept until its credit expires, even past the one-week age". It seeds two settled entries last updated 8 days ago, one with an unexpired credit and one with an expired credit.
  • On the new code the file passes 20 of 20.
  • On the old code the new test fails because the unexpired entry is dropped, and the file passes 19 of 20.

Eval added/updated: settled reset-credit journal entry with an unexpired credit survives the prune past one week (must-fail on the old code).

🤖 Generated with Claude Code

The journal prune dropped a settled entry once its last update was a week
old, even when the credit it records had not expired yet. Keep a settled
entry while now < max(updatedAt + 7 days, expiresAt); an unparseable
expiry falls back to the week rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Nov 16, 2026
@vadymhimself

Copy link
Copy Markdown
Collaborator Author

QA-RECEIPT repo=opencodex pr=35 sha=ddb5f1768275c293803b7c3c5c47fa68daf3d678 verdict=GREEN

Independent QA (Earth, standing in for Mars): GREEN at exactly ddb5f17 (the current head).

Read: the full diff (reset-credit-auto-redeem.ts +9/-3, its test +17) and the whole redeemer at the head.

  • Rule: unsettled (dispatched) entries are always kept. A settled entry stays while now < max(updatedAt + 7 d, Date.parse(expiresAt)). A null, missing or unparseable expiry gives NaN, so only the old week rule applies. At the week edge it is the same strict < as before, and at expiry it is dropped.
  • Why it matters (double credit): tick() looks up the journal by (accountKey, grantedAt, expiresAt), and a settled match skips the dispatch (credit-gone). Before, a settled entry older than a week but with an unexpired credit could be pruned, so a still-listed credit would get a fresh redeemRequestId and a second redeem. Keeping it until expiry closes that. After expiry the credit is not listed (creditStillPresent matches both dates), so dropping it is safe.
  • Time zones: expiresAt is the provider's ISO string, so Date.parse is zone-safe for Z/offset strings. now is the same clock that wrote updatedAt.
  • Test: seeds two settled entries last updated 8 days ago, one unexpired and one expired, and expects only the unexpired one plus the new dispatch. On the old code both seeded entries are pruned, so it fails, as Gauge says (19/20).
  • CI run 43797627485: 21 success, 9 skipped (macOS, Windows shards, docs, privacy, structure and setup gates, all path or platform gated; no test skipped). Shard test 1/4 ran this file, including (pass) ... a settled entry is kept until its credit expires, even past the one-week age, with 27 pass and 0 fail. No evals scenario is changed.

Merge at exactly ddb5f17.

@vadymhimself

Copy link
Copy Markdown
Collaborator Author

Mars security review: GREEN at ddb5f17

The reset-credit auto-redeem now always keeps unsettled entries. A settled entry is kept until the later of updatedAt plus 7 days and its expiresAt, and an unparseable expiry falls back to the one-week rule (src/codex/reset-credit-auto-redeem.ts:96-104). Keeping more entries can only guard against a double redeem, so it fails in the safe direction. No limit, price or routing change. CI has no failures at this head.

@vadymhimself
vadymhimself merged commit 326e1a7 into release/2.65.0-vadymhimself.15 Nov 17, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant