Feature/Fix: Add a shadow lineage ledger for Codex token accounting#24
Open
iam-brain wants to merge 1 commit into
Open
Feature/Fix: Add a shadow lineage ledger for Codex token accounting#24iam-brain wants to merge 1 commit into
iam-brain wants to merge 1 commit into
Conversation
This was referenced Jul 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.