fix(statistics): clamp delegated counts, exact task cost, monotonic ordering - #32
Open
efirvida wants to merge 3 commits into
Conversation
…cost CodeRabbit review response: - accumulateTaskCost keeps each step on the integer nano-USD grid, so repeated nine-decimal deltas no longer drift (agents-runner's cost assertion updated from 0.30000000000000004 to the exact 0.3). - The publisher clamps the delegated event's diagnostic counts to the payload bound, so a session with more than 4096 retained tasks still publishes instead of silently dropping the total. - The shell ignores an out-of-order delegated event (older at) so a stale publish can never replace a newer total. - Added docstrings across the touched usage/delegated seams.
The ordering guard compared payload.at (Date.now()), so a backward wall-clock adjustment could make a newer total look stale. The publisher now stamps each event with a monotonic seq and the shell orders by it; at stays diagnostic only. Tests updated.
A transcript reports cost split by input, output, cacheRead and cacheWrite, and a billing report needs that split without re-deriving it. Add `UsageCostBreakdown` as an optional, additive field on the canonical `SessionUsageRecord`; each component carries its own reported/absent provenance exactly as the total already does, so an absent component is never read as a reported zero. I3 (issue #3), part of the session statistics epic (#1).
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-03-delegated-cost-transportupstream/statistics-03-delegated-cost-transportChain Overview
Scope
upstream/statistics-03-delegated-cost-transportis 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.