Skip to content

fix(dashboard): summarise the whole window, not its newest bucket - #140

Merged
flyworker merged 1 commit into
mainfrom
fix/earnings-window-summary
Sep 7, 2026
Merged

flyworker merged 1 commit into
mainfrom
fix/earnings-window-summary

Conversation

@flyworker

Copy link
Copy Markdown
Member

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:

const activeIndex = hovered ?? (points.length > 0 ? points.length - 1 : null);

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 usd
differences 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.
unattributed was 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:

2026-09-04   usd=1.6396   models=2.3023   unattributed=0.5782

$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:

window header segments now sum to
24h $0.1105 $0.1105
7d $19.1700 $19.1700
30d $32.5816 $32.5816

The new test builds the counter disagreement directly and fails without the
backend change:

models 3.000000 + unattributed 0.000000 exceeds the bucket total 1.000000

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.
@flyworker
flyworker merged commit 0d08819 into main Sep 7, 2026
1 check passed
@flyworker
flyworker deleted the fix/earnings-window-summary branch September 7, 2026 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant