fix(dashboard): summarise the whole window, not its newest bucket - #140
Merged
Merged
Conversation
With nothing hovered the earnings panel fell back to `points.length - 1`, so a 24-hour window described its most recent hour. On this node that meant a heading reading "$0.1104 in this window" above a breakdown listing two models, while six had earned over the day — the four missing ones had simply been idle for the last hour. The panel now sums every interval in the window by default and says which window it is describing; hovering a bar still shows that one interval, and the hint says so. Fixing the display surfaced a second defect underneath it. The per-model split is rescaled onto the bucket total only when the total came from the platform's ledger. A local bucket got no such treatment, so when the per-model deltas outran the aggregate delta — a restart, or a model removed mid-interval — the excess was left in place and only `unattributed` was clamped to zero. Summing a single bucket hid it; summing a window does not: one daily bucket here drew $2.30 of model segments inside a $1.64 bar. The rescale now also applies whenever a local split exceeds its own total, so the segments sum to the bar in both cases. Covered by a test that reproduces the disagreement and fails without the change.
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.
The reported problem
The 24-hour window showed the models from the last hour, not the last 24
hours. With nothing hovered the panel fell back to the newest bucket:
So the heading said "$0.1104 in this window" and the breakdown under it
described one hour of it. On this node six models earned over the day and only
two in the final hour, so four were missing from a panel that looked like it
described the day.
The panel now sums every interval in the window by default and labels itself
with the window it is showing. Hovering a bar still isolates that interval, and
the header says so rather than leaving it to be discovered.
The defect this uncovered
Summing the window made the segments disagree with the total. The per-model
split is rescaled onto the bucket total only when that total came from the
platform's ledger; a locally-priced bucket was left alone. But
usddifferences the aggregate counter while the split differences each model's own
counter, and the two can disagree — a restart, or a model removed
mid-interval, leaves the per-model deltas summing above the aggregate one.
unattributedwas clamped at zero, which hid the excess without removing it.Looking at one bucket at a time concealed this. Looking at a window does not:
$2.30 of model segments drawn inside a $1.64 bar. The rescale now applies
whenever a split exceeds its own total, whichever produced that total.
Verification
Against this node's live data, the panel total now equals the header total for
every window, which it did not before:
The new test builds the counter disagreement directly and fails without the
backend change: