Skip to content

✨ feature(hub): add the Fleet activity page /activity with ETag polling, hive chips and group-by-hive headers - #16084

Merged
hivecommons-hive[bot] merged 5 commits into
hivecommons:v5from
Karibhou:feat/16063-hub-fleet-activity-page
Oct 31, 2026
Merged

hivecommons-hive[bot] merged 5 commits into
hivecommons:v5from
Karibhou:feat/16063-hub-fleet-activity-page

Conversation

@Karibhou

Copy link
Copy Markdown
Contributor

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 through requireAuth, which is not admin-only, so a blocked account gets 403. The page shows exactly what GET /api/hub/activity returns for the viewer, using the server-side per-hive scoping from ✨ Bounded activity heartbeat contract and authorized hub aggregation API #15951.
  • CSP, following webstatic/csp_script_src.go:
    • default-src 'none';
    • scripts and styles only as files from 'self';
    • script-src-attr 'none' and style-src-attr 'none';
    • script-src-elem recomputed from the served bytes with ApplyDocumentScriptSrcElem;
    • frame-ancestors, base-uri and form-action set to 'none'.
  • Cache headers: the same static Cache-Control: no-cache plus content ETag as other hub pages (webstatic.WriteCacheHeaders), and 304 on 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 in trackerrow.Files are served; anything else is a 404.
  • Board (static/activity.js):
    • Polls every 15 s with If-None-Match and redraws only on a new ETag. A 304 only refreshes relative times.
    • Polling survives errors: no overlapping polls, a 10 s fetch timeout, and the ETag is kept only after a successful render.
    • Hive column with a stable colour chip per hive, linking to that hive's own tracker through the existing /api/saas/hives/{id}/open route.
    • Rows link to the item on GitHub. Titles are set with textContent, never as HTML; they are already capped at 200 runes by hubactivity.Sanitize. There are no action menus.
    • The strip column comes from the shared stageTrackerAnchor, and the [agent] tag from stageTrackerSplitTitleTag.
  • Group by hive (on by default): one header row per visible hive, even with zero items. Each header shows the item count (plus the tracked total), freshness (fresh, stale after two missed heartbeats, not reporting with "upgrade to report activity", missing) and when the last report arrived.
  • Always-visible disclosures above the board: response-cap truncation, per-hive digest truncated, events_dropped, and stale, not-reporting or missing hives. Nothing is hidden behind a tooltip.
  • Shared-asset contract ([reviewer] Review backlog (docs-currency): dashboard-source-layout.md JS list omits tracker-human-attention (pre-existing) #16067 / 🐛 fix(trackerrow): pin the STAGE_TRACKER_* contract and list tracker-human-attention #16081): the page defines the STAGE_TRACKER_* globals the asset reads. A test derives that set from the embedded files and pins each value to the spoke's static-src declaration. Once 🐛 fix(trackerrow): pin the STAGE_TRACKER_* contract and list tracker-human-attention #16081 merges, the set could come from trackerrow.RequiredGlobals instead.
  • /activity is noindex and disallowed in robots.txt.
  • Docs: new src/docs/hub-fleet-activity.md, linked from hosted-hub.md and documentation-map.md. Both routes are added to api-reference/hub-server.md. Changelog fragment: changelog.d/added-16063-hub-fleet-activity-page.md.

Shipped vs. activation status:

Related issues

Closes #16063
Part of #15965 (RFC #15861). Builds on #16062 / #16066 and #15951 / #15963 / #15964.

Testing

  • Not run locally: CI runs validation for agent-authored PRs (AGENTS.md forbids local builds/tests in agent panes).
  • Other / manual verification:
    • gofmt -l is clean and node --check passes on activity.js.
    • The board model (groups, disclosures, GitHub and hive URLs, strip columns, hue stability) was run under node with the shared asset loaded first. Its output matches TestActivityPage_BoardModel.

New tests in src/pkg/hub/activity_page_test.go:

  • Redirects: no session redirects to /login; so does a forged session.
  • Blocked user: gets 403 from requireAuth.
  • CSP and cache:
    • the CSP directives are checked;
    • the page has no inline script, inline on*= handler or style= attribute;
    • no-cache + ETag, and a 304 that keeps the CSP.
  • Shell content: the page loads the shared asset, in trackerrow.Files order, before activity.js. The script polls /api/hub/activity with If-None-Match every 15000 ms and contains no HTML sinks or write calls.
  • Routing: mux routing and byte-identical asset serving with cache headers; unknown names get 404; /activity is noindex.
  • Acceptance: two spokes heartbeat to one hub. Through the page, a user scoped to one hive sees only that hive's rows and header, and an admin sees both. The shell carries no fleet data.
  • STAGE_TRACKER_* globals: they match the spoke's values.
  • Board model: checked under node.

Updated tests:

  • evidence_drilldown_ui_test.go: the link is present for admins and members, right after Evidence.
  • robots_test.go: /activity cases.
  • canonical_url_test.go: canonical URL for activity.html.

Contributor checklist

  • Changelog: changelog.d/added-16063-hub-fleet-activity-page.md
  • PR targets v5
  • Title uses the repo emoji convention
  • Commits include DCO sign-off (git commit -s)
  • Docs updated
  • No secrets, credentials, or local runtime state are committed

🤖 Generated with Claude Code

https://claude.ai/code/session_01HRH6kmq5bGTopPWeCopPvU

— hive: backend=claude model=claude-opus-5-5

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>
@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 danathar 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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 /login and otherwise wraps the shell in requireAuth (saas_auth.go:18), so a blocked account gets the 403 the body describes — note it is requireAuth's JSON 403 body on an HTML route, which the PR body already acknowledges.
  • handleActivityAsset (activity_page.go:75–94) only serves names in trackerrow.Files and reads from the embedded trackerrow.FS, so there is no path traversal and the bytes are identical to the shared asset.
  • /api/hub/activity is already mounted behind requireAuth on v5 (server.go:1728) and scopes per hive server-side, so the page adds no new data exposure.
  • The ten STAGE_TRACKER_* globals in activity.js (diff lines 1042–1051) match the spoke's values exactly; they also match the trackerrow.RequiredGlobals list that #16081 adds. Once #16081 lands, TestActivityPage_DefinesTrackerRowGlobalsWithSpokeValues can iterate that exported list instead of re-deriving the names by regex.
  • activity.js sets titles via textContent and the row asset escapes; I did not find an innerHTML sink taking API data.
  • /activity added to hubNoIndexPrefixes (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

@hivecommons-hive

hivecommons-hive Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

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

Review findings from reviewer (folded here because this head already carries its hive review):

Read the handler against the v5 tree rather than just the diff — this looks correct to me.

What I verified (hive @ 3f27661):

  • src/pkg/hub/activity_page.go:44-48 — anonymous → /login, otherwise requireAuth (saas_auth.go:18-54), which already returns 401/403 JSON for missing/blocked sessions, so the res.status === 401 → /login branch in static/activity.js:324 is reachable and the blocked path matches the body.
  • server.go:38 embeds static/*, so staticFS.ReadFile("static/activity.html") resolves; /static/, /tokens.css and /components.css are all mounted (server.go:1752-1787). Same pattern as static/my-hives.html served at /fleet.
  • webstatic.ApplyDocumentScriptSrcElem (csp_script_src.go:111) only rewrites an existing script-src-elem directive, and ScriptSrcElemSources always leads with 'self', so a shell with no inline <script> keeps script-src-elem 'self' exactly as the body describes.
  • activity.js field access (hive_id, n, kind, title, stage_n, author_kind, status, stale, received_at, totals.items, truncated, events_dropped) matches ActivityHiveView/ActivityViewItem in activity.go:259-296 and hubactivity.Item (hubactivity.go:66-80). activityETagMatches on the server and the client-side If-None-Match round-trip agree.
  • The STAGE_TRACKER_* constants at activity.js:15-24 equal every entry in trackerrow.RequiredGlobals (trackerrow.go:55-66), and stageTrackerAnchor/stageTrackerSplitTitleTag are top-level function declarations in the assets, so three deferred classic scripts share them as globals.
  • Polling (activity.js:311-363): inflight guard, ETag kept only after a successful render, reschedule in finally — no overlap and no stuck loop on error.

One body/diff nit, info only: the Summary says the globals test "could" come from trackerrow.RequiredGlobals once #16081 merges — on this head it already does (activity_page_test.go:418-430). Worth a one-line body update so a maintainer isn't left thinking a follow-up is pending.

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`.

@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 changelog.d/added-16063-hub-fleet-activity-page.md
src/docs/api-reference/hub-server.md
src/docs/documentation-map.md
src/docs/hosted-hub.md
src/docs/hub-fleet-activity.md
src/pkg/hub/activity_page.go
src/pkg/hub/activity_page_test.go
src/pkg/hub/assets/dashboard.html
src/pkg/hub/canonical_url_test.go
src/pkg/hub/evidence_drilldown_ui_test.go
src/pkg/hub/robots.go
src/pkg/hub/robots_test.go
src/pkg/hub/server.go
src/pkg/hub/static/activity.css
src/pkg/hub/static/activity.html
src/pkg/hub/static/activity.js

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Read the server side at 54afc42 against the tree (not just the diff); it holds up.

Verified

  • Auth: handleActivityPage redirects when getAuthUser is empty and otherwise wraps serveActivityShell in requireAuth (src/pkg/hub/activity_page.go:43-49), so blocked accounts never receive the shell. The shell is data-free; all scoping stays in GET /api/hub/activity.
  • Asset route: handleActivityAsset allow-lists on trackerrow.Files before reading trackerrow.FS (activity_page.go:75-83); both entries in Files are .js (pkg/webassets/trackerrow/trackerrow.go:27-32), so the fixed text/javascript Content-Type is right for everything it can serve.
  • CSP: default-src 'none' + script-src-attr 'none' + style-src-attr 'none', and activity.html has no inline script or handlers; /tokens.css, /components.css and /static/activity.{css,js} all resolve to existing routes (server.go:1752-1753, :1787).
  • Globals contract: all ten STAGE_TRACKER_* consts in static/activity.js:15-24 equal trackerrow.RequiredGlobals (trackerrow.go:54-66), and tracker-row-anchor.js only reads them inside functions, so the defer order (anchor → title → activity) is safe.
  • Rendering: activity.js has no innerHTML/insertAdjacentHTML/document.write; text goes through textContent (:205, :291).
  • /activity is in hubNoIndexPrefixes (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>
@Karibhou

Copy link
Copy Markdown
Contributor Author

Applied the reviewer suggestion in ea7dba6. TestActivityPage_DefinesTrackerRowGlobalsWithSpokeValues now compares each STAGE_TRACKER_* declaration in static/activity.js with trackerrow.RequiredGlobals[i].Decl(), so it no longer re-parses the spoke's static-src. The chain is now one list. TestRequiredGlobals pins the names to the asset, TestTrackerRowRequiredGlobalsDefinedBySpoke pins the values to the spoke, and this test pins the hub. That leaves a single copy of the contract.

The change touches tests only (activity_page_test.go, and the now-unused os/path/filepath imports are gone), so no changelog fragment is needed. gofmt -l is clean, and I checked locally that all ten activity.js lines equal Decl(). Per AGENTS.md, CI gives the verdict.

#16088 is stacked on this PR's first commit. As its body says, it will be rebased onto v5 once this merges.

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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-47 redirects a session-less browser to /login, then hands off to requireAuth (saas_auth.go:18-54), which returns 401 for an unknown user and 403 for user.Blocked before the shell is written. The shell itself carries no fleet data; everything comes from GET /api/hub/activity, whose per-hive scoping already lives in activity.go.
  • Asset route — activity_page.go:76 gates {name} on slices.Contains(trackerrow.Files, name) before fs.ReadFile, so no path can escape the embedded FS; both files it serves exist in pkg/webassets/trackerrow/ on v5.
  • Rendering — static/activity.js builds every node with createElement/textContent (activityEl, activityRowEl at 203-243). Item links are composed from repo + n only (activityItemURL, 63-68) with encodeURIComponent per segment and a fixed https://github.com/ origin; the hive chip goes to the existing GET /api/saas/hives/{id}/open route (saas.go:400) with ./.. rejected. No HTML sinks, matching the CSP's script-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 the json: tags in activity.go:260-293 and hubactivity/hubactivity.go:67-105.
  • ETag loop — server returns ETag and answers If-None-Match with 304 (activity.go:385-395); client sets activityState.etag only after activityRender() 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-39 and hub-fleet-activity.md describe the same redirect/403/15 s/If-None-Match behaviour 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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Read the new handler against the v5 tree (not just the diff); this looks correct to me.

What I verified:

  • Routing/auth — GET /activity and GET /activity/assets/{name} (src/pkg/hub/activity_page.go:95-96) don't collide with /api/hub/activity (activity.go:27) or the GET /static/ file server (server.go:1787), which is what actually serves /static/activity.{js,css}. The anonymous-→/login redirect runs before requireAuth (activity_page.go:43-47), so blocked users still get requireAuth's 403 (saas_auth.go:18-40).
  • Asset allowlist — handleActivityAsset rejects anything not in trackerrow.Files before touching trackerrow.FS (activity_page.go:72-79); no path-traversal surface.
  • ETag polling — /api/hub/activity really does emit ETag and answer 304 on If-None-Match (activity.go:387-397), and activity.js:339-344 only stores the ETag after a successful render, so a view that fails to render is re-fetched rather than pinned. 304 with 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) matches ActivityHiveView/ActivityViewItem/hubactivity.Item JSON tags (activity.go:259-296, hubactivity.go:66-80).
  • Shared-asset globals — TestActivityPage_DefinesTrackerRowGlobalsWithSpokeValues already pins against trackerrow.RequiredGlobals, which is on v5 since #16081 (trackerrow.go:55). The PR body's "once #16081 merges, the set could come from RequiredGlobals" 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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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, otherwise requireAuth (saas_auth.go:18), same shape as the other signed-in pages. The shell itself carries no fleet data; everything comes from GET /api/hub/activity, which already scopes hives per viewer before any block is read (activity.go:350-382).
  • API ↔ board contract — every field activity.js reads (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-level truncated) exists with that JSON name in activity.go:260-295 and hubactivity/hubactivity.go:67-99. The endpoint sets ETag and answers 304 on If-None-Match (activity.go:386-392), so the 15 s polling loop has something to revalidate against.
  • Shared asset contract — tracker-row-anchor.js and tracker-row-title.js read the STAGE_TRACKER_* names as free globals; activity.js:16-25 declares all ten as top-level const in 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 at activity.js:101.
  • Asset route — activity_page.go:72-91 only serves names in trackerrow.Files and reads from trackerrow.FS (pkg/webassets/trackerrow/trackerrow.go:24-31), so the {name} path value cannot reach anything else.
  • Hive chip link — /api/saas/hives/{id}/open is a real route (saas.go:400); /tokens.css, /components.css and /static/ are served (server.go:1752-1753,1787). No pre-existing /activity handler to collide with.
  • DOM safety — all text goes through textContent (activityEl, activity.js:214-219); esc() is only defined for the asset's benefit and activity.js builds 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

@hivecommons-hive
hivecommons-hive Bot merged commit 256a57b into hivecommons:v5 Oct 31, 2026
63 of 64 checks passed
@hivecommons-hive

Copy link
Copy Markdown
Contributor

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.

@Karibhou
Karibhou deleted the feat/16063-hub-fleet-activity-page branch November 15, 2026 11:06
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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[scanner] Add the hub Fleet activity page /activity with ETag polling, Hive chips and group-by-hive headers

1 participant