fix(codex): settle reset-credit retry aliases canonically - #3919
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Team Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe reset-credit consume flow now adopts the ledger’s canonical operation ID after alias resolution. Settled results replay for known aliases without another upstream request. The integration test and management API documentation cover this behavior. ChangesReset-credit operation aliases
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to Reset-credit retries using known alias IDs now reuse the canonical operation and replay settled results without triggering another redemption. The covered behavior is ready to merge with no identified current-head risk. Sequence Diagram(s)sequenceDiagram
participant Caller
participant Ledger
participant Upstream
Caller->>Ledger: Submit operationId
Ledger-->>Caller: Resolve canonical operation ID
Caller->>Upstream: Consume with canonical ID
Upstream-->>Ledger: Settle result
Caller->>Ledger: Retry with known alias
Ledger-->>Caller: Replay settled result
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
⏳ DRAFT
What to do
Review readiness checklist
3/4 boxes ticked. This pull request was already a draft. Its draft status will be preserved after every issue above is resolved. Hygiene
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
리뷰 · 우선순위 62 / 80이 PR은 수동 reset-credit 소비 API에서 별칭(alias) operationId로 재시도할 때 정산 키가 어긋나는 작은 버그를 고칩니다. 같은 물리 계정에 아직 끝나지 않은 소비가 있는데 클라이언트가 다른 지금 근처 PR과의 관계만 짚으면, #3912( 변경 자체는 한 줄 의미의 수정이라 읽기 쉽습니다. upstream 호출 전에 이미 다만 프로세스 게이트가 막혀 있습니다. hygiene가 라인 2344 - 라인 2380 근처 - 기존 주석 “Canonical id, which an alias join may map to an earlier caller id”는 이미 있었는데, 정산 identity 갱신이 빠져 있던 상태다. 이번 한 줄이 그 주석과 실제 동작을 맞춘다.
메인테이너의 판단이 필요한 지점
너의 추천 코드 방향은 이 댓글은 grok-bot이 작성했습니다 |
|
Delivered independently via #3965 as The carry retains the two production hunks and adds three real-ledger pending-to-ambiguous oracles for alias throw/non-2xx/unknown-code outcomes. Final candidate Actual landing tree equals the fully tested candidate tree, fetched dev contains the landing, and original author credit survives. No real credits/accounts or local product suites used. Closing this original as carried, not directly merged. Thank you for the original correction. |
Summary
A manual reset-credit retry can join an unfinished operation under a different caller ID. The upstream request already uses the original canonical ID, but the API was recording settlement with the alias ID. The ledger rejects that mismatch, so a later retry dispatches another consume request instead of replaying the stored result.
Use the ledger-returned canonical identity for settlement and ambiguous outcomes. Keep account ownership checks, failure handling, and the legacy path without an operation ID unchanged. The API reference clarifies alias replay and when a new ID represents a new redemption.
This carries the focused source commit
45ff81c25ed7636382fb0144409918067d44f616onto currentdev; unrelated release ancestry is excluded and the original authorship is retained. Scope is three files with 16 added lines and one removed line.Verification
Head
6f20c3d08cd202e43b8679de33674133bdc7f34c, based ondev273a3ab865cdd95f3ce08f5583c3e1661978301d. Tested tree:d7ca5f7f17e0acbdfd9d5b4fcf26171c7540834b.bun test tests/codex-integration/codex-auth-api.test.ts tests/codex-integration/codex-reset-credit-operation-ledger.test.ts --timeout 60000: 299 passed with the project-pinned Bun 1.4.0 on Windows (and previously with Bun 1.4.2).bun run typecheck,bun run privacy:scan, andgit diff --check: passed.bun run test:changed --timeout 60000reached the repository runner's 900-second limit (exit 124), which discarded the captured output before emitting a selection summary. This is not a passing suite. Its owned runner and worker processes were confirmed absent afterward. Full cross-platform contributor CI passed all 26 jobs on this exact head after one failed-job rerun. Contributor validation is complete; the PR remains in draft pending the required maintainer security review /maintainer-sponsoredlabel forsrc/codex/auth-api.ts; the independent review above does not satisfy that maintainer gate.The first CI attempt completed the macOS control with 21,405 passed, 16 skipped, and two Cursor stream-health timing assertion failures. Both cases passed in the other macOS lane on the same head, and the alias replay regression passed in the failed control. The single failed-job rerun passed on the same head without a source change; the initial attempt is retained here and is not counted as green.
Checklist
Review readiness checklist
Summary by CodeRabbit
Documentation
Bug Fixes