Skip to content

✨ feat: serve Matrix lines via authorized /api/matrix/lines and content-free code-lines SSE nudge - #15977

Merged
hivecommons-hive[bot] merged 6 commits into
hivecommons:v5from
thatguywob:scanner/fix-15935
Oct 31, 2026
Merged

hivecommons-hive[bot] merged 6 commits into
hivecommons:v5from
thatguywob:scanner/fix-15935

Conversation

@thatguywob

@thatguywob thatguywob commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Why

Part of #15862 (Activity Monitor Matrix mode). This exposes the line source (#15934) through an authorized pull endpoint and a content-free code-lines SSE nudge on /api/events. Both sit behind dashboard.matrix.

Changes

• GET /api/matrix/lines?since=&max= in src/pkg/dashboard/api_matrix.go:

  • Returns 404 when matrix source is nil or inactive.
  • Returns {"seq": <latest>, "source": "pushed-lines", "lines": [...]}.
  • since=0 returns the backlog (≤2,000); max is clamped to 1–500 (defaults to 200 when since > 0).
  • Auth is enforced via dashboard auth middleware; ?kiosk=1 / ?view=matrix grant nothing. isPublicPath("/api/matrix/lines") is false.
  • Repo allow-list filtering: requires caller role ≥ read; filters lines through cfg.Dashboard.Matrix.RepoAllowed at read time so removing an allow-listed repo immediately hides its lines.
  • Response headers: Cache-Control: no-store.
    • code-lines SSE nudge on /api/events:
  • event: code-lines\ndata: {"seq":N}\n\n carrying only seq and no code content.
  • Coalesced to at most 1 frame per second.
  • Nothing broadcast when flag is off.
    • Tests in src/pkg/dashboard/api_matrix_test.go covering 404-when-off, auth rejection with ?kiosk=1 and ?view=matrix, per-repo filtering, paging/clamp, nudge coalescing with injected fake timers, and content-free frames.
    • Changelog fragment changelog.d/added-15862-matrix-source.md.
    • API reference documentation updated and line citations verified.
    • Route registered in dashboard/openapi.json.

Closes #15935
Part of #15862

— hive: backend=agy


🐝 Hive Agent: contributor | SHA: 9d6e6bfbc

@kubestellar-prow kubestellar-prow Bot added dco-signoff: yes Indicates the PR's author has signed the DCO. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Oct 31, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

@thatguywob this PR is back in your court (stage/072-returned-to-contributor). The hive will not merge it until the head changes.

Review asks:

  • 2 commits are signed off as the hive App instead of you, so a squash merge would misattribute them — set git config user.email to your own address, then run git rebase --exec 'git commit --amend --no-edit --reset-author -s' HEAD~3 && git push --force-with-lease

Reply here or push a new head to this branch (same sign-off); CI and the review swarm re-run automatically and the PR returns to the normal path.

Your relay session received this as a fix-pr task and launched a parallel fix session; your current work continues.

@hivecommons-hive

Copy link
Copy Markdown
Contributor
febbe60

⚠️ Sentinel alert — maintainer review required

Hive flagged this PR (author @thatguywob, head febbe6099a40) 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.

  • remote_code_execution — adds a remote-fetch-and-execute, decoded payload, reverse shell or embedded credential (Adds curl|sh, eval of encoded payloads, reverse shells or embedded private keys)
    • src/pkg/dashboard/matrix_source_test.go

Hive added the sentinel-alert label. While it is present, Hive will not approve this PR, apply LGTM/approval labels, or merge it through any auto-merge lane. Remove the label once reviewed; Hive will not re-apply it unless new commits are pushed. Tune paths and behaviors under sentinel in hive.yaml or the dashboard Security tab.

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

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

@github-actions github-actions Bot added the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Oct 31, 2026
@github-actions github-actions Bot removed the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Oct 31, 2026

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

Correctness review (head febbe609). The handler, auth boundary and nudger logic check out; the blocker is the PR's own test.

1. TestHandleMatrixLines_AuthRejectionAndKiosk fails in CI — route never registered on the test server

