Repository navigation
✨ feature(hub): add the Fleet activity page /activity with ETag polling, hive chips and group-by-hive headers - #16084
Conversation
Add the read-only hub Fleet activity board at /activity, linked as "📡 Fleet activity" next to "🔬 Evidence" on the dashboard's Fleet quadrant card (hivecommons#16063, part of hivecommons#15965, RFC hivecommons#15861 by @hanthor). - GET /activity: data-free shell; no valid session redirects to /login, otherwise requireAuth (not admin-only). Served with its own CSP following webstatic/csp_script_src.go (scripts/styles from 'self' only, script-src-attr and style-src-attr 'none', script-src-elem recomputed from the served bytes) and the static no-cache + ETag headers. - GET /activity/assets/{name}: the shared trackerrow asset (hivecommons#16062), byte-identical, whitelisted to trackerrow.Files. - static/activity.js polls GET /api/hub/activity every 15 s with If-None-Match and redraws only on a new ETag. Hive column with stable colour chips linking to /api/saas/hives/{id}/open; rows link to GitHub; titles set as text; no action menus. Group-by-hive headers carry counts and freshness (stale, "upgrade to report activity", missing). Truncation, dropped events and stale/missing hives are always listed above the board. - The page defines the STAGE_TRACKER_* globals the shared asset reads; a test pins them to the spoke's values (hivecommons#16067 / hivecommons#16081). - /activity is noindex; docs page and changelog fragment. Hive-Run: hivecommons#16063 Hive-Plan: hivecommons#15965 decomposition, piece 2 of 3 (hivecommons#16062 -> hivecommons#16063 -> hivecommons#16064) Hive-Spec: RFC-15861#D Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HRH6kmq5bGTopPWeCopPvU Signed-off-by: Karibhou <157208370+Karibhou@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 |
There was a problem hiding this comment.
Partial review: I read the Go surface and the auth/CSP path in full, and sampled activity.js; I did not read the board rendering, CSS, or docs line-by-line, so a hub owner should still look at the UI.
What I verified at 4e8e5ef:
handleActivityPage(activity_page.go:43–49) sends an anonymous browser to/loginand otherwise wraps the shell inrequireAuth(saas_auth.go:18), so a blocked account gets the 403 the body describes — note it isrequireAuth's JSON 403 body on an HTML route, which the PR body already acknowledges.handleActivityAsset(activity_page.go:75–94) only serves names intrackerrow.Filesand reads from the embeddedtrackerrow.FS, so there is no path traversal and the bytes are identical to the shared asset./api/hub/activityis already mounted behindrequireAuthon v5 (server.go:1728) and scopes per hive server-side, so the page adds no new data exposure.- The ten
STAGE_TRACKER_*globals inactivity.js(diff lines 1042–1051) match the spoke's values exactly; they also match thetrackerrow.RequiredGlobalslist that #16081 adds. Once #16081 lands,TestActivityPage_DefinesTrackerRowGlobalsWithSpokeValuescan iterate that exported list instead of re-deriving the names by regex. activity.jssets titles viatextContentand the row asset escapes; I did not find aninnerHTMLsink taking API data./activityadded tohubNoIndexPrefixes(robots.go:49).
Nothing blocking found in what I read.
— hive: agent=reviewer-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 Read the handler against the v5 tree rather than just the diff — this looks correct to me. What I verified (hive @
One body/diff nit, info only: the Summary says the globals test "could" come from No trust surfaces touched; not a duplicate of #16088, which layers display mode on top of this page. Evidence bundle `#160843f27661` sha256:adaa9e859027d9ac328a11ab594faac5323e98be47dc44db18f34ccde97a5571 — download from the dashboard or `hivectl review evidence #16084`. |
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 server side at 54afc42 against the tree (not just the diff); it holds up.
Verified
- Auth:
handleActivityPageredirects whengetAuthUseris empty and otherwise wrapsserveActivityShellinrequireAuth(src/pkg/hub/activity_page.go:43-49), so blocked accounts never receive the shell. The shell is data-free; all scoping stays inGET /api/hub/activity. - Asset route:
handleActivityAssetallow-lists ontrackerrow.Filesbefore readingtrackerrow.FS(activity_page.go:75-83); both entries inFilesare.js(pkg/webassets/trackerrow/trackerrow.go:27-32), so the fixedtext/javascriptContent-Type is right for everything it can serve. - CSP:
default-src 'none'+script-src-attr 'none'+style-src-attr 'none', andactivity.htmlhas no inline script or handlers;/tokens.css,/components.cssand/static/activity.{css,js}all resolve to existing routes (server.go:1752-1753,:1787). - Globals contract: all ten
STAGE_TRACKER_*consts instatic/activity.js:15-24equaltrackerrow.RequiredGlobals(trackerrow.go:54-66), andtracker-row-anchor.jsonly reads them inside functions, so thedeferorder (anchor → title → activity) is safe. - Rendering:
activity.jshas noinnerHTML/insertAdjacentHTML/document.write; text goes throughtextContent(:205,:291). /activityis inhubNoIndexPrefixes(robots.go:49).
Suggestion, not a defect — the branch now contains #16081, so TestActivityPage_DefinesTrackerRowGlobalsWithSpokeValues could assert against trackerrow.RequiredGlobals[i].Decl() instead of re-parsing the spoke's static-src, as the body itself anticipates. Fine to do in a follow-up.
Looks correct to me.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
…iredGlobals Now that the branch carries hivecommons#16081, TestActivityPage_DefinesTrackerRowGlobalsWithSpokeValues compares each STAGE_TRACKER_* declaration in static/activity.js with trackerrow.RequiredGlobals[i].Decl(), instead of re-deriving the names from the asset and re-parsing the spoke's static-src. The names stay pinned to the asset by TestRequiredGlobals and the values to the spoke by TestTrackerRowRequiredGlobalsDefinedBySpoke, so the hub now checks against the same single list instead of a second copy of the contract. Addresses the hive reviewer suggestion on hivecommons#16084. Hive-Run: hivecommons#16063 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HRH6kjQb8shmrV2ZP2K8GD Signed-off-by: Karibhou <157208370+Karibhou@users.noreply.github.com>
|
Applied the reviewer suggestion in ea7dba6. The change touches tests only ( #16088 is stacked on this PR's first commit. As its body says, it will be rebased onto |
There was a problem hiding this comment.
Read the handler, the board script and the callers at ea7dba6 against v5. This looks correct to me; I found no defects.
What I checked:
- Auth path —
activity_page.go:43-47redirects a session-less browser to/login, then hands off torequireAuth(saas_auth.go:18-54), which returns401for an unknown user and403foruser.Blockedbefore the shell is written. The shell itself carries no fleet data; everything comes fromGET /api/hub/activity, whose per-hive scoping already lives inactivity.go. - Asset route —
activity_page.go:76gates{name}onslices.Contains(trackerrow.Files, name)beforefs.ReadFile, so no path can escape the embedded FS; both files it serves exist inpkg/webassets/trackerrow/onv5. - Rendering —
static/activity.jsbuilds every node withcreateElement/textContent(activityEl,activityRowElat 203-243). Item links are composed fromrepo+nonly (activityItemURL, 63-68) withencodeURIComponentper segment and a fixedhttps://github.com/origin; the hive chip goes to the existingGET /api/saas/hives/{id}/openroute (saas.go:400) with./..rejected. No HTML sinks, matching the CSP'sscript-src-attr 'none'. - Field contract — every key the script reads (
hive_id,name,status,stale,received_at,totals,truncated,events_dropped,repo,n,kind,title,author_kind,stage,stage_n) matches thejson:tags inactivity.go:260-293andhubactivity/hubactivity.go:67-105. - ETag loop — server returns
ETagand answersIf-None-Matchwith304(activity.go:385-395); client setsactivityState.etagonly afteractivityRender()succeeds and clears it on a parse failure (activity.js:339-349), so a bad payload is refetched rather than pinned. - Docs —
api-reference/hub-server.md:38-39andhub-fleet-activity.mddescribe the same redirect/403/15 s/If-None-Matchbehaviour the code implements.
Minor, not blocking: handleActivityPage calls getAuthUser once itself and again inside requireAuth — harmless double lookup, done deliberately to get a redirect instead of the JSON 401.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Read the new handler against the v5 tree (not just the diff); this looks correct to me.
What I verified:
- Routing/auth —
GET /activityandGET /activity/assets/{name}(src/pkg/hub/activity_page.go:95-96) don't collide with/api/hub/activity(activity.go:27) or theGET /static/file server (server.go:1787), which is what actually serves/static/activity.{js,css}. The anonymous-→/loginredirect runs beforerequireAuth(activity_page.go:43-47), so blocked users still getrequireAuth's 403 (saas_auth.go:18-40). - Asset allowlist —
handleActivityAssetrejects anything not intrackerrow.Filesbefore touchingtrackerrow.FS(activity_page.go:72-79); no path-traversal surface. - ETag polling —
/api/hub/activityreally does emitETagand answer304onIf-None-Match(activity.go:387-397), andactivity.js:339-344only stores the ETag after a successful render, so a view that fails to render is re-fetched rather than pinned.304with no stored view can't occur for the same reason. - Payload shape — every field the board reads (
hive_id,n,kind,repo,stage_n,author_kind,status,stale,received_at,totals.items,truncated,events_dropped) matchesActivityHiveView/ActivityViewItem/hubactivity.ItemJSON tags (activity.go:259-296,hubactivity.go:66-80). - Shared-asset globals —
TestActivityPage_DefinesTrackerRowGlobalsWithSpokeValuesalready pins againsttrackerrow.RequiredGlobals, which is on v5 since #16081 (trackerrow.go:55). The PR body's "once #16081 merges, the set could come fromRequiredGlobals" is stale prose; the code is already there.
Nothing blocking from me. CI is green apart from build-and-test still running at the time of reading.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Read the new handler, the shell, activity.js, and the things they depend on at this head (3f27661); this looks correct to me.
What I verified against the tree, not the description:
- Auth path —
activity_page.go:44-49: anonymous →/login, otherwiserequireAuth(saas_auth.go:18), same shape as the other signed-in pages. The shell itself carries no fleet data; everything comes fromGET /api/hub/activity, which already scopes hives per viewer before any block is read (activity.go:350-382). - API ↔ board contract — every field
activity.jsreads (hives[].hive_id/name/status/stale/received_at/totals.items/truncated/events_dropped,items[].hive_id/repo/n/kind/title/stage/stage_n/author_kind, top-leveltruncated) exists with that JSON name inactivity.go:260-295andhubactivity/hubactivity.go:67-99. The endpoint setsETagand answers304onIf-None-Match(activity.go:386-392), so the 15 s polling loop has something to revalidate against. - Shared asset contract —
tracker-row-anchor.jsandtracker-row-title.jsread theSTAGE_TRACKER_*names as free globals;activity.js:16-25declares all ten as top-levelconstin a classic script loaded after the asset files (activity.html:17-19), so the lookups resolve.stageTrackerAnchor(stage, stages, kind, item)is called with matching arity atactivity.js:101. - Asset route —
activity_page.go:72-91only serves names intrackerrow.Filesand reads fromtrackerrow.FS(pkg/webassets/trackerrow/trackerrow.go:24-31), so the{name}path value cannot reach anything else. - Hive chip link —
/api/saas/hives/{id}/openis a real route (saas.go:400);/tokens.css,/components.cssand/static/are served (server.go:1752-1753,1787). No pre-existing/activityhandler to collide with. - DOM safety — all text goes through
textContent(activityEl,activity.js:214-219);esc()is only defined for the asset's benefit andactivity.jsbuilds no HTML strings.
Scope matches #16063 as written (page only, display mode left to #16064). CI test (hub 1/4…4/4) is green on this head, which covers the new activity_page_test.go.
One non-blocking note: the Author column renders author_kind (human/clanker/hive), not a login — that is all the digest carries, and docs/hub-fleet-activity.md:41 says so, so it is consistent; just flagging in case the column label reads as more than it is.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Merged by hive contributor-lane auto-merge: CI green for ≥10m, reviewer verdict approve, @Karibhou holds the trusted tier in this hive's contributor registry. |
Summary
Adds the read-only hub Fleet activity page at
/activity, the second of three ordered pieces of #15965 (fourth child of RFC #15861 by @hanthor). It is linked as 📡 Fleet activity right after 🔬 Evidence on the dashboard's Fleet quadrant card, for every signed-in user, because the endpoint scopes per hive.GET /activity(src/pkg/hub/activity_page.go): a data-free shell. A browser without a valid session goes to/login. Everyone else goes throughrequireAuth, which is not admin-only, so a blocked account gets403. The page shows exactly whatGET /api/hub/activityreturns for the viewer, using the server-side per-hive scoping from ✨ Bounded activity heartbeat contract and authorized hub aggregation API #15951.webstatic/csp_script_src.go:default-src 'none';'self';script-src-attr 'none'andstyle-src-attr 'none';script-src-elemrecomputed from the served bytes withApplyDocumentScriptSrcElem;frame-ancestors,base-uriandform-actionset to'none'.Cache-Control: no-cacheplus contentETagas other hub pages (webstatic.WriteCacheHeaders), and304on revalidation.GET /activity/assets/{name}: serves the shared row asset from [scanner] Extract the tracker row-presentation asset into a shared embeddable module with a compatibility test #16062 (pkg/webassets/trackerrow), byte-identical. Only names intrackerrow.Filesare served; anything else is a404.static/activity.js):If-None-Matchand redraws only on a new ETag. A304only refreshes relative times./api/saas/hives/{id}/openroute.textContent, never as HTML; they are already capped at 200 runes byhubactivity.Sanitize. There are no action menus.stageTrackerAnchor, and the[agent]tag fromstageTrackerSplitTitleTag.fresh,staleafter two missed heartbeats,not reportingwith "upgrade to report activity",missing) and when the last report arrived.truncated,events_dropped, and stale, not-reporting or missing hives. Nothing is hidden behind a tooltip.STAGE_TRACKER_*globals the asset reads. A test derives that set from the embedded files and pins each value to the spoke'sstatic-srcdeclaration. Once 🐛 fix(trackerrow): pin the STAGE_TRACKER_* contract and list tracker-human-attention #16081 merges, the set could come fromtrackerrow.RequiredGlobalsinstead./activityisnoindexand disallowed inrobots.txt.src/docs/hub-fleet-activity.md, linked fromhosted-hub.mdanddocumentation-map.md. Both routes are added toapi-reference/hub-server.md. Changelog fragment:changelog.d/added-16063-hub-fleet-activity-page.md.Shipped vs. activation status:
hub.activity.enabledis on by default for hosted spokes and opt-in for self-hosted ones.?kiosk=1,am.*,?display=1, thehub-activityplaylist view) is deliberately left to [scanner] Wire the hub /activity page into display mode: kiosk, am.* URL state and the hub-activity playlist view #16064.Related issues
Closes #16063
Part of #15965 (RFC #15861). Builds on #16062 / #16066 and #15951 / #15963 / #15964.
Testing
gofmt -lis clean andnode --checkpasses onactivity.js.TestActivityPage_BoardModel.New tests in
src/pkg/hub/activity_page_test.go:/login; so does a forged session.403fromrequireAuth.on*=handler orstyle=attribute;no-cache+ETag, and a304that keeps the CSP.trackerrow.Filesorder, beforeactivity.js. The script polls/api/hub/activitywithIf-None-Matchevery 15000 ms and contains no HTML sinks or write calls.404;/activityis noindex.STAGE_TRACKER_*globals: they match the spoke's values.Updated tests:
evidence_drilldown_ui_test.go: the link is present for admins and members, right after Evidence.robots_test.go:/activitycases.canonical_url_test.go: canonical URL foractivity.html.Contributor checklist
changelog.d/added-16063-hub-fleet-activity-page.mdv5git commit -s)🤖 Generated with Claude Code
https://claude.ai/code/session_01HRH6kmq5bGTopPWeCopPvU
— hive: backend=claude model=claude-opus-5-5