fix(server): include Codex archived_sessions in usage scan - #11896
bulbulogludemir wants to merge 1 commit into
Conversation
Codex moves rolled-out sessions to archived_sessions, but the usage scanner only read sessions/, so archived history never contributed cost. Scan both directories and give Codex events a stable dedupeKey so copies across the two are charged once. Bump the scan cache version since v3 Codex records have null keys.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — The PR changes production usage metering by adding archived Codex sessions to priced summaries and changing cross-file duplicate charging behavior. It is narrowly scoped and tested, but metering changes require human review. You can add or adjust custom eligibility rules. Learn more. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (6)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughCodex usage scanning now includes ChangesCodex usage deduplication
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The archived-session scan, deduplication, and cache invalidation changes have no identified merge-blocking risk. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Ready for human review (per the Macroscope approability note — this touches usage metering, so auto-approval is off by policy). Verification summary:
|
Codex moves rolled-out sessions to
archived_sessions, but the usage scanner only readssessions/, so any archived history silently contributes zero cost to the Usage page.This change:
archived_sessionsalongsidesessionsfor every Codex home (deduped per directory, so aliased/shadow homes still scan once),dedupeKey(session, timestamp, model, token totals) so a rollout present in both directories is charged exactly once; genuinely different sessions/events keep distinct keys,USAGE_SCAN_CACHE_VERSION3 → 4 because v3 Codex records carry null keys and would double-count archived copies.Tests:
usageTranscripts.test.ts: identical events parsed from two copies share one dedupeKey.UsageService.test.ts: an identical archived rollout copy is scanned (sources 4 → 5, files 4 → 5) with totals unchanged.usageScanCache.test.ts: previous-version rejection now targets v3.apps/servertypecheck passes; usage test files pass (usageTranscripts/usageScanCache/usageAggregationgreen, modifiedUsageServiceaccount test green — 2 pre-existingit.livetimeouts in that file also fail on clean main in this environment).Summary by CodeRabbit