Feature/Fix: Add a shadow lineage ledger for Codex token accounting#2140
Feature/Fix: Add a shadow lineage ledger for Codex token accounting#2140iam-brain wants to merge 1 commit into
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 13, 2026, 9:19 PM ET / July 14, 2026, 01:19 UTC. Summary Reproducibility: yes. at source level: distinct observations in one lineage with the same complete token-counter tuple are treated as one admitted observation under the proposed identity contract. The PR head has not changed since this case was previously raised. Review metrics: 2 noteworthy metrics.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Define a copy-stable event identity or a conservative fail-open collision policy that preserves ambiguous equal-counter events, then attach redacted initial and repeat replay output before integrating the ledger into production totals. Do we have a high-confidence way to reproduce the issue? Yes, at source level: distinct observations in one lineage with the same complete token-counter tuple are treated as one admitted observation under the proposed identity contract. The PR head has not changed since this case was previously raised. Is this the best way to solve the issue? No in its current form. Lineage grouping is a plausible boundary, but deduplication must use stronger identity or preserve ambiguous events rather than treating matching token counters as proof of duplication. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0437067deaa8. Label changesLabel justifications:
Evidence reviewedWhat I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (1 earlier review cycle)
|
|
Superseded by the consolidated four-PR review stack. This slice is now included in #2155; closing this draft to keep the upstream review surface manageable. |
Stack position
This is slice 1 of 15 and the first isolated component of the planned scanner rearchitecture.
Summary
Adds a shadow lineage ledger that treats Codex rollout files as overlapping physical views of transitive session families. It admits each complete
(last_token_usage, total_token_usage)state once per lineage, keeps identical observations from unrelated lineages additive, and provides separate UTC and local-day projections.This is the first isolated component of a planned scanner rearchitecture tracked in Map: rearchitect Codex rollout token accounting around lineages. It deliberately does not change production scanner totals yet.
Why
Forked, sibling, archived, and long-lived Codex sessions can copy or re-emit token history across physical rollout files. A small lineage-focused component gives later PRs a testable accounting boundary before discovery, parsing, pricing, shadow comparison, and production promotion are migrated piecemeal.
An independent privacy-safe replay over active and archived local rollout data reproduced the investigated July 9–11 UTC lineage totals and collapsed 1.535 million physical snapshots to 204,547 admitted observations. The remaining gap to OpenAI totals is intentionally not hidden or guessed away; later mapped slices will classify it through shadow diagnostics.
Validation
swift test --filter CodexLineageLedgerTestsmake checkSDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.5.sdk make testKnown limits
Tracks Land the shadow lineage ledger foundation.
Related investigation: steipete/CodexBar#2037.