src/pkg/dashboard/api_matrix_test.go:62 builds the server with NewServerWithAuth, which only creates an empty mux (server.go:1548); GET /api/matrix/lines is registered in RegisterAPI (api.go:191), which the test never calls. The three 401 assertions pass only because authenticate rejects before mux dispatch; the positive case at api_matrix_test.go:101 gets 404 page not found — see job test (dashboard 2/4): api_matrix_test.go:101: authenticated: code = 404, want 200. Same failure in dashboard 4/4 and both shuffle lanes.

	s := NewServerWithAuth(0, "matrix-secret-123", logger)
	s.RegisterAPI(&Dependencies{})
	s.MatrixObserver(config.MatrixConfig{Enabled: true, Repos: []string{"org/repo"}})

(RegisterAPI(&Dependencies{...}) is how the other dashboard tests do it, e.g. release_channel_selector_test.go with NewServerWithAuth.)

2. Branch conflicts with v5

Tide reports a merge conflict: #15934's files (matrix_source.go, matrix_source_filter.go, matrix_source_test.go, main_sweeps.go, changelog.d/added-matrix-line-source.md) have landed on v5 since the merge-base, and this branch carries its own copy of matrix_source.go differing only by the two s.matrix.setNotify(s.nudgeMatrixLines) calls (matrix_source.go:355,359). A rebase onto v5 should reduce the PR to api_matrix.go, the two setNotify lines, api.go, server.go, the tests and docs.

Advisory (no change required)

handleMatrixLines applies max inside src.Since (matrix_source.go:294-310) before the RepoAllowed filter (api_matrix.go:186-190), and seq in the response is the source's latest seq, not the last line returned. That matches #15935's shape, but a client paging with max must use the last returned line's seq as its next since, not the top-level seq, or it will skip lines. Worth a sentence in the dashboard-misc.md entry so the UI child doesn't trip on it.

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

@hivecommons-hive

Copy link
Copy Markdown
Contributor

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

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

@hivecommons-hive

Copy link
Copy Markdown
Contributor

@thatguywob this PR is back in your court (stage/072-returned-to-contributor). The hive will not merge it until the head changes.

Failing checks:

  • coverage
  • test
  • test (dashboard 2/4)
  • test (dashboard 4/4)
  • test (dashboard shuffle 2/3)
  • test (dashboard shuffle 3/3)

Reply here or push a new head to this branch (same sign-off); CI and the review swarm re-run automatically and the PR returns to the normal path.

Your relay session received this as a fix-pr task and launched a parallel fix session; your current work continues.

@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-2 (folded here because this head already carries its hive review):

Re-review at 05d42db9: the three defects from my earlier review are fixed; the code reads correct against v5. What remains is a maintainer call, not a code fix.

Fixed since febbe609

  • src/pkg/dashboard/api_matrix_test.go:64 now registers GET /api/matrix/lines before s.Handler(), so the authenticated case reaches the handler (was a deterministic 404).
  • dashboard/openapi.json documents the route; openapi_route_parity_test is green.
  • Rebased: the delta vs v5 is now only api.go (+1), api_matrix.go (new), api_matrix_test.go (new), matrix_source.go:355,359 (setNotify), server.go:123 (matrixNudge), docs, changelog. All required checks pass; only tide is pending.

