Repository navigation
feat(telemetry): a prompt is an axis, and the only one complete by construction - #757
Merged
Merged
Conversation
…nstruction Every breakdown the report carries can read low for a reason about the capture rather than about the work: a skill the host never named, a run journal that was never written, an identity nobody declared. `by_prompt` groups on `prompt_id`, which the transcript reader already resolves for every usage line it stores by walking each file's own `parentUuid` chain back to the turn that caused the work. Measured on the built binary against a sandboxed copy of one real session: 1073 of 1073 records carry a `prompt_id`, its 972 subagent records included, across 12 distinct prompts. The axis reconciles to the same total as every other breakdown with nothing left in a remainder, on the same session where the step axis cannot name 96% of the tokens. A row carries `started_at`, the earliest moment measured inside that prompt, because an id alone is opaque and the moment is what a person greps for in their own transcript. The row for records that named no prompt carries neither field, and is placed last rather than ranked among the prompts: a bucket drawn from many turns has no size comparable to a single turn's. The text rendering prints the ten largest and says how many it withheld, since this is the first axis whose cardinality is unbounded; the envelope always carries them all. Envelope 12 -> 13, every consumer updated in this commit. Two gaps closed on the way. The skill's `--axis` enumeration and its question table both omitted `agent`, which had shipped two versions earlier, so a person asking which subagent spent the tokens was told the question had no axis while the binary had been answering it. A guard now reads `ARTEFACT_AXES` from the module itself and asserts the two lists are equal in both directions. And the e2e that runs every command the skill names held its own copy of the axis list in a placeholder regex, so a skill could not name a new axis without that regex being edited in the same breath; it now expands any `<a|b|c>` by its shape. Bundle 588.4 -> 590.6 KB, budget raised 590 -> 593 with the measurement recorded beside it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01VWNxk63AGKkqE8HRqHLjGp
The axis guard added with `by_prompt` matched the question table with a `\n\n` terminator, which finds nothing in a checkout whose endings are CRLF - so a suite green everywhere else failed on Windows alone, naming the first axis it looked for. Measured: the same regex returns true on the POSIX file and false on the identical file with CRLF. The reader normalizes now, once, for every string assertion in this file rather than only for the one that caught it. Its guard writes a CRLF file to disk and reads it back through that reader, so a normalization removed from the reader fails - a string normalized inside the assertion would have passed however the reader behaved. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01VWNxk63AGKkqE8HRqHLjGp
Merged
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
Adds
by_promptto the cost report: one row per prompt that caused work, dated by the earliest moment measured inside it, plus one row for records that named none.Why this one
Every other breakdown can read low for a reason about the capture rather than about the work — a skill the host never named, a run journal that was never written, an identity nobody declared. This one groups on
prompt_id, which the transcript reader already resolves for every usage line it stores by walking each file's ownparentUuidchain back to the turn that caused the work. Nothing new is captured for it.Measured, on the built binary
Sandboxed copy of one real session (
HOMEandAIDD_TELEMETRY_DIRboth under a scratch directory):1073 of 1073 records carry a
prompt_id, its 972 subagent records included, across 12 distinct prompts. The axis reconciles to the same total as every other breakdown with nothing in a remainder — on the same session where the step axis cannot name 96% of the tokens.Decisions
SymbolNO_AGENTandNO_KNOWN_MODELstarted_atby_flowplaces its own remainder the same way--jsonby_daysuppresses every row above its cap because a partial series is a lie about continuity; a partial ranking is not, and it says how many it withheld. The envelope carries them allEnvelope 12 → 13
A new top-level breakdown, so a consumer summing every breakdown's
requestsagainsttotals.requestshas one more to include. Every consumer updated in this commit: the contract document, the cost skill's own pinned version and axis lists, the envelope fixture, and the two e2e version pins.Two gaps closed on the way
--axisenumeration and its question table both omittedagent, which had shipped two versions earlier — a person asking which subagent spent the tokens was told the question had no axis while the binary had been answering it. A guard now readsARTEFACT_AXESfrom the module itself and asserts the two lists are equal, in both directions.<a|b|c>by its shape.Cost
Bundle 588.4 → 590.6 KB. Budget raised 590 → 593, with the measurement recorded beside the previous raises.
Gates
cd cli && pnpm test— 305 files, 3396 tests, green (build included)node --test "scripts/__tests__/**/*.test.js"— 366 passpnpm knip:production,pnpm jscpd,npx biome ci,npx tsc --noEmit— green🤖 Generated with Claude Code
https://claude.ai/code/session_01VWNxk63AGKkqE8HRqHLjGp