Skip to content

Token report: say what the RTK and Headroom counters actually count (client-visible RTK view, Headroom ledger presence) - #282

Merged
seathatflowsinourveins merged 5 commits into
mainfrom
claude/token-report-counter-semantics-20260925
Sep 25, 2026
Merged

seathatflowsinourveins merged 5 commits into
mainfrom
claude/token-report-counter-semantics-20260925

Conversation

@seathatflowsinourveins

@seathatflowsinourveins seathatflowsinourveins commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Scope

  • What this PR changes: the portable token report now says what the RTK and Headroom counters actually count, in the manifest's JSON and HTML. The semantics come from the independently reviewed host receipts in Lifetime token-counter receipts on the WSL authoring laptop, with what each counter actually counts #270.
    • RTK: when rtk_database is configured, the global snapshot gets a client_visible view.
      • It re-counts every retained row as a client first shows the output: whole up to 30,000 characters, otherwise a 2,000-character preview. These are Claude Code 2.1.282's bashOutputMaxChars default and saved-output preview (Rwe), overridable with client_inline_chars and client_preview_chars.
      • It reports the top-10 share and the net, and the boundary text says so.
      • It is a model: later reads of saved files are not counted, and Codex has its own limits.
    • Headroom: ledger_present comes from the path the report itself prints. An absent ledger is labelled instead of being read as a measured zero.
    • Static text: the coverage-matrix boundaries and the README say the same, including Context Mode's lifetime = retained events × 256.
  • Base commit: f5812d3f (origin/main, rebased)
  • Lane: lane:foundation
  • Owned paths touched: tools/token-report/token_manifest.py, test_token_manifest.py, README.md and token_manifest.full.html.in. The RTK card now shows the client-visible net and the boundary; the Headroom card marks an absent ledger; the hot file manifests/evidence.json, re-registered in the last commit.

Evidence-class table

