# Claude usage reconciliation proof

Target: [#20276](https://github.com/pingdotgg/t3code/pull/20276), head [48084a4](https://github.com/pingdotgg/t3code/commit/48084a474147c75fd1f9922a2453730d4d498be3), base [f5c1142](https://github.com/pingdotgg/t3code/commit/f5c1142d2426d314a3399a9862bdbf347ff9920d).

## Focused automated proof

Current implementation counts merged keyed records once in finish(), preserving repeated snapshots and ordinary accumulation for unkeyed records. Signed retraction and category-presence bookkeeping were removed. A scratch differential probe compared 18,000 random day/hour sequences and 107,310 snapshots with zero mismatches at 1e-9; this is numerical evidence, not a performance benchmark.

Fresh test reduction: 146 passing tests across nine suites became 138 across the same nine suites. The three changed test files retain 78 cases versus 86 in the submitted PR; 74 already existed on main. Four new behavioral cases replace twelve additions. They cover the partial/final-copy lifecycle, unterminated-tail replacement and restart, cross-file maxima in either order with first-copy attribution, pricing/category transitions, and v5 live-file reparsing with deleted history retained. Existing baseline cases remain.

Reverting production to main gives six failures: four behavior regressions and two artifacts from the absent v6 cache filename. Separately disabling the legacy invalidation guard gives output 10 instead of 271, proving migration behavior independently of filename changes. Source restoration hashes match. Current implementation: 138/138 focused tests in nine suites, scoped format/lint pass (one existing unused layerTest warning), server typecheck zero errors/warnings. No repository-wide checks were run.

## Running server and web client

On head 48084a4, an isolated Linux development server used disposable Claude transcript files and explicit synthetic pricing. Its real server.getUsageSummary RPC first scanned two messages: output 3 and 7, total 10. This is a partial-input baseline on the same head, not an execution of main.

With the server stopped, a final copy of the first message (output 264) was appended as an unterminated tail, the second transcript was deleted, and the saved cache was represented as version 5. After restarting the actual server:

| Observable | Partial input | Migrated complete input |
| --- | ---: | ---: |
| Records | 2 | 2 |
| Output tokens | 10 | 271 |
| Uncached input | 4 | 4 |
| Cache read | 135868 | 135868 |
| Cache write | 2194 | 2194 |
| Estimated cost USD | 0.163833 | 0.176883 |
| Cache savings USD | 1.222812 | 1.222812 |

The cost difference is exactly the 261 recovered output tokens at the configured synthetic rate: USD 0.01305. The new version-6 cache exists; SHA-256 confirms version-5 bytes are unchanged. Output 271 includes all 264 live tokens and the seven cached tokens from the deleted transcript.

The actual web Usage page, with other-provider data filtered out, exposes Output 271, Input 4, Cache read 136K, Cache write 2.19K, one Claude session and estimated cost $0.18 in its accessibility tree. The screenshot was captured and inspected: text glyphs are absent across this VM's preview, so it is unusable and intentionally omitted. No visual layout changed. The isolated server was stopped after verification.

## Limits

No authenticated Claude SDK call, real-corpus performance/RSS benchmark, macOS, Windows, Electron desktop, iOS or Android execution was performed. Tests cover accounting states beyond the live fixture. First-copy metadata and speed stay authoritative. Deleted old transcripts retain only what their legacy cache saved; unavailable final copies cannot be recovered. Upgrade reparses live legacy files once. Semantic corruption of otherwise parseable cache JSON is not claimed to recover deleted history. Human review of metering/cost policy and cache migration remains required; this proof grants no merge approval.

Original implementation by @rfrost-xyz; maintainer takeover preserved contributor history. Test agent GPT-6 Astra; implementation GPT-6.1 Sol; independent whole-PR reviews GPT-6 Sol and Claude Opus 5.5, coordinated through T3 Code. Review/CI completion is recorded in the PR body.
