fix(statistics): stop coercing unreported tokens to a measured zero - #55
Open
efirvida wants to merge 1 commit into
Conversation
The no-coercion rule that cost already satisfies never reached tokens: a usage payload with an empty or partial counter set summed to 0 and the aggregate reported that figure as measured. Measured evidence on a real profile: 163 of 163 subagent records on one provider family carry tokens 0, indistinguishable from a reported zero. Carry the same availability state cost uses, one layer at a time: - SessionUsageRecord gains `tokensComplete`; absent means complete for a legacy record, a reported all-zero set stays complete. - parseTranscriptLine reads each counter through a finite reader and records a missing counter instead of inventing a measured zero. A stored line states the flag explicitly so an incomplete record survives the round trip; the task dir scan is unchanged. - The aggregate folds that state the way it folds cost: one absent record makes the token figure partial for good, and every breakdown inherits it. - UsageEvent carries `tokensComplete` and TaskRecord accumulates it with `accumulateTaskTokens`, the exact counterpart of `accumulateTaskCost`. An all-zero or empty usage is "not reported", matching childTokens: the SDK injects zeros, so zero is not presence evidence. - The panel marks a partial token figure with the `+` the legend already documents, and the contract states the rule. Where a counter is missing the sum remains the known lower bound; it is the provenance flag that keeps it honest. Verified: 68 focused tests and 259 affected-suite tests green, typecheck at the 187-diagnostic baseline with no regressions.
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.
Chain Context
upstream/statistics-tracker→ upstream integration PR Gentleman-Programming#1627 (draft)upstream/statistics-26-billable-bounded-collectionupstream/statistics-26-billable-bounded-collectionChain Overview
Scope
upstream/statistics-26-billable-bounded-collectionis a branching bug, not a scope surprise.Verification
Focused and affected suites are green on this slice; tests and docs for this unit ship with it.