Claim Evidence class Command / receipt
RTK rows are uncapped ceil(bytes/4) of raw minus filtered output source_review + native_proven estimate_tokens/track at v0.49.0; receipt wsl-authoring-20260923--rtk--use--20260925-2 (#270)
Claude Code shows up to 30,000 characters inline, otherwise a preview of at most 2,000 source_review (installed 2.1.282 binary) Same receipt, command 5; y2e(g, Rwe) with Rwe=2000
An absent Headroom ledger also reads as zero native_proven wsl-authoring-20260923--headroom--use--20260925-2 (#270)
The new view reproduces the receipt's model on real data local_integration rtk_client_visible(~/.local/share/rtk/history.db): 80,726 rows, top-10 74.3%, net 8,936,430 (1.20%)
The new tests exercise the change synthetic Both new tests error on origin/main's reporter (AttributeError: … rtk_client_visible) and pass with this change

Independent review

An evidence-reviewer (Opus 5.5 at max) reviewed three rounds.

  • Round 1: needs_changes. Findings:
    • the floor at zero was missing;
    • the Headroom relative path;
    • view errors failed the counter;
    • the model assumptions were missing;
    • there was no database cross-check;
    • the tests had gaps;
    • the template showed none of it.
  • Round 2: needs_changes. The component-table wording, and "by default" appearing with overridden limits.
  • Round 3: agree.

Its two non-blocking notes are also applied: a precise code comment, and a test that pins the 1% threshold. Seven targeted mutations are killed by the tests.

A real-host refresh with the revised code, against a copy of this host's report config with outputs redirected, exited 0 with no issues:

  • rtk-global: 742,550,141, with client_visible net 8,985,531 (1.21%), 80,978 rows and top-10 74.3%;
  • Headroom: ledger_present: false, with the absent note;
  • the HTML rendered with no placeholder left.

Local commands run

$ python3 -m unittest discover -s tools/token-report -p test_token_manifest.py
Ran 55 tests ... OK
$ python3 -m unittest tests.test_native_token_ci tests.test_ecosystem_manifest
OK
$ python3 scripts/validate.py
{"components": 69, "hashed_files": 5612, "profiles": 4, "receipts": 147, "status": "passed"}
$ python3 scripts/component_matrix.py --check; python3 scripts/new_host_grand_list.py --check
checked; passed
$ gitleaks git --log-opts="origin/main..HEAD" --redact .   (guarded ecosystem wrapper)
no leaks found

Checklist

  • No workflows changed, no secrets, and no billing surface.
  • The reporter still installs nothing and runs no new upstream command. It reads the already-configured RTK database read-only.

🤖 Generated with Claude Code

@seathatflowsinourveins seathatflowsinourveins added the lane:foundation Foundation lane: Claude/Codex setup, hosts, memory, RAG, research, workers label Sep 25, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

- RTK: when rtk_database is configured, the global snapshot adds a
  client_visible view. It re-counts each retained row as a client first
  shows the output: whole up to 30,000 characters, otherwise a
  2,000-character preview (Claude Code 2.1.282 defaults, overridable).
  It reports the top-10 share and the net, and the boundary text says so.
  The view is a model: it excludes later reads of saved files, and Codex
  has its own limits.
- Headroom: record ledger_present from the path the report itself names.
  An absent ledger is labelled rather than read as a measured zero.
- Coverage-matrix boundaries and the README say the same, including
  Context Mode's lifetime = retained events x 256.

Evidence: the independently reviewed host receipts in #270.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
- RTK: state the floor at zero (max(0, raw - filtered)) and why the
  signed client view differs from it.
  - Name the Claude Code 2.1.282 defaults and list the model's
    assumptions: ASCII, preview at most, wrapper text and saved-file
    reads not counted, script rows included.
  - Validate the client limits (inline 4000-128000).
  - Report shares as n/a on a zero total.
  - Omit the view with an issue when the configured database holds fewer
    rows than rtk gain reported.
  - View problems (sqlite, value, type, OS) are the view's own issues and
    no longer fail the rtk gain counter.
- Headroom: use only the path the report names, resolve a relative path
  from the configured project (Headroom's working directory), and label
  an absent ledger only when the reading is zero.
- HTML: the RTK card shows the client-visible net and the reporter's
  boundary; the Headroom card marks an absent ledger and shows its
  boundary.
- Tests pin the inline limit (<=), ceil, the top-ten ranking, zero
  totals, overrides, the mismatch and error paths, the Headroom path
  branches and connection closing. Seven targeted mutations are killed.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@seathatflowsinourveins
seathatflowsinourveins force-pushed the claude/token-report-counter-semantics-20260925 branch from 743611a to 6c6d2b4 Compare September 25, 2026 20:25
- The component-table RTK boundary states max(0, raw - filtered).
- The boundary says "by default" only when both client limits are the
  Claude Code 2.1.282 defaults, and the preview must stay below the
  inline limit.
- The row cross-check allows 1% fewer rows than rtk gain counted, for
  retention pruning between the two reads.
- Tests cover the configured-limits wording, the preview limit and the
  pruning tolerance. A real-host refresh with the revised code exited 0
  with no issues and a client_visible block.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@seathatflowsinourveins
seathatflowsinourveins force-pushed the claude/token-report-counter-semantics-20260925 branch from 6c6d2b4 to 3d8afbb Compare September 25, 2026 20:41
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@seathatflowsinourveins
seathatflowsinourveins force-pushed the claude/token-report-counter-semantics-20260925 branch from 3d8afbb to ebb74b0 Compare September 25, 2026 20:43
@seathatflowsinourveins
seathatflowsinourveins enabled auto-merge (squash) September 25, 2026 20:43
@seathatflowsinourveins
seathatflowsinourveins merged commit c7dbcb5 into main Sep 25, 2026
23 checks passed
@seathatflowsinourveins
seathatflowsinourveins deleted the claude/token-report-counter-semantics-20260925 branch September 25, 2026 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lane:foundation Foundation lane: Claude/Codex setup, hosts, memory, RAG, research, workers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant