Skip to content

✨ feature(hub): add the public-safe Fleet activity view for the hivecommonsfleet broadcast - #16110

Merged
hivecommons-hive[bot] merged 1 commit into
v5from
scanner/fix-15966
Oct 31, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
v5from
scanner/fix-15966

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Closes #15966. Part of RFC #15861 by @hanthor (cc @hanthor).

Why

The twitch.tv/hivecommonsfleet deployment from #15998 renders the hub anonymously, but it had nothing safe to point at. Its DASHBOARD_PATH was a CHANGE-ME placeholder. The signed-in /activity page is scoped per viewer, and a Twitch stream is public. A viewer's own Fleet access must therefore never decide what a broadcast shows. The issue asks for a separately authorized view that shows public-safe content only, plus a hub-side test that private rows are omitted. That route and test were the only acceptance left after #15998.

What changes

  • GET /activity/public + GET /api/hub/activity/public (src/pkg/hub/activity_public.go). These are distinct routes, not a flag on the signed-in ones. The endpoint never reads a cookie, token or Authorization header, so a signed-in admin gets the same bytes as an anonymous visitor. It filters the copied store data before building the view:
    • only hives the registry lists as public (the same flag the public registry and leaderboard use) on public github.com; GitHub Enterprise hives are left out;
    • only items and events not marked private. The spoke marks a repo private unless it knows it is public, so unknown visibility fails closed;
    • no totals, digest truncated or events_dropped, because those can count private items; no owner; no per-user grants.
  • activity.js: on /activity/public the page polls only the public endpoint, with credentials: 'omit'. /activity behaves exactly as before.
  • fleet/configmap.yaml: DASHBOARD_PATH now points at /activity/public?kiosk=1. The gate still refuses to start, because STREAM_ENABLED=false, there is no policy ack and no key, and replicas: 0.
  • Docs: the streaming guide (a new "The public-safe hub view" section and an updated owner steps list), hub-fleet-activity.md#public-safe-view and the API reference rows.
  • Changelog: changelog.d/added-15966-public-safe-activity-view.md.

Tests (activity_public_test.go)

  • TestActivityPublic_OmitsPrivateRowsByConstruction: one spoke shares a private item and a private event; the other hives are a non-public hive, a hive with no public flag and a GHE hive. Only the public row and the public event appear, and no totals, truncation or drop counts. The response is byte-identical whether the request is anonymous or carries an admin session and bearer. The admin's /api/hub/activity still sees all four hives.
  • TestActivityPublic_PublicRowsRender: public rows render, and an invalid filter returns 400.
  • TestActivityPublic_RoutesAnonymouslyThroughTheHubMux: both public routes return 200 anonymously; /activity still redirects to login and /api/hub/activity still returns 401; both public routes are noindex.
  • TestActivityPublic_PagePollsThePublicEndpointWithoutCredentials: run under node.

Existing /activity tests are unmodified. TestHivecommonsStreamConfigUnchanged is untouched (no change under k8s/, overlays/ or docker-compose.yaml). Following AGENTS.md, I did not run anything locally except gofmt -l; CI gives the verdict.

Deployment / activation status

Nothing is activated. This PR installs no credential and enables no broadcast; the hivecommons stream is unchanged. What remains are owner actions outside this issue's code scope (#15861):

  1. check https://hive.hivecommons.dev/activity/public in a private window;
  2. install the hivecommonsfleet stream key;
  3. set STREAM_ENABLED and PUBLIC_SAFE_POLICY_ACK, then scale to 1.

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 requested_by=@hanthor

…ommonsfleet broadcast

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 hanthor 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/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 31, 2026
@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

Hive filed review findings that do not block this PR as backlog items:

Cap: 10 backlog item(s) per PR per day.

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

Read the new handler against the tree at 674a580, not just the diff. This looks correct to me; nothing blocking.

What I verified:

  • Fail-closed filtering happens before the view is built. publicActivityHives (src/pkg/hub/activity_public.go:38-46) keeps only Public hives, and Public is derived in activityRegistry (activity.go:406) from h.IsPublic && sameGitHubHost(h.GitHubHost, publicGitHubHost) — the same flag the registry/leaderboard already use. Rows and events are dropped on Private (activity_public.go:51-78), and the spoke sets Private: !public.allows(repo) (src/pkg/dashboard/hub_activity.go:88,114), so unknown visibility is private. The rebuilt Digest carries no Totals/Truncated, so ActivityHiveView.totals/events_dropped are empty for the public view; the response-level truncated at activity.go:344 is computed from already-filtered items only.
  • No credential is read. handleHubActivityPublic (activity_public.go:96-117) is registered without requireAuth (activity_page.go:113-114) and only touches r.URL.Query() and If-None-Match; TestActivityPublic_OmitsPrivateRowsByConstruction asserts byte-identical output with and without an admin cookie + bearer.
  • Noindex already covers the new routes. /activity in hubNoIndexPrefixes (robots.go:48) is a bare prefix, so /activity/public is matched; /api/ covers the endpoint.
  • Anonymous registration matches existing convention — /api/registry, /api/hub/leaderboard, /api/hub/stats (server.go:1720-1722) are likewise unauthenticated with no per-route limiter, so this adds no new class of exposure.
  • Deploy manifest. The only infra change is DASHBOARD_PATH in src/deploy/stream/fleet/configmap.yaml:21 going from the CHANGE-ME placeholder to /activity/public?kiosk=1; public-safe-gate.sh:41-49 still refuses to start on STREAM_ENABLED=false / empty ack, and activity.js:75-83 honours ?kiosk=1. The public exposure itself is what [scanner] Prepare a disabled-by-default independent hivecommonsfleet broadcast of a public-safe hub activity view #15966 / the owner decisions on 📝 RFC: Hub-wide Activity Monitor with per-hive aggregation #15861 asked for ("a dedicated route … renders only content explicitly marked public-safe"), so I am not raising it as a decision question.

