Repository navigation
Spend attribution 2026-09-29: count-only scan, ccusage-reconciled receipt, run-shape section and decision record - #500
Merged
Conversation
…eipt, run-shape section and decision record Adds evidence/artifacts/claude-spend-scan.py.txt (a portable count-only scan of Claude Code transcripts: one row per message.id with the per-field maximum, advisor iterations from usage.iterations, list-price cost by class and model, child length and agent-type mix, session-tree concentration, effort, context bins, cache misses and tool invocations, with a synthetic control that runs one mutant per counting rule), tests/test_claude_spend_scan.py, and the receipt claude-spend-attribution-20260929, whose token totals match ccusage 20.0.26 within 0.001% on a shared copy of the transcript tree. docs/token-practice.md gains a "Run shape and accounting" section and docs/decisions/2026-09-29-token-spend-attribution.md records the decisions (effort max and the advisor stay by the user's answers; the subagent cache TTL stays by the receipt's arithmetic), the practice status and the levers by owner. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…er the delta review The dollar breakdown counted claude-sonnet-5-5's unsplit cache writes twice. The receipt now reconciles dollars per model (data.reconciliation.cost_usd.by_model: Fable, Haiku and the scan agree with ccusage to the cent; the gap is claude-sonnet-5-5 unpriced by ccusage, claude-opus-4-8 priced only by ccusage and the unsplit writes of the other models, with a residual of about a dollar). The cache-creation limitation states both the field difference and the clamped remainder, the artifact's docstring no longer credits the merge rule to ccusage's loader, commands are recorded consistently with the snapshot directory, the session-view percentile method is stated, and the decision record words the advisor switch as an absence result and refers to #499 as merged. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
seathatflowsinourveins
force-pushed
the
claude/spend-attribution-20260929
branch
from
September 29, 2026 08:14
9d0ecb4 to
db3e218
Compare
seathatflowsinourveins
deleted the
claude/spend-attribution-20260929
branch
September 29, 2026 08:35
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.
Scope
evidence/artifacts/claude-spend-scan.py.txt) with a test that pins it to its receipt (tests/test_claude_spend_scan.py), a receipt from one run of it that is reconciled to ccusage 20.0.26 on a shared copy of the transcript tree (claude-spend-attribution-20260929), a "Run shape and accounting (2026-09-29)" section indocs/token-practice.md, and a decision record (docs/decisions/2026-09-29-token-spend-attribution.md) that gives each token-saving lever its owner and overturn condition. It changes no setting, hook, agent definition, carrier text or pin.bbc34acelane:foundation. Paths:docs/,evidence/,tests/andmanifests/evidence.json(a receipt index entry and hashes only, which the hot-file protocol indocs/lanes.mddoes not treat as a change to what the file says).docs/token-practice.md,docs/decisions/2026-09-29-token-spend-attribution.md(new),evidence/artifacts/claude-spend-scan.py.txt(new),evidence/receipts/claude-spend-attribution-20260929.json(new),tests/test_claude_spend_scan.py(new),manifests/evidence.json.SOTA sources
manifests/stack.json; v20.0.26 installed; v20.0.17 release notes: "claude: Count advisor model usage"): the counting oracle.ccusage claude daily --json --offlineandccusage claude session --json --offline, withCLAUDE_CONFIG_DIRpointing at a copy of the transcript tree, are the upstream commands the receipt is reconciled to.usagefields reflect executor tokens only." Advisor inference is therefore read fromusage.iterations[type=advisor_message]./clearbetween unrelated tasks: "Stale context wastes tokens on every subsequent message"), model configuration (max"may show diminishing returns and is prone to overthinking, so test before adopting it broadly"), prompt caching and advisor ("The advisor model's own read of the conversation is not cached").clear_thinking_20251015keep default: all turns on Opus 4.5+ and Sonnet 4.6+) and pricing (cache read 0.1x the input price, 0.05x on Opus 5.5; 5-minute write 1.25x, 1-hour write 2x).evidence/receipts/claude-advisor-usage-scan-20260928.json(a count-only transcript scan stored with a synthetic-fixture control) andexamples/claude-native/workflows/child-usage.mjs(transcriptUsage, the per-child counter that reads nousage.iterations).Evidence-class table
native_proven(both tools executed on this host; receipt retained)data.reconciliationanddata.commands(all exit 0) in the receiptsyntheticpython3 claude_spend_scan.py --control(data.control,passed: true, five mutants);tests/test_claude_spend_scan.py, 4 tests OK, including one that breaks a rule and expects the control to failmax82.2% of callsnative_proven(list-price proxy, one host, one window, no quality comparison)data.scannative_provendata.ccusage_session_viewsource_review(arithmetic ondata.scanand the documented price ratios)data.derived.subagent_cache_ttl;docs/token-practice.md"Cache" bulletsource_review(read back from repository files by a seven-agent Workflow with an independent refuter; no committed receipt)docs/decisions/2026-09-29-token-spend-attribution.mdLocal commands run
Decision record
docs/decisions/2026-09-29-token-spend-attribution.mdrecords the user's 2026-09-29 answers (effort staysmax, the advisor stays on, savings come from architecture) as their choices, not as measured results, and derives one decision (the subagent cache TTL) from the receipt. An independent review of the first draft found eight fix-level defects (cache-class attribution and the TTL arithmetic, a control with no failing run,--sincenot reaching the tool counters, an unreproducible reconciliation, unattributed decision wording and a few figures); the first repair fixed them, and a delta review of that repair found one more error, a double count of unsplit cache writes in the dollar breakdown, which this head fixes with a per-model dollar reconciliation (data.reconciliation.cost_usd.by_model) plus seven wording notes. Residuals recorded rather than fixed: the miss bins are approximate (see the receipt's limitations), the unsplit cache remainder's class is unknown, and the external documentation quotes were not re-fetched by the reviewer (they were read by the Workflow's research stages on 2026-09-29). Levers owned elsewhere:flag(Gate A PR-H: E2E preregistration for the token-save-practice stack (frozen tasks, metrics, gate, procedure) #381, ownernative-agent-stack-2d):maxTurnson the six uncapped role agents,omitClaudeMdstarting withlandscape-sweep-worker, a query limit perctx_batch_execute, the serena ids in the carrier's mandatory select (694 loads against 28 calls), per-agentexperimental.cacheTtl, and anybashOutputMaxCharschange. None is touched here; each waits for the owner.flag(compaction window, Compaction-window A/B/C preregistration draft (not frozen, not run) #416): left native.flag(repository, queued): count advisor iterations inchild-usage.mjs(agent-lab first, then re-vendored),--max-budget-usdat headless call sites (one headless probe on 2.1.284,local_integrationand not receipted:error_max_budget_usdwithterminal_reason: budget_exhaustedat $0.000001,successat $1, on a subscription account), a spend-rate rule beside the existing counter alerts.Host evidence
Not applicable (no
evidence/hosts/files). The receipt is a measurement of one workstation's own transcripts; a new host runs the same scan and collects its own.Checklist
permissions: contents: read(none changed).🤖 Generated with Claude Code