Repository navigation
🐛 fix(hub): purge a hive's activity digest when it is removed from the registry - #16007
Conversation
…e registry Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
hive/awaiting-ci: CI pending — sweep will merge when green. 🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of No conflicting open PRs or same-file overlaps were found. |
|
Hive filed review findings that do not block this PR as backlog items:
Cap: 10 backlog item(s) per PR per day. |
There was a problem hiding this comment.
Security perspective — no blocker. Reviewed head b6c1520.
activityStore.forget (src/pkg/hub/activity.go:118-127) is nil-safe, takes only the leaf lock, and is wired into the single removal choke point removeRegistryEntry (src/pkg/hub/server.go:4284), which covers the saas_hives_api and pullonly_upgrade callers. Tests cover the purge and the unrelated-hive guard.
Advisory (low, not blocking): the purge is best-effort against a concurrent heartbeat. handleHeartbeat accepts the beat into the registry under s.mu, releases it, and only then calls s.activity.record (src/pkg/hub/server.go:2733-2737). A beat that passes the registry check immediately before removeRegistryEntry runs can re-insert the digest after forget (src/pkg/hub/server.go:4284) and after the registry entry is gone, leaving it in memory for up to activityForgetAfter as before. Exposure is bounded — visibleActivityHives only yields registry hives, so the orphan is not readable via GET /api/hub/activity — but if the retention promise is meant to be strict, record would need to re-check registry membership (or the heartbeat would need to record under s.mu). Moving forget after the s.mu critical section narrows but does not close the window, so this is noted for follow-up rather than requested here.
— hive: agent=adjudicator-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. Review findings from Intent alignment (#16002) — read at head b6c1520. The fix is right where it lands: One removal path is missed. The PR body says Advisory, not blocking: Review findings from Correctness review (head b6c1520) 1. Admin registry delete still leaks the digest — in-scope. The PR body says 2. Advisory (low):
Review findings from The Finding (low): admin registry delete still leaves the digest in memory for 24h
Verified otherwise:
Marked as changes requested (advisory only — I have not changed any review state). Review findings from Read both removal paths and the heartbeat path at merge-base; this looks correct to me.
|
handleRegistryDelete duplicates removeRegistryEntry's inline splice and missed the activity.forget(id) call, so an admin DELETE left the removed hive's digest in memory until the 24h sweep. Call forget there as well and cover it in TestHandleRegistryDeleteAsAdmin (#16002). 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>
There was a problem hiding this comment.
Read against the v5 tree at head 29a2d0c. This looks correct to me.
What I verified
activityStoreis documented and used as a leaf lock (src/pkg/hub/activity.go:66-71);forgettakes onlyst.muand both call sites (server.go:4284,server.go:4350) run befores.mu.Lock(), so there is no lock-order inversion.deleteon a nilbyHiveis a no-op, so the zero-value store is fine.s.activityis a value field (server.go:1002), so thest == nilguard is purely defensive; harmless and covered byTestActivityStoreForget.- The one registry-removal path the diff does not touch is
markStaleHives(server.go:4434-4463). It evicts only afterstaleRemoveAge= 24h (server.go:124), and a digest'sreceivedAtis never newer than the hive's last heartbeat, soforgetOldLocked(activity.go:129,activityForgetAfter= 24h) has already dropped it by then. No gap there. - Tests: the new asserts in
TestRemoveRegistryEntryPersistsSynchronouslyandTestHandleRegistryDeleteAsAdminfail without the twoforgetcalls, and each also checks an unrelated hive survives. - Changelog fragment name
fixed-16002-…matches the guard's<category>-<slug>.mdrule.
Info only, not a defect: a heartbeat that has already passed its s.mu section (server.go:2733) when the delete runs can re-record after forget. The digest is then unreachable (visibleActivityHives only yields registry hives) and still bounded by the 24h sweep, so the issue's advisory goal holds; just noting the window exists in either ordering of forget vs. the registry mutation.
Diff matches the PR body and resolves #16002 as scoped.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Read the diff against the v5 tree, not just the patch. Looks correct to me.
activityStore.forget(src/pkg/hub/activity.go:120) takes onlyst.mu, and both call sites (server.go:4283,server.go:4349) run befores.mu.Lock(), so the "leaf lock" contract on theactivityfield (server.go:1002) holds.deleteon a nilbyHivemap is a no-op, so a server that never received a digest is safe.- The only two places that splice
registry.HivesareremoveRegistryEntryandhandleRegistryDelete(server.go:4289,:4355); both now purge. The only writer is the authenticated heartbeat (server.go:2737), which re-adds the registry entry first — so a deleted hive that keeps beating simply re-registers; there is no path that leaves a digest without an entry. pkg/huband its_test.gofiles type-check at this head.
One nit on the body, not the code: it says removeRegistryEntry is "the common choke point for every removal path", but the admin DELETE /api/hub/registry/{id} handler splices the slice itself and needed its own forget call — which the diff correctly adds. Worth a one-word edit so the next reader doesn't assume the handler delegates.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Read at 4a92402. Looks correct to me.
removeRegistryEntry(src/pkg/hub/server.go:4283) andhandleRegistryDelete(:4349) are the only two places that splice an entry out ofs.registry.Hivesin non-test code; both now calls.activity.forget(id)before takings.mu, which respects the "leaf lock" note on theactivityfield (server.go:1002) — no lock nesting introduced.forget(activity.go:120) deletes frombyHive;deleteon a nil map is a no-op, so the lazily-initialised store is safe before the firstrecord.- Tests cover both removal paths plus the unrelated-hive-preserved case (
delete_hive_registry_test.go:426,hub_coverage_boost_test.go:939). v2 Tests / coverage / patch-coverage are green at this head.
No findings. Not approving — that's a human's signature.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Looks correct to me. Read src/pkg/hub/activity.go and server.go at 9f7d994.
- The registry only ever drops an entry in two places —
removeRegistryEntry(server.go:4289) andhandleRegistryDelete(server.go:4355) — and both now calls.activity.forget(id)right afterforgetUncollectibleUpgrade. No removal path is missed. forgetruns befores.muis taken, honouring the "leaf lock, never take s.mu while holding it" rule onactivityStore(activity.go:62). A heartbeat racing the delete re-appends the registry entry (server.go:2730) and re-records the digest (server.go:2737), so the two stay consistent either way.deleteon a nilbyHivemap is a no-op, andactivityis a value field (server.go:1002), so the nil-receiver branch is belt-and-braces rather than load-bearing; harmless.- Tests exercise both paths with a kept sibling hive, which is the assertion that matters.
One nit on the body only: it says removeRegistryEntry is "the common choke point for every removal path", but handleRegistryDelete has its own loop and doesn't call it. The diff already instruments both, so nothing to change in code — just noting so a future reader doesn't assume one hook is enough.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
…es (#16039) Since #16007, removing a hive from the registry purges its activity block immediately via activityStore.forget (removeRegistryEntry and the admin registry DELETE handler). The 24h sweep is now only a backstop for hives that stopped reporting while still registered, so drop the "or left the registry" wording that still framed departure as a time-based eviction. Comment-only change; no behavior change. Closes #16009 Hive-Run: #16009 Hive-Plan: reviewer backlog docs-currency (from review of #16007) Hive-Spec: hub-activity#activityForgetAfter Claude-Session: https://claude.ai/code/session_01HRH6kif1Xa5LCs6yXPcSgw Signed-off-by: Karibhou <157208370+Karibhou@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: hivecommons-hive[bot] <280983584+hivecommons-hive[bot]@users.noreply.github.com>
Closes #16002
The memory-only retention promise of #16005 should hold when a hive is deleted, not only after 24h of silence.
removeRegistryEntryis the common choke point for every removal path, so it now calls a new nil-safeactivityStore.forget(id). Tests coverforget(unknown id, nil store) and the registry-removal purge.— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88