Body and diff agree. Remaining owner steps (private-window check, stream key, enable + ack) are correctly listed as out of this PR's scope.

Evidence bundle `#16110674a580` sha256:7e4baca772c0fb9263b0ccdb9c527b9bdcb412f7e56d061479020242f5843c9a — download from the dashboard or `hivectl review evidence #16110`.

@github-actions

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.

No conflicting open PRs or same-file overlaps were found.

@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

Copy link
Copy Markdown
Contributor Author
674a580

ℹ️ Sentinel notice — informational; author is trusted (hive agent), merge is not blocked

Hive flagged this PR (author @hivecommons-hive[bot], head 674a580aa956) because it matches behaviors that can override security controls, escalate privileges or damage the codebase. This is a heuristic, not an accusation — a maintainer should confirm the change is intended before it merges.

  • sensitive_path — changes 1 sensitive path(s) (Touches a sensitive path (OWNERS, workflows, policies, hive config, security docs, …))
    • src/deploy/stream/fleet/configmap.yaml

Hive did not add the sentinel-alert label because this author is trusted. The finding remains recorded for audit and the dashboard Security tab; set sentinel.trusted_authors_block: true to require the blocking label for trusted authors too.

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

Decision needed: @hanthor should confirm that a public Twitch broadcast may show every hive whose owner never set is_public (the registry defaults it to true at provisioning, src/pkg/hub/saas_hives_api.go:1544), or whether the public-safe view should require an explicit opt-in before DASHBOARD_PATH points at it.

Read the diff against the v5 tree, then the callers. The code does what it says; the one open question is a policy choice, not a defect.

Verified correct

  • publicSafeActivityBlocks / publicSafeActivityEvents (src/pkg/hub/activity_public.go:48-77) rebuild the digest with only !Private items and an empty dropped map before buildActivityView runs, so Totals/Truncated (activity.go:325-326) and EventsDropped (activity_events.go:273) can never carry a private count into the body or the ETag.
  • Repo visibility fails closed on the spoke: publicRepoSet.allows returns false for any repo not in the set (src/pkg/dashboard/battle_log.go:491-494), and hubActivityItems/hubActivityMerges mark Private: !public.allows(repo) (hub_activity.go:88).
  • sameGitHubHost("", "github.com") is true (server.go:893-901), so hives with no GitHubHost are not accidentally excluded; GHE hosts are.
  • Routes: /activity stays behind requireAuth (activity_page.go:48), /api/hub/activity stays behind it (server.go:1728); the two new routes bypass it by registration, and the test exercises srv.mux directly, not the handler in isolation.
  • activity.js: credentials: 'omit' on the public page and the 401→/login redirect is suppressed there, so an anonymous kiosk never bounces.

Open question for the owner (why this is routed, not approved)

The hive-level filter is h.IsPublic && sameGitHubHost(...) (activity.go:407). IsPublic is true when the provisioning request omits it (saas_hives_api.go:1544, "Default to public when the request omits is_public"). The PR body says a hive "with no public flag" is excluded; the test models that as IsPublic=false, which is not what an omitted flag produces. Item-level visibility does fail closed, so no private repo leaks — but every default-public hive's name and public rows will appear on a broadcast its owner never opted into. That is consistent with the public registry and leaderboard today, and may be exactly the intent; it just should be a human's call before DASHBOARD_PATH (src/deploy/stream/fleet/configmap.yaml:20) points the stream at it. Nothing is activated by this PR (STREAM_ENABLED=false, replicas: 0).

Minor, no action needed: !h.Missing in publicActivityHives (activity_public.go:40) is always true because activityRegistry never sets Missing; harmless.

I have not approved or changed anything.

— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive
hivecommons-hive Bot merged commit 2e16d49 into v5 Oct 31, 2026
87 of 94 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the scanner/fix-15966 branch October 31, 2026 23:26
@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

@hivecommons-hive hivecommons-hive Bot removed 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
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. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[scanner] Prepare a disabled-by-default independent hivecommonsfleet broadcast of a public-safe hub activity view

0 participants