Repository navigation
refactor(telemetry): simplest, deterministic, true - #1054
Merged
Merged
Conversation
A call whose transcript record carries no requestId is no longer stored. It is counted in left_out under its own reason, requestless, hashed by tool, message id and session. One predicate applies where a call enters: at ingest, and at every ledger read, so a line an earlier or an older CLI stored leaves the ledger at the next write of its day and is counted then. Measured again: 0 requestless usage lines of 265,472 (Claude Code 2.1.232 to 2.1.302), after 0 of 512,820 before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VWNxk63AGKkqE8HRqHLjGp
No call without a request id is stored any more, so the ledger no longer needs to read every day for one, re-key cli-v5.5.0's timestamped keys, or state a limit for the copies an older CLI writes after the migration. The window property holds with no exemption. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VWNxk63AGKkqE8HRqHLjGp
The guard no longer parses arrays of session ids across lines: no cap, no offset-to-line search, no sort. Every path pattern, the dash slug, the session key, the session-file name, the placeholder-id rule and the allowlist stay. Multi-line structures are not parsed, as its header says. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VWNxk63AGKkqE8HRqHLjGp
Merged into the test-first rule rather than added beside it: an input never observed is stated as a limit, a review finding about one is closed by that limit, and of two fixes the one that deletes wins. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VWNxk63AGKkqE8HRqHLjGp
The ledger read drops such a call too, so only the ingest result and the bytes right after an ingest tell the two apart: a mutant skipping the ingest check survived every other test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VWNxk63AGKkqE8HRqHLjGp
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VWNxk63AGKkqE8HRqHLjGp
…ounted Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VWNxk63AGKkqE8HRqHLjGp
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VWNxk63AGKkqE8HRqHLjGp
Only transcripts and the migration's one pass over the ledger add to left_out.requestless, so the count no longer depends on the days a report reads. A line an older CLI writes after the migration is a line this version does not accept: kept as found, counted in skipped_ledger_lines. The window property compares the figures of the envelope, run excluded, with requestless lines in its generator and no exemption. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VWNxk63AGKkqE8HRqHLjGp
…ision Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VWNxk63AGKkqE8HRqHLjGp
…nts the review named Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VWNxk63AGKkqE8HRqHLjGp
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.
🎯 What & why
Simplifies the R1 telemetry code under one rule: the simplest design that stays deterministic and true. A Claude Code call with no
requestId(0 of 265,472 usage lines measured, Claude Code 2.1.232 to 2.1.302; 0 of 512,820 before) is no longer stored. It is counted incoverage.left_out.requestless, so the code that kept such calls folded across days is deleted. The local-path guard becomes line-based. The process rule is written once.🛠️ How it works
isRequestless(claude-transcript-usage.ts): a Claude Code key naming its own session, as this version (msg:session) or cli-v5.5.0 (msg:session:time) wrote it.left-out.txtbefore its rewrite (stored-usage-migration.ts).parseStoredUsagedoes not accept such a line. One an older CLI writes after the migration is kept as found and counted inrun.skipped_ledger_lines, like any line this version does not accept. It is not a figure, soleft_outnever depends on the days a report reads.isKeyedBySession, the full-ledger read instoreCalls,legacy-usage-key.ts(re-keying), the window's second bound, the older-CLI limit rows, the window property's exemption, the tests that existed only for them.Lines: +383 / −412, net −29; without the task folder, +279 / −412, net −133. Bundle: 716,561 → 717,130 bytes (+569).
🧪 How to verify
cd cli && npx vitest run tests/contexts/telemetry/application/report/report-window.property.integration.test.ts: a bounded report's figures (totals, rows, coverage) equal the full ledger's filtered, requestless and timestamped lines in the generator, no exemption.cd cli && npx vitest run tests/contexts/telemetry/application/legacy/stored-usage-migration.property.integration.test.ts: a migrated store equals one fresh ingest byte for byte,left-out.txtincluded.node scripts/check-no-local-paths.js --all: 0.coverage.left_outgainsrequestless, an addition allowed in envelope v2.usage-ledger-adapter.ts:90, the re-id unsettled mark, reachable only by an older CLI writing earlier ids after the upgrade.🔗 Linked issue
None. Follows the R1 telemetry audit: simplest, deterministic, true.
✅ I certify
🤖 Generated with Claude Code
https://claude.ai/code/session_01VWNxk63AGKkqE8HRqHLjGp