Repository navigation
✨ feat(hub): surface "Pause hive" in the hub spoke dropdown menu - #15163
Conversation
Add a "⏸ Pause hive" / "▶ Resume hive" item to the per-hive menu in the
hub's hive list (owner or hub admin). It drives the spoke's existing fleet
breaker — the same EngageBreaker/ReleaseBreaker path as the spoke's own
top-bar "running ⏸" button — so no new pause mechanism is introduced.
- hub: POST /api/saas/hives/{id}/breaker {"engaged": bool} queues the
instruction durably on the SaaSHive record (owner-or-admin gate,
audit log + activity timeline entry)
- hub: the next heartbeat response carries it once in
HeartbeatResponse.Breaker and clears it (one-shot, like
ResetAgentRestarts)
- spoke: new BreakerCallback applies engage/release via the agent
runtime and writes the dashboard audit entry
- dashboard: menu label follows breaker state, derived from agents
whose pausedTrigger is "fleet-breaker"
- tests for the handler's authz/validation/queueing, one-shot delivery,
and the boot callback driving the real breaker
- api-reference row for the new route (citations re-anchored)
Hive-Run: #15092
Hive-Plan: #15092 proposed solution
Hive-Spec: #15092#proposed-solution
Co-authored-by: kanrenibm <91967876+kanrenibm@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HRH6kkwbjSjorhcbXnoxg3
Signed-off-by: Karibhou <157208370+Karibhou@users.noreply.github.com>
…items Review fix for the TestStyleRatchet failure: the new Pause/Resume menu item pushed hub static pages to 942 inline style= attributes (baseline 941). Replace the ad-hoc `mi` inline-style string with a `.hive-menu-item` class built from design tokens (--sp-3/--sp-5, --text, --fs-sm) and apply it to every item in the spoke dropdown, including the new one. That drops the surface to 930 style= attributes with no change to the raw color, font-size, padding or border-radius counters, so the baseline is lowered to 930 rather than raised. Hive-Fix-Attempt: 2/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> 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 |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
There was a problem hiding this comment.
Read the tree at 15cd4482 (hub, spoke, cmd/hive), not just the diff. The change does what the body says and looks correct to me.
What I verified
src/pkg/hub/spoke_breaker.go:23-45—handleSpokeBreakeris behindrequireAuth(saas.go:429) plususerIsHiveOwner || isHubAdmin, matching the owner gate on the spoke's own/api/breaker/*(src/pkg/dashboard/api_breaker.go:30). Body isMaxBytesReader(1024)andEngaged *boolrejects a missing key.spoke_breaker.go:66-89—pendingBreakerForHeartbeatis the same load → clear → save → return one-shot aspendingAgentRestartResetsForHeartbeat(saas.go:552-573), andhandleHeartbeatcalls it right after that function (server.go:3344). Failing to clear withholds rather than redelivers — the right default.src/pkg/hub/spoke/heartbeat.go:1474andsrc/cmd/hive/main.go:5704-5716— the spoke callsagentMgr.EngageBreaker()/ReleaseBreaker(b.ctx), the same methodshandleBreakerEngage/Releasecall, and writes the samebreaker-engage/breaker-releaseaudit actions. Unknown values are logged and ignored.src/pkg/hub/assets/dashboard.html—breakerOnkeys offpausedTrigger === 'fleet-breaker', which iscrux.BreakerTrigger(src/crux/pause.go:12) and is already carried on hub agent rows (src/pkg/hub/heartbeat.go:21). Confirm/toast are the in-apphiveConfirm/hiveToast, no native dialogs.- Tests cover authz + queue + one-shot delivery (
spoke_breaker_test.go) and the spoke callback (boot_heartbeat_deps_test.go:255). Changelog fragment name andapi-reference.mdrow are present; both commits are signed off.
One low-severity note, not a blocker
The dashboard path calls s.refreshAndPersist() right after engaging (api_breaker.go:40), so an engaged breaker survives a crash. The heartbeat callback at main.go:5706-5713 does not, and relies on the run loop's next deps.persist(b) tick (main.go:6331). A crash in that window comes back with agents running. This matches the sibling AgentRestartResetCallback in the same block, so it is consistent with the file — but if you want parity with the ⏸ button, a persist hook after the engage/release would close it. Suggestion only.
Note for maintainers: #15105 is this exact head (15cd4482) on the contributor fork; this PR is the hive's adopt-in-place of it, so one review covers both.
— 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 tree at 15cd448 (cloned, go build ./cmd/hive/ ./pkg/hub/... passes). The change does what it says and reuses existing machinery correctly; I found no defects. Notes for whoever merges:
Verified
- Hub gate:
pkg/hub/spoke_breaker.go:31-34—userIsHiveOwner || isHubAdmin. The spoke's own/api/breaker/{engage,release}isrequireOwnerRole(pkg/dashboard/api_breaker.go:30), so the hub side is the same gate plus hub admin, as the body states. Body is capped at 1 KiB andengagedis a*bool, so a missing key is a 400 rather than a silent release. - One-shot delivery:
pendingBreakerForHeartbeat(spoke_breaker.go:68-89) is the same load → clear → save → return shape aspendingAgentRestartResetsForHeartbeat(pkg/hub/saas.go:552-574); the unlocked read-modify-write onmeta.jsonis the pre-existing pattern for every queued-on-heartbeat field, not something this PR introduces. Read inhandleHeartbeatafterverifyHeartbeatBearer(server.go:1893), so only the authenticated spoke consumes it. - Spoke side:
BreakerCallbacktype-switch and dispatch inpkg/hub/spoke/heartbeat.gomirrorAgentRestartResetCallback;cmd/hive/main.go:5704-5717callsagentMgr.EngageBreaker()/ReleaseBreaker(ctx)— identical calls to the dashboard handlers — and writes the samebreaker-engage/breaker-releaseaudit actions. - UI:
AgentSummarycarriespaused+pausedTrigger(pkg/hub/heartbeat.go:19-20), andcrux.BreakerTrigger == "fleet-breaker"(crux/pause.go:12), so the Pause/Resume label flips on real state.hiveConfirmescapes the message whenrawHTMLis unset (dashboard.html:3140), so the hive name is safe in the dialog. No native dialogs. - Docs:
api-reference.mdrow added and citations re-anchored; changelog fragment followsadded-<issue>-<slug>.md.
One behavioural note, not a defect — when two instances report as the same hive (the case Restart Spoke exists for), the one-shot is consumed by whichever instance beats first; the other never hears it. That is the same contract as ResetAgentRestarts, and the breaker is idempotent so a second click fixes it, but it differs from RestartSpoke, which uses a time window so every instance acts. Worth a line in the hub-side comment if that case matters to operators.
Looks correct to me. CI was still running (build linux/arm64, tide) when I read it.
— 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 |
Supersedes #15105 (adopted in place, re-homed because a hive commit on the contributor branch cannot carry a squash-safe sign-off; original commits by @Karibhou preserved).
Closes #15092
This branch is #15105's head
15cd4482b930as pushed by @Karibhou (forkKaribhou/hive), unchanged. Last lane reason on the original:reviewer-verdict:changes_requested.Hive fix agent: rebase this branch on
v5, fix the failing checks / review asks, and push to THIS branch. Keep the original author's commits and theirSigned-off-by; add your own sign-off on your commits. Do not open another PR.Sign-off attribution: the original PR would squash the App's signed fixes as the contributor. This App-authored superseder keeps every original commit and sign-off unchanged and attributes the squash to the App instead. DCO and all merge gates still apply here.