Still open

  1. Body vs code (unchanged). The body says "Per-viewer filtering: drops lines whose repo the caller cannot read." api_matrix.go:174-179 applies only the global cfg.RepoAllowed(l.Repo) allow-list, gated by the all-or-nothing viewerCanReadMatrix (api_matrix.go:131-142: role ≥ read, or bearer token). Every reader sees the same set. That may be the intended design — but since the endpoint serves repository code, the body/docs should say so and a maintainer should confirm it. (Decision question above.)
  2. sentinel-alert still references matrix_source_test.go, which is no longer in this diff at all (it merged via ✨ feat: bounded scrub-drop Matrix line source behind dashboard.matrix #15967). The label will stay until a human removes it; Hive will not merge while it is present.
  3. Scope: commit 05d42db9 edits src/pkg/dashboard/api_event_triggers_test.go:177-178 (points the persistence-failure case at a path under a missing directory). It is unrelated to Matrix. If that shard was red on the rebased branch this is a legitimate fix, but it would be cleaner as its own PR; worth one line in the body either way.

What checks out

  • Auth: route is not in isPublicPath; authenticate (server.go:1983-1996) strips inbound X-Hive-Role and only restores it after proxy proof, so the handler's role read follows the sibling pattern at api_campaigns_jam_live.go:74. ?kiosk=1/?view=matrix grant nothing (tested at api_matrix_test.go:81-97).
  • matrixLinesNudger.nudge (api_matrix.go:40-68): first frame immediate, later frames within 1 s collapse to one trailing frame with the newest seq; nudgeMatrixLines re-checks Active() at send time. The code-lines frame carries only seq.
  • max clamp 1–500, default 200 when since>0, backlog cap when since=0 matches the body.

I have not approved, labelled, or closed anything.

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

Style / maintainability review (head 05d42db, read against #15935). No in-scope blocker; three advisory notes, worst first.

  1. viewerCanReadMatrix duplicates the auth middleware and diverges from the sibling read-gate idiom — src/pkg/dashboard/api_matrix.go:132-144. By the time the mux reaches this handler, authenticate has already stripped and re-set X-Hive-Role on every admitted branch (bearer → RoleOwner at server.go:2195-2207, contributor token → RoleRead, session → live role, open spoke → RoleOwner), so the handler's own Authorization/secureCompare re-check is dead on the served path and only "works" when tests call handleMatrixLines directly. Siblings gate reads with one line and a 403 (api_campaigns_jam_live.go:74: read access required); this handler instead returns 200 {"lines":[]} for role=none (api_matrix.go:184-190), which a client cannot distinguish from "no new lines". Suggested replacement (tests in api_matrix_test.go that call the handler directly would set X-Hive-Role: read):

    -// viewerCanReadMatrix reports whether the caller has at least read role to view matrix lines.
    -func (s *Server) viewerCanReadMatrix(r *http.Request) bool {
    -	role := r.Header.Get("X-Hive-Role")
    -	if role != "" {
    -		return config.RoleAtLeast(role, config.RoleRead)
    -	}
    -	if s != nil && s.authToken != "" {
    -		token := r.Header.Get("Authorization")
    -		if !secureCompare(token, "Bearer "+s.authToken) && !secureCompare(token, s.authToken) {
    -			return false
    -		}
    -	}
    -	return true
    -}
    ...
     func (s *Server) handleMatrixLines(w http.ResponseWriter, r *http.Request) {
     	w.Header().Set("Cache-Control", "no-store")
    +	if !config.RoleAtLeast(r.Header.Get("X-Hive-Role"), config.RoleRead) {
    +		jsonError(w, "read access required", http.StatusForbidden)
    +		return
    +	}

    and drop the if s.viewerCanReadMatrix(r) wrapper around the allow-list loop. Per-repo filtering via cfg.RepoAllowed stays as is.

  2. matrixLinesNudger is a verbatim copy of stageTrackerNudger — api_matrix.go:24-68 vs stage_tracker_nudge.go:16-62; the only difference is the interval constant. [scanner] Serve Matrix lines via authorized /api/matrix/lines and content-free code-lines SSE nudge #15935 asked to copy the pattern, not the 40 lines. One interval field on the existing type removes the duplicate and keeps both nudges in lockstep for future fixes:

    // stage_tracker_nudge.go
     type stageTrackerNudger struct {
    +	interval time.Duration // zero → stageTrackerNudgeInterval
     	mu       sync.Mutex
    ...
    -	if wait := stageTrackerNudgeInterval - now.Sub(n.last); !n.last.IsZero() && wait > 0 {
    +	interval := n.interval
    +	if interval == 0 {
    +		interval = stageTrackerNudgeInterval
    +	}
    +	if wait := interval - now.Sub(n.last); !n.last.IsZero() && wait > 0 {
    // server.go
    -	matrixNudge matrixLinesNudger
    +	matrixNudge stageTrackerNudger // interval set to matrixLinesNudgeInterval in NewServer*

    (or rename the type to a neutral sseNudger). Delete matrixLinesNudger and point the test at the shared type.

  3. Unrelated edit not covered by the PR body or [scanner] Serve Matrix lines via authorized /api/matrix/lines and content-free code-lines SSE nudge #15935 — src/pkg/dashboard/api_event_triggers_test.go:177-178 changes TestEventTriggersRejectInvalidAndUnpersistedRules to use a non-existent parent dir for RuntimeConfigFile/DashboardOverlayFile. It may well be a legitimate flake fix, but nothing in the body says why it rides along with the matrix endpoint. Please either state the reason in the PR body or split it out so git blame on that test does not land on a Matrix feature commit.

Not verified: I could not run go test ./pkg/dashboard/ from this host, so the new tests were read, not executed.

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

docs-currency (read at head 05d42db)

One operator-facing statement goes stale with this PR:

src/docs/operator-reference/README.md:285 describes dashboard.matrix as "Opt-in Activity Monitor Matrix display block (#15862); nothing reads it yet." After this PR the flag is read by GET /api/matrix/lines (src/pkg/dashboard/api_matrix.go:151-200, serving code lines to any read-role/authenticated caller) and gates the code-lines SSE nudge (api_matrix.go:72-85). An operator reading that row would reasonably believe enabling the flag is inert, when it now exposes pushed source lines over an endpoint. Suggested rewording:

| `dashboard.matrix` | Off by default (`enabled: false`, `repos: []`, `exclude_paths: []`). **Experimental.** | Opt-in Activity Monitor Matrix display block (#15862). When active, pushed lines from allow-listed repos are served to authenticated read-role viewers via `GET /api/matrix/lines?since=&max=` (bounded backlog, `Cache-Control: no-store`; `404` when inactive) and `/api/events` emits a content-free `code-lines` nudge (`{"seq":N}`, ≤1/s) telling browsers to pull. `repos` is an explicit exact `owner/name` allowlist (no wildcards, URLs or bare names) and an empty list captures nothing, so `enabled: true` alone stays inactive. `exclude_paths` adds non-empty path globs to the built-in deny-list. There is no `authors` or `private_repos` key: authors are fixed and private repos are always excluded. |

Checked and consistent: dashboard/openapi.json line-item schema matches matrixLine (matrix_source.go:37-46); api-reference/dashboard-misc.md entry and api-reference.md route counts updated; changelog fragment uses a valid added- prefix.

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

Conclusion: the Go change reads correctly to me and matches what the body claims; the only thing holding it is the sentinel label, which a maintainer has to clear. I read api_matrix.go, matrix_source.go, stage_tracker_nudge.go and the auth middleware in server.go at head 59db511.

What I verified

  • Auth. handleMatrixLines gates on X-Hive-Role ≥ read (src/pkg/dashboard/api_matrix.go:89). That header is client-untrusted by construction: the authenticate middleware deletes any inbound value (src/pkg/dashboard/server.go:1985) and only re-sets it after token/session/proxy-proof checks (e.g. :2230 for a trusted profile). /api/matrix/lines is not in isPublicPath, so unauthenticated and ?kiosk=1 callers never reach the handler — TestHandleMatrixLines_AuthRejectionAndKiosk covers it.
  • Off switch. matrixActiveSource() (api_matrix.go:60-78) returns nil unless both the live config and the source's own stored config are Active(), and the handler 404s on nil (:95-97). Allow-list filtering is applied at read time (:124-128), so dropping a repo from RepoAllowed hides its already-buffered lines immediately, as the body states.
  • Clamping. max is clamped to 1–500 (:108-116); with no max and since=0 the limit is matrixBacklogCap (2000), otherwise 200 (:117-119). Since (matrix_source.go:294-309) walks the ring under m.mu and never returns more than limit.
  • No lock cycle. ingest snapshots notify and releases m.mu before calling it (matrix_source.go:222-226); nudgeMatrixLines then takes s.matrixMu only on the no-deps.Config path (api_matrix.go:48). MatrixObserver takes matrixMu → setNotify takes m.mu, so the order is consistently matrixMu → m.mu.
  • SSE frame is content-free. matrixCodeLinesSSEFrame emits only {"seq":N} (api_matrix.go:20-22); stageTrackerNudger gained a configurable interval with the old default preserved when zero (stage_tracker_nudge.go:17,43-46), so the existing stage-tracker nudger is unchanged.

Sentinel. The <!-- hive-sentinel --> comment names src/pkg/dashboard/matrix_source_test.go (remote_code_execution heuristic) at head febbe60. The current head's file list does not include that file; the 21 changed files are api_matrix.go, its test, three small wiring edits, the changelog fragment, openapi.json, and src/docs/api-reference/* line-citation shifts caused by the server.go edit. I have no finding against the code; whether the label comes off is a maintainer call.

Minor, not blocking: the changelog fragment cites #15935 while the body says "Part of #15862" — worth making them agree before merge.

Evidence bundle `#1597732e2d48` sha256:68e7b7fd4249d2d3a5f48a6fc49cf02ff50466a1a8e64f311b22e1d8b5cd841d — download from the dashboard or `hivectl review evidence #15977`.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

⚠️ Hold-gate mergeability: this PR has a real conflict with its base

This PR is hold-gated and has fallen behind its base branch. The hive tried to merge the base in to keep it mergeable while it waits on review, but that merge conflicts and the hive cannot resolve it automatically.

It will stay held and will NOT merge on its own even once reviewed — removing hold alone will not be enough. Someone will need to merge or rebase the base branch in by hand (or resolve the conflict another way) before this PR can merge.

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

Decision needed: @clubanderson this PR still carries sentinel-alert (raised on a file no longer in its diff) and exposes pushed code lines to any role>=read viewer under the global dashboard.matrix.repos allow-list — please confirm that exposure is intended and clear the label, or state the per-viewer scoping you want.

Conclusion (head 05d42db): the two code defects from the previous review are fixed and the branch is now MERGEABLE; the Go changes read correctly against v5. What remains is a maintainer call, not a code fix: the sentinel-alert label, and a PR-body claim the code does not implement.

Since the last review (head febbe609)

  • api_matrix_test.go:64 now registers GET /api/matrix/lines on the test mux, so TestHandleMatrixLines_AuthRejectionAndKiosk can reach the handler.
  • dashboard/openapi.json:1309 documents the route; openapi_route_parity_test no longer has an undocumented path.
  • Rebased: the true delta is api.go (+1), api_matrix.go, api_matrix_test.go, matrix_source.go (+2 setNotify calls), server.go (+matrixNudge), openapi.json, docs, one fragment, and one unrelated test (below).

For the maintainer

  1. The sentinel hit is on a file this PR no longer touches. The alert (remote_code_execution, head febbe609) named src/pkg/dashboard/matrix_source_test.go. After the rebase that file is not in the diff — it landed via #15967. The label stays until a human removes it, and while it is present Hive will not merge this.
  2. Body vs code — still unaddressed. The body says "Per-viewer filtering: drops lines whose repo the caller cannot read." api_matrix.go:184-190 applies only the global cfg.RepoAllowed(l.Repo) allow-list behind an all-or-nothing viewerCanReadMatrix (role ≥ read, api_matrix.go:138-150). Every read-role viewer sees the same lines. Private-repo lines are already dropped at ingest (matrix_source.go:110, !obs.Private), so what is served is public-repo code from allow-listed repos. That may well be the intended design — but it is not what the body or src/docs/api-reference.md describe, and because this endpoint serves repository code to the dashboard, you should confirm it rather than me.

Scope note (low)

src/pkg/dashboard/api_event_triggers_test.go:177-178 is unrelated to Matrix. It is, however, a real fix: config.Save() (src/pkg/config/config.go:7364-7366) removes the target path and retries on write failure, so pointing RuntimeConfigFile at an empty t.TempDir() lets the retry succeed and the "storage failure" assertion cannot hold; a path under a missing parent fails both attempts. Worth keeping, but it belongs in its own commit message explaining that — which the commit does.

What checks out

  • Route is not in isPublicPath (server.go:2474); the auth middleware strips inbound X-Hive-Role and re-sets it only from proof/session/internal token (per api_agent_control.go:512-518), so the handler's role read follows the api_campaigns_jam_live.go:74 pattern. ?kiosk=1 / ?view=matrix grant nothing.
  • matrixLinesNudger.nudge (api_matrix.go:40-68): first frame immediate, later ones coalesce to one trailing frame with the newest seq; nudgeMatrixLines re-checks Active() at send time.
  • max clamp 1–500, default 200 for since>0, backlog cap 2000 for since=0; Since() (matrix_source.go:294) is read under the ring mutex.

I have not closed or approved anything.

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

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Needs a decision, not a merge:

  • the reviewer swarm returned requires_human @05d42db
  • the review found: the reviewer marked this change high-risk
  • reviewer question: @clubanderson this PR still carries the sentinel-alert label and adds an authenticated endpoint that streams pushed code lines; please confirm that "role ≥ read sees every line in the global dashboard.matrix.repos allow-list" (no per-viewer repo scoping, contrary to the PR body) is the intended exposure, and clear the label if so.
  • a sentinel alert is open on this PR
  • the automerge lane will not merge this unattended

Head: verdict requires_human @05d42db, 57/58 checks green, 1 pending, DCO yes, sentinel alert, soak 0s of 10m0s.

How to release it:

  • After reading the verdict, a trusted merger can submit a GitHub Approve review for the current head and the lane clears the hold on its next pass; /hive approve replies on a PR are acknowledged but not consumed. An ordinary contributor cannot release their own PR.
  • Resolve the sentinel alert and have a maintainer clear its label.

Clear the cause and the hive re-evaluates on its next pass; the stage moves to stage/090-ready-for-human-merge, stage/095-pre-merge-soak or the merge queue on its own. Approval does not bypass CI, hold labels or other merge gates.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

@thatguywob this PR is back in your court (stage/072-returned-to-contributor). The hive will not merge it until the head changes.

Review asks:

  • the review swarm requested changes

Reply here or push a new head to this branch (same sign-off); CI and the review swarm re-run automatically and the PR returns to the normal path.

Your relay could not take this as a fix-pr task (Hub is not the active polling slot); the hive will retry it from your relay fix queue.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

@thatguywob the hive has adopted this PR (stage/074-adopted-by-hive): CI stayed red for 2h after the nudge and the relay nudge went unanswered. The hive will rebase this branch on v5 and fix CI here; your commits and sign-off stay. Push a new head yourself at any time and the hive yields it back to you.

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

Decision needed: @clubanderson #15977 still carries sentinel-alert; please confirm that any viewer with role ≥ read may pull every line in the global dashboard.matrix.repos allow-list via GET /api/matrix/lines (no per-viewer repo scoping), and clear the label if that exposure is intended.

Re-review at 59db511: the delta since 05d42db reads correct against v5. Nothing here needs a code change — the only thing left is the same maintainer call as before, which I am not restating as a new finding.

What changed since the last head, and what I verified:

  • Hard role gate — src/pkg/dashboard/api_matrix.go:89-92 now returns 403 unless X-Hive-Role ≥ read, replacing the earlier viewerCanReadMatrix fallback that let an anonymous caller on an open spoke through. I read authenticate (src/pkg/dashboard/server.go:1955-2150): the inbound header is stripped at :1977-1979, and every authenticated branch sets a server-side role — open spoke → RoleOwner (:2049-2050), session → live role (:2026-2029), shared token → RoleOwner (:2095), hub proxy → proven inbound role (:1988-1996). So the gate cannot be satisfied by a client-forged header, and it does not lock out any deployment shape.
  • Nudger dedup — the bespoke matrixLinesNudger is gone; stageTrackerNudger gained an interval field (stage_tracker_nudge.go:17, defaulting to the old 2 s at :43-46) and the matrix uses a 1 s instance (server.go:1557). Behaviour of the existing stage-tracker nudger is unchanged (zero interval → previous constant).
  • Notify wiring — matrix_source.go:355,359 set the notify hook on both the create and reconfigure paths; Observe snapshots m.notify under the lock and calls it after unlock (:222-227), so the broadcast does not run under m.mu.
  • Paging cursor — Since returns the source's global m.seq, not the last returned line's seq, so max-truncated pages must advance by the last line. The PR documents exactly that (src/docs/api-reference/dashboard-misc.md, /api/matrix/lines row), so this is a contract, not a defect.
  • Body vs diff — changelog.d/added-15862-matrix-source.md and the dashboard/openapi.json entry both exist as claimed; isPublicPath does not list the route.

On the sentinel alert: the heuristic hit named src/pkg/dashboard/matrix_source_test.go at head febbe609. That file is no longer in this PR's diff against v5 — it landed separately via #15982 — so the specific thing the sentinel flagged is not part of what would merge here. The label is still a maintainer-clears-it gate, and the remaining question (global allow-list read exposure for any read-role viewer) is unchanged from my 05d42db review.

I have not approved, labelled, or merged anything.

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

@hivecommons-hive

Copy link
Copy Markdown
Contributor

@thatguywob this PR is back in your court (stage/072-returned-to-contributor). The hive will not merge it until the head changes.

Review asks:

  • the review swarm requested changes

Reply here or push a new head to this branch (same sign-off); CI and the review swarm re-run automatically and the PR returns to the normal path.

Queued in your relay fix queue (0 waiting): fixes are handed out before new work as soon as you have capacity.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

/lgtm

Posted by @clubanderson from the Hive dashboard; the merge gate decides from here.

@kubestellar-prow

Copy link
Copy Markdown
Contributor

@hivecommons-hive[bot]: changing LGTM is restricted to collaborators

Details

In response to this:

/lgtm

Posted by @clubanderson from the Hive dashboard; the merge gate decides from here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

/approve

Posted by @clubanderson from the Hive dashboard; the merge gate decides from here.

@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: hivecommons-hive[bot]
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

@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 tree at b150fd6; this looks correct to me.

What I verified:

  • Auth gate. /api/matrix/lines is not in isPublicPath (src/pkg/dashboard/server.go:2359), and the auth middleware strips inbound X-Hive-User/X-Hive-Role at server.go:1984-1985 before re-setting them only from a verified session/proxy proof. So the RoleAtLeast(..., RoleRead) check at api_matrix.go:88 cannot be satisfied by a client-supplied header, and ?kiosk=1 / ?view=matrix grant nothing — matching TestHandleMatrixLines_AuthRejectionAndKiosk.
  • Flag off ⇒ 404. matrixActiveSource (api_matrix.go:60-77) requires both the effective config and the source's own stored config to be Active(), and MatrixObserver (matrix_source.go:340+) already nils/stops the source when the flag goes off, so a stale backlog cannot be served after deactivation.
  • Allowlist at read time. Lines are filtered through cfg.RepoAllowed in the handler (api_matrix.go:121-125) in addition to the ingest-time admits gate (matrix_source.go:108-111), so removing a repo from the allowlist hides already-buffered lines immediately, as the body states.
  • Nudge lock order. matrixSource invokes notify after releasing m.mu (matrix_source.go:222-226), and nudgeMatrixLines only takes s.matrixMu when deps.Config is nil, so the coalescer calling broadcastFrame from the ingest goroutine does not nest locks. The interval field added to stageTrackerNudger defaults to the existing 2 s when zero (stage_tracker_nudge.go:43-46), so the stage-tracker path is unchanged.
  • Paging contract. Since applies limit before the handler's repo filter and the top-level seq is the source's latest, so a page truncated by max can return fewer than max lines and since=<resp.seq> would skip the remainder. The api-reference row already tells clients to use the last returned line's seq as the cursor, so this is documented rather than a defect — just noting it for whoever writes the browser consumer in #15862.

The large src/docs/api-reference/*.md churn is line-citation renumbering from the citation checker after the server.go struct change, not content edits.

Not approving (that is a human's signature); flagging as ready for a maintainer's read.

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

@github-actions github-actions Bot added the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Oct 31, 2026
@github-actions github-actions Bot removed the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Oct 31, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

@thatguywob this PR is back in your court (stage/072-returned-to-contributor). The hive will not merge it until the head changes.

Review asks:

  • the branch conflicts with the base and needs a rebase

Reply here or push a new head to this branch (same sign-off); CI and the review swarm re-run automatically and the PR returns to the normal path.

Your relay could not take this as a fix-pr task (Hub is not the active polling slot); the hive will retry it from your relay fix queue.

@thatguywob

Copy link
Copy Markdown
Contributor Author

hive-base-moved: merged upstream v5 (2d07449)


🐝 Hive Agent: contributor | SHA: 6dc848d

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

Looks correct to me. What I verified against v5:

  • Auth. handleMatrixLines trusts X-Hive-Role (api_matrix.go:90), which is the same pattern as ~35 other dashboard handlers; the auth middleware strips any client-supplied value at server.go:1983 and re-sets it from verified identity (:1994-2100), so the header cannot be forged on /api/matrix/lines. The route is registered on the authenticated mux (api.go:191) and is not in isPublicPath.
  • Locking. matrixSource invokes notify after releasing m.mu (matrix_source.go:222-226), and setNotify only takes m.mu (:329), so wiring it from MatrixObserver under s.matrixMu (:355,359) and having the callback take s.matrixMu in currentMatrixConfig cannot deadlock. cfg is an atomic.Pointer (:59), read lock-free.
  • Bounds. since absent/0 without max → matrixBacklogCap (2000, :22); max clamped to 1–500; Since (:294) already bounds by the ring. Allow-list is re-applied at read time via cfg.RepoAllowed (config/dashboard_matrix.go:26), so a repo removed from the list disappears immediately as the body says.
  • Nudge. Reusing stageTrackerNudger with a per-instance interval (stage_tracker_nudge.go:17,43-47) keeps the existing 2s stage-tracker default (zero → stageTrackerNudgeInterval) and gives this frame a 1s coalesce; the frame carries only seq.

No overlap with #16020 (display side; disjoint file sets), so the two compose rather than conflict. The large src/docs/api-reference/* churn is line-citation renumbering from the citation fixer, not content.

One optional nit, not a defect: an unparsable since (api_matrix.go:103-107) is silently treated as 0 and returns the full backlog; a 400 would make client bugs visible sooner.

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

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Ready for a human merge: verdict approved @32e2d48, 59/59 checks green, DCO yes, soak 10m0s elapsed. Blocked only by role/contributor (below require_tiers).

The hive never approves on your behalf: /lgtm /approve (or merge) if you accept it.

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

Approved by @clubanderson for Hive auto-merge on green CI.

Approved from the Hive dashboard by @clubanderson as the owner decision on a Ready-for-human-merge pull request; the hive's merge sweep merges it on green CI.

@kubestellar-prow

Copy link
Copy Markdown
Contributor

@hivecommons-hive[bot]: changing LGTM is restricted to collaborators

Details

In response to this:

Approved by @clubanderson for Hive auto-merge on green CI.

Approved from the Hive dashboard by @clubanderson as the owner decision on a Ready-for-human-merge pull request; the hive's merge sweep merges it on green CI.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@hivecommons-hive hivecommons-hive Bot added the lgtm Indicates that a PR is ready to be merged. label Oct 31, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

Hive queued this PR but could not set the prow/lgtm commit status, so Prow may strip the lgtm label and the auto-merge queue may not hold.

@hivecommons-hive
hivecommons-hive Bot merged commit d5a7c57 into hivecommons:v5 Oct 31, 2026
69 of 70 checks passed
hivecommons-hive Bot added a commit that referenced this pull request Oct 31, 2026
GET /api/matrix/lines applied max inside matrixSource.Since before the
per-repo allowlist filter, so a window whose oldest raw lines belonged to
repos the caller cannot see came back short or empty. A client following
the documented "next since = last returned line's seq" contract then
stalled on the same cursor (or, falling back to the top-level seq,
skipped lines).

Add matrixSource.SinceMatching(seq, limit, keep), which counts only kept
lines toward limit; Since delegates with a nil predicate. The handler now
passes cfg.RepoAllowed into the scan. Document the paging contract in the
dashboard API reference.

Fixes #15979

Hive-Run: #15979
Hive-Plan: review-backlog correctness finding from PR #15977
Hive-Spec: matrix-lines-paging#15935

Claude-Session: https://claude.ai/code/session_01HRH6kkPCaErih6zio4iUQ7

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>
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. lgtm Indicates that a PR is ready to be merged. 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] Serve Matrix lines via authorized /api/matrix/lines and content-free code-lines SSE nudge

1 participant