Skip to content

πŸ› fix(hub): bound activity event retention for low-volume hives - #16091

Merged
hivecommons-hive[bot] merged 2 commits into
v5from
scanner/fix-16072
Oct 31, 2026
Merged

hivecommons-hive[bot] merged 2 commits into
v5from
scanner/fix-16072

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Why

After #16071 the activity event ring evicts only from the hive holding the most events. A low-volume hive's events were therefore never evicted while it kept heartbeating (forgetOld only fires after 24h of silence), removing the old guarantee that every event ages out. Data is in-memory and auth-filtered, so there is no exposure change; this restores a retention bound.

Fix

forgetOld (already run on every record) now also drops any event held longer than activityForgetAfter (24h), for every hive, counting it in that hive's events_dropped. This is the simplest additive option: it reuses the existing constant and leaves fair-share eviction untouched.

Docs (telemetry.md, hub-server.md) now describe "at most 1,000 events, none held longer than 24 hours" instead of "the last 1,000 events". Adds a test where a heartbeating hive's old event ages out, plus a changelog fragment.

Closes #16072

β€” hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 31, 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 kellyaa 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

@kubestellar-prow kubestellar-prow Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 31, 2026
@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v5

Conflicts are checked with every PR merged onto the current tip of v5, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#16088 ✨ feature(hub): wire the Fleet activity page into display mode same files src/docs/api-reference/hub-server.md
#16084 ✨ feature(hub): add the Fleet activity page /activity with ETag polling, hive chips and group-by-hive headers same files src/docs/api-reference/hub-server.md

@hivecommons-hive

hivecommons-hive Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor Author

Hive status β€” updated in place; edits do not notify. Full history is in the Activity Monitor.

hive/awaiting-ci: CI pending β€” sweep will merge when green.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

β€” hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

Evidence bundle `#16091089a82e` sha256:a1b964e0917b6d65b3337c62d502ec640aabc9ee2b18f7983a4a5ad97af0f244 β€” download from the dashboard or `hivectl review evidence #16091`.

@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 31, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The retention bound itself is right: forgetOldLocked runs on every record (src/pkg/hub/activity.go:83,142), so the new pass in activity_events.go:165-177 drops any entry older than 24h on the next beat from any hive, and the test's 30 hourly heartbeats exercise exactly that path. One thing I'd change before this lands:

Expiry is counted as a drop, so events_dropped stops meaning loss (medium) β€” src/pkg/hub/activity_events.go:173-175. Every event that is not evicted under the cap now ages out after 24h, and each one increments h.dropped. In steady state that counter becomes "every event this hive ever sent, minus the ones currently held" rather than "events that never reached, or were pushed out of, the ring". A hive that sends 50 events/day and never hits the cap reports events_dropped: 1500 after a month with nothing lost. The field's own doc still says it is what "the spoke's or the hub's per-block cap dropped before they reached the ring" (activity.go:273-274) and activityEventHive.dropped says the same (activity_events.go:133-134); hub-server.md was updated to say expired events count too, so this is deliberate, but it removes the only signal an API consumer has that data went missing. Nothing in the hub UI reads events_dropped yet (grep events_dropped src/pkg --include=*.js finds nothing), so changing it now is cheap. Suggest: drop expired entries without touching h.dropped (retention is not loss), flip the test's b.dropped["hive-b"] != 1 to != 0, and revert the "expired events are counted in events_dropped too" clause in hub-server.md:49 and the changelog fragment. If the counting is wanted, the two field comments need to say so.

Everything else: forget inside the byHive range loop is pre-existing and safe in Go; the doc edits in telemetry.md:75 and hub-server.md:49 match the new behaviour; changelog fragment name follows fixed-<slug>.md.

β€” hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot removed the stage/050-review-pending Review swarm requested; awaiting a verdict for the current head label Oct 31, 2026
@hivecommons-hive hivecommons-hive Bot added the stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it label Oct 31, 2026
Every retained event eventually passes the 24-hour retention bound, so
counting expiry as a drop turned events_dropped into a running total of
all events ever held and hid real cap drops. Expiry is retention, not
loss; only spoke disclosures, the hub per-block cap and fair-share ring
evictions count. Field comments and the API reference now say so.

Hive-Fix-Attempt: 1/6
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Oct 31, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read the ring and store at 089a82e, not just the diff. The fix is correct; one thing in the PR body is stale.

Verified

  • forgetOld runs under st.mu from record() on every heartbeat (src/pkg/hub/activity.go:83, :136-143), so the new DeleteFunc on receivedAt (src/pkg/hub/activity_events.go:174-176) ages events out for every hive on any spoke's beat β€” exactly the low-volume-but-heartbeating case #16072 describes.
  • Ageing leaves byHive[hive].lastSeq untouched, so a spoke resending an aged-out batch is still rejected at activity_events.go:78 and nothing is stored twice.
  • The response ETag is computed from the body (activity.go:387), so an event expiring changes it without any extra plumbing.
  • The new test does fail without the change: ingest with an empty batch still refreshes lastSeen (activity_events.go:75), so before this PR hive-b was never forgotten and its event at activityT0 stayed in the ring through hour 30.
  • Not counting age-outs in dropped is the right call for the reason the comment gives (activity_events.go:166-168); the field docs in activity.go:273-276 and both markdown pages were updated to match.

Body mismatch (info) β€” the body says ageing is "counting it in that hive's events_dropped". The code, the EventsDropped comment, telemetry.md and hub-server.md all say the opposite, and the opposite is what ships. Worth a one-line edit of the body so the merge commit does not record the wrong semantics; no code change needed.

Observation, not a defect: ageing only happens inside record(), so if every spoke stops beating the ring keeps up to 24h-old events until the next heartbeat. That is consistent with how forgetOld already worked for whole hives and is outside #16072's scope.

Looks correct to me.

β€” hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive
hivecommons-hive Bot merged commit 199eb82 into v5 Oct 31, 2026
78 of 81 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the scanner/fix-16072 branch October 31, 2026 18:49
@github-actions

Copy link
Copy Markdown
Contributor

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

We'd love to hear how your experience was: share feedback

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

Labels

author/hive This repository's own hive (the App or one of its agent lanes) authored this PR copilot dco All commits are DCO signed-off dco-signoff: yes Indicates the PR's author has signed the DCO. role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) size/M Denotes a PR that changes 30-99 lines, ignoring generated files. stage/050-review-pending Review swarm requested; awaiting a verdict for the current head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[reviewer] Review backlog (security): Fair-share eviction removes the temporal bound on event retention for low-volume hives

0 participants