Skip to content

πŸ› fix(dashboard): report the count window separately from the freshness window - #4878

Merged
clubanderson merged 1 commit into
v4from
fix/4860-activity-window-labels
Aug 27, 2026
Merged

πŸ› fix(dashboard): report the count window separately from the freshness window#4878
clubanderson merged 1 commit into
v4from
fix/4860-activity-window-labels

Conversation

@clubanderson

Copy link
Copy Markdown
Member

GET /api/repo-activity advertised window_hours: 12 while the per-repo counts were accumulated over 14 days:

Value Source
Counts accumulated over activityWindow = 336h activity_collector.go:214
Window advertised activityHealthWindowHours = 12 activity_collector.go:289

Any consumer treating Count as "output within window_hours" β€” an events-per-hour rate, most obviously β€” overstates activity by 28Γ—.

Both values are legitimate; reporting one for both questions was the bug

The wide accumulation window is deliberate and documented: the hub computes freshness itself from NewestAt, and a slightly-late collect must not drop a just-inside-12h event. So this adds count_window_hours alongside window_hours rather than redefining either.

The hub's health verdict already recomputes recency from NewestAt and owns its own 12h constant (health_verdict.go:33-35), so it was never misled and its semantics are untouched. No clamp change was needed β€” sanitizeRepoActivity already tolerates 720h.

What's included

  • CountWindowHours on ActivitySnapshot, populated from activityWindow
  • Carried through the heartbeat (repo_activity_count_window_hours) and the hub registry, so hub-side consumers get the same disambiguation
  • Stated in the endpoint's own limitations strings β€” a caller reading the JSON shouldn't have to find this commit
  • A test pinning the two apart: equal values fail, and a count window narrower than the freshness window fails, since that would let a "fresh" event fall outside the counted range

Why this is worth fixing now rather than later

Phase 1 of the per-repo cost epic (#4836) produces these counts, and Phase 3 attaches spend to them. At that point a 28Γ— mislabel stops being a wrong dashboard number and becomes a wrong budget figure. It also directly contradicted that epic's own stated rule that the attribution window must be reported alongside the number.

One correction to the reported scope

While adding a retention caveat I initially wrote that the audit log's rotated backups are not read. That is no longer true β€” OutputActionsSince reads rotated and compressed .gz backups (with a gzip-bomb cap, hardened in #4863). The limitation now states the accurate constraint: backups are read, but only MaxBackups are kept, so a busy hive's effective lookback can still be shorter than the nominal count window.

Fixes #4860

…ss window

/api/repo-activity advertised window_hours: 12 while the per-repo counts were
accumulated over 14 days (activity_collector.go:214 uses activityWindow = 336h;
:289 labelled the snapshot with activityHealthWindowHours = 12). Any consumer
treating Count as "output within window_hours" β€” an events-per-hour rate, most
obviously β€” overstates activity by 28x.

Both values are legitimate and both are needed. The wide accumulation window is
deliberate: the hub computes freshness itself from NewestAt, and a slightly-late
collect must not drop a just-inside-12h event. The bug was reporting one number
for two different questions.

Adds count_window_hours alongside the existing window_hours rather than
changing what window_hours means. The hub's health verdict already recomputes
recency from NewestAt and owns its own 12h constant, so it was never misled and
its semantics are untouched β€” no clamp change needed either, the sanitizer
already tolerates 720h.

Carried through the heartbeat and hub registry so hub-side consumers get the
same disambiguation, and stated in the endpoint's own limitations strings,
because a caller reading the JSON should not have to find this commit.

A test pins the two windows apart: equal values fail, and a count window
narrower than the freshness window fails, since that would let a "fresh" event
fall outside the counted range.

This matters beyond the cosmetic. Phase 1 of the per-repo cost epic (#4836)
produces these counts, and Phase 3 attaches spend to them β€” at which point a
28x mislabel stops being a wrong dashboard number and becomes a wrong budget
figure. It also contradicted that epic's own stated rule that the window must
be reported alongside the number.

While here, the limitations now state that counts are bounded by audit-log
retention: rotated and compressed backups ARE read, but only MaxBackups are
kept, so a busy hive's effective lookback can be shorter than the nominal
count window.

Fixes #4860

Signed-off-by: Andy Anderson <andy@clubanderson.com>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Aug 27, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign clubanderson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@github-actions

Copy link
Copy Markdown
Contributor

Changelog: this PR changes code but does not touch CHANGELOG.md.

If it is user-visible β€” a feature, a fix an operator would notice, a
security change, a migration, a deprecation, or anything breaking β€”
please add a line under ## Unreleased. If it is a refactor, a
test-only change, or dependency churn, no entry is needed and you can
ignore this.

This is a reminder, not a gate; it never blocks a merge.

@kubestellar-prow kubestellar-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 27, 2026
@clubanderson
clubanderson merged commit 7a349f6 into v4 Aug 27, 2026
39 of 40 checks passed
@clubanderson
clubanderson deleted the fix/4860-activity-window-labels branch August 27, 2026 12:47
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

Check out what's new:

Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[scanner] /api/repo-activity reports window_hours:12 for counts computed over a 14-day window

1 participant