Repository navigation
fix(cost): preserve catalog pricing evidence - #2776
Conversation
Problem:\nCodex state_5 threads.tokens_used can contain zero sentinels, stale\nrepeated defaults, and inherited cross-thread counters. Treating those\nvalues as archive drift made the reconciliation probe overstate failures.\n\nWhat changed:\nClassify these external-state-unreliable counters before tolerance\ncomparison and report their classes and samples separately. Remove\narchived/has_user_event from residual classification because they are not\ndiscriminating evidence.\n\nVerification:\nnix develop --command devtools test tests/unit/devtools/test_cost_reconciliation_probe.py tests/unit/core/test_pricing.py tests/unit/sources/test_parsers_codex.py tests/unit/sources/test_parsers_claude_code_artifacts.py -k 'cost or pricing or token_lane or unreliable_state' (29 passed, 77 deselected)\nnix develop --command devtools verify --quick (16 checks passed)\n\nRef polylogue-w8et\n\nCo-authored-by: Codex <[email protected]>
|
Warning Review limit reached
Next review available in: 50 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (7)
✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1283f7a170
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Problem:\nThe price-catalog hash was written but never read. A PRICING correction under\nthe same effective date left model_prices stale and new usage pointed at an\narbitrary catalog row.\n\nWhat changed:\nUse the catalog hash to reuse an exact persisted revision or seed an immutable\nversioned catalog. Resolve priced_with from the row matching the active hash,\npreserving historical price evidence.\n\nVerification:\nnix develop --command devtools test tests/unit/storage/test_pricing_chain_roundtrip.py tests/unit/core/test_pricing.py tests/unit/sources/test_parsers_codex.py tests/unit/sources/test_parsers_claude_code_artifacts.py -k 'pricing or token_lane' (34 passed, 77 deselected)\nnix develop --command devtools verify --quick (15 checks passed)\n\nRef polylogue-w379\n\nCo-authored-by: Codex <[email protected]>
Review fix from PR feedback: classify repeated cross-thread values as repeated_stale_state_fingerprint only when the archive-backed state fingerprint confirms staleness, instead of on value repetition alone. Verified: 29 focused tests passed; devtools verify --quick passed. Co-Authored-By: Claude <[email protected]>
Problem:\nExisting index archives skip bootstrap seeding, so a changed in-memory catalog\nhad no matching database revision when normal message writes ran.\n\nWhat changed:\nSeed or reuse the hash-matched catalog in the production usage writer. The\nregression mutates PRICING then writes to an existing archive without manually\nseeding a revision.\n\nVerification:\nnix develop --command devtools test tests/unit/storage/test_pricing_chain_roundtrip.py -k 'seed or priced_with or cost_usd' (8 passed)\n\nRef polylogue-w379\n\nCo-authored-by: Codex <[email protected]>
Problem:\nDirect Codex message usage could report uncached_input_tokens without an\ninclusive input_tokens value. The parser ignored that explicit fresh lane and\npriced it as zero in the message fallback.\n\nWhat changed:\nPrefer the explicit uncached-input aliases when present, otherwise derive fresh\ninput by subtracting cache reads. The regression drives parser output through\nstorage and estimate_session_cost's per-message fallback.\n\nVerification:\nnix develop --command devtools test tests/unit/core/test_pricing.py tests/unit/sources/test_parsers_codex.py tests/unit/sources/test_parsers_claude_code_artifacts.py -k 'pricing or token_lane or message_usage' (24 passed)\n\nRef polylogue-d3xj\n\nCo-authored-by: Codex <[email protected]>
|
Adversarial review iteration 1 Found and repaired two real gaps:
The prior duplicate-total review finding is covered by |
|
Adversarial review iteration 2 No real acceptance-criterion gaps found across Borderline dismissed: the probe's |
|
Final acceptance matrix
No criteria are deferred or misframed. Local focused gates and the pre-push quick gate passed. GitHub Actions' no-step initialization failures remain the known account-infrastructure pattern; this PR was not merged and no beads were closed. |
…789,2792,2797 d3xj, w8et, w379 (cost-honesty, PR #2776), fs1.3 (hermes-wedge, PR #2789), and f2qv.5 (usage-convergence, PR #2797) fully satisfied — closed. cuxz (temporal-provenance, PR #2786), th0 (test-harness, PR #2777), and fs1.11/ fs1.12 (hermes-wedge cluster, PR #2792) partially satisfied — noted with disposition, left open per closure-discipline (no closing on partial ACs). Co-Authored-By: Claude <[email protected]>
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Make Codex cost evidence honest at both reconciliation boundaries: unreliable
state_5.sqlitecounters are separated from archive drift, and pricing catalog revisions are versioned by their content hash.Problem
threads.tokens_usedis external runtime state. Zero sentinels, stale repeated values, and inherited/cumulative counters were folded into outside-tolerance drift. Separately,price_catalogs.catalog_hashwas write-only: aPRICINGcorrection under the same effective date left DB price rows stale and new usage could select an arbitrary historical catalog.Solution
session_model_usage.priced_withfrom the catalog matching the current hash, preserving historical price evidence.Acceptance matrix:
polylogue-d3xj8c9dfbb00/ PR #2647 normalizes Codex message input to disjoint fresh-input and cache-read lanes with a parser-to-storage-to-pricing fallback regression.polylogue-w8et713a07feareports zero sentinel, repeated stale-state fingerprints, and over-2,000,000-token counters as external-state-unreliable rather than drift.polylogue-w379292c4e84dversions stored hashes;831c7d970seeds that revision during ordinary existing-archive writes and links new usage to it.Ref polylogue-d3xj
Ref polylogue-w8et
Ref polylogue-w379
Verification
nix develop --command devtools test tests/unit/devtools/test_cost_reconciliation_probe.py tests/unit/core/test_pricing.py tests/unit/sources/test_parsers_codex.py tests/unit/sources/test_parsers_claude_code_artifacts.py -k 'cost or pricing or token_lane or unreliable_state'— 29 passed, 77 deselected.nix develop --command devtools test tests/unit/storage/test_pricing_chain_roundtrip.py tests/unit/core/test_pricing.py tests/unit/sources/test_parsers_codex.py tests/unit/sources/test_parsers_claude_code_artifacts.py -k 'pricing or token_lane'— 34 passed, 77 deselected.nix develop --command devtools verify --quick— 15 checks passed.Anti-vacuity: the
w8etregression drives the production CLImain()path against a real archive index and copiedstate_5.sqlite; removing classification/exclusion returns unreliable values to the tolerance comparison. Thew379regression mutates the productionPRICINGdict, reseeds a real index, writes real usage, and fails if hash comparison, immutable revision seeding, or active-catalog linkage is removed.Adversarial review notes
831c7d970), and direct messages could ignore explicit fresh-input lanes (6b3ce5712).external_total_tokensincludes excluded unreliable state rows, but it does not drive comparison/pass-fail and the response separately reports those rows.