Repository navigation
✨ feat: serve Matrix lines via authorized /api/matrix/lines and content-free code-lines SSE nudge - #15977
Conversation
|
@thatguywob this PR is back in your court ( Review asks:
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 |
9d6e6bf to
febbe60
Compare
febbe60
|
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of No conflicting open PRs or same-file overlaps were found. |
There was a problem hiding this comment.
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
|
Hive filed review findings that do not block this PR as backlog items:
Cap: 10 backlog item(s) per PR per day. |
|
@thatguywob this PR is back in your court ( Failing checks:
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 |
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. Review findings from Re-review at Fixed since
|
|
febbe60 to
83fb6cd
Compare
There was a problem hiding this comment.
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:64now registersGET /api/matrix/lineson the test mux, soTestHandleMatrixLines_AuthRejectionAndKioskcan reach the handler.dashboard/openapi.json:1309documents the route;openapi_route_parity_testno longer has an undocumented path.- Rebased: the true delta is
api.go(+1),api_matrix.go,api_matrix_test.go,matrix_source.go(+2setNotifycalls),server.go(+matrixNudge),openapi.json, docs, one fragment, and one unrelated test (below).
For the maintainer
- The sentinel hit is on a file this PR no longer touches. The alert (
remote_code_execution, headfebbe609) namedsrc/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. - Body vs code — still unaddressed. The body says "Per-viewer filtering: drops lines whose repo the caller cannot read."
api_matrix.go:184-190applies only the globalcfg.RepoAllowed(l.Repo)allow-list behind an all-or-nothingviewerCanReadMatrix(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 orsrc/docs/api-reference.mddescribe, 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 inboundX-Hive-Roleand re-sets it only from proof/session/internal token (perapi_agent_control.go:512-518), so the handler's role read follows theapi_campaigns_jam_live.go:74pattern.?kiosk=1/?view=matrixgrant nothing. matrixLinesNudger.nudge(api_matrix.go:40-68): first frame immediate, later ones coalesce to one trailing frame with the newestseq;nudgeMatrixLinesre-checksActive()at send time.maxclamp 1–500, default 200 forsince>0, backlog cap 2000 forsince=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
|
Needs a decision, not a merge:
Head: verdict requires_human @05d42db, 57/58 checks green, 1 pending, DCO yes, sentinel alert, soak 0s of 10m0s. How to release it:
Clear the cause and the hive re-evaluates on its next pass; the stage moves to |
|
@thatguywob this PR is back in your court ( Review asks:
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 |
|
@thatguywob the hive has adopted this PR ( |
There was a problem hiding this comment.
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-92now returns 403 unlessX-Hive-Role ≥ read, replacing the earlierviewerCanReadMatrixfallback that let an anonymous caller on an open spoke through. I readauthenticate(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
matrixLinesNudgeris gone;stageTrackerNudgergained anintervalfield (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,359set the notify hook on both the create and reconfigure paths;Observesnapshotsm.notifyunder the lock and calls it after unlock (:222-227), so the broadcast does not run underm.mu. - Paging cursor —
Sincereturns the source's globalm.seq, not the last returned line's seq, somax-truncated pages must advance by the last line. The PR documents exactly that (src/docs/api-reference/dashboard-misc.md,/api/matrix/linesrow), so this is a contract, not a defect. - Body vs diff —
changelog.d/added-15862-matrix-source.mdand thedashboard/openapi.jsonentry both exist as claimed;isPublicPathdoes 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
|
@thatguywob this PR is back in your court ( Review asks:
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. |
|
/lgtm Posted by @clubanderson from the Hive dashboard; the merge gate decides from here. |
|
@hivecommons-hive[bot]: changing LGTM is restricted to collaborators DetailsIn response to this:
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. |
|
/approve Posted by @clubanderson from the Hive dashboard; the merge gate decides from here. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: hivecommons-hive[bot] 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.
Read the new handler against the tree at b150fd6; this looks correct to me.
What I verified:
- Auth gate.
/api/matrix/linesis not inisPublicPath(src/pkg/dashboard/server.go:2359), and the auth middleware strips inboundX-Hive-User/X-Hive-Roleatserver.go:1984-1985before re-setting them only from a verified session/proxy proof. So theRoleAtLeast(..., RoleRead)check atapi_matrix.go:88cannot be satisfied by a client-supplied header, and?kiosk=1/?view=matrixgrant nothing — matchingTestHandleMatrixLines_AuthRejectionAndKiosk. - Flag off ⇒ 404.
matrixActiveSource(api_matrix.go:60-77) requires both the effective config and the source's own stored config to beActive(), andMatrixObserver(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.RepoAllowedin the handler (api_matrix.go:121-125) in addition to the ingest-timeadmitsgate (matrix_source.go:108-111), so removing a repo from the allowlist hides already-buffered lines immediately, as the body states. - Nudge lock order.
matrixSourceinvokesnotifyafter releasingm.mu(matrix_source.go:222-226), andnudgeMatrixLinesonly takess.matrixMuwhendeps.Configis nil, so the coalescer callingbroadcastFramefrom the ingest goroutine does not nest locks. Theintervalfield added tostageTrackerNudgerdefaults to the existing 2 s when zero (stage_tracker_nudge.go:43-46), so the stage-tracker path is unchanged. - Paging contract.
Sinceapplieslimitbefore the handler's repo filter and the top-levelseqis the source's latest, so a page truncated bymaxcan return fewer thanmaxlines andsince=<resp.seq>would skip the remainder. The api-reference row already tells clients to use the last returned line'sseqas 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
|
@thatguywob this PR is back in your court ( Review asks:
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 |
|
hive-base-moved: merged upstream v5 (2d07449) 🐝 Hive Agent: |
There was a problem hiding this comment.
Looks correct to me. What I verified against v5:
- Auth.
handleMatrixLinestrustsX-Hive-Role(api_matrix.go:90), which is the same pattern as ~35 other dashboard handlers; the auth middleware strips any client-supplied value atserver.go:1983and 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 inisPublicPath. - Locking.
matrixSourceinvokesnotifyafter releasingm.mu(matrix_source.go:222-226), andsetNotifyonly takesm.mu(:329), so wiring it fromMatrixObserverunders.matrixMu(:355,359) and having the callback takes.matrixMuincurrentMatrixConfigcannot deadlock.cfgis anatomic.Pointer(:59), read lock-free. - Bounds.
sinceabsent/0withoutmax→matrixBacklogCap(2000,:22);maxclamped to 1–500;Since(:294) already bounds by the ring. Allow-list is re-applied at read time viacfg.RepoAllowed(config/dashboard_matrix.go:26), so a repo removed from the list disappears immediately as the body says. - Nudge. Reusing
stageTrackerNudgerwith a per-instanceinterval(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 onlyseq.
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
|
Ready for a human merge: verdict approved @32e2d48, 59/59 checks green, DCO yes, soak 10m0s elapsed. Blocked only by The hive never approves on your behalf: |
There was a problem hiding this comment.
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.
|
@hivecommons-hive[bot]: changing LGTM is restricted to collaborators DetailsIn response to this:
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. |
|
Hive queued this PR but could not set the |
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>
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:{"seq": <latest>, "source": "pushed-lines", "lines": [...]}.since=0returns the backlog (≤2,000);maxis clamped to 1–500 (defaults to 200 whensince > 0).?kiosk=1/?view=matrixgrant nothing.isPublicPath("/api/matrix/lines")is false.cfg.Dashboard.Matrix.RepoAllowedat read time so removing an allow-listed repo immediately hides its lines.Cache-Control: no-store.•
code-linesSSE nudge on/api/events:event: code-lines\ndata: {"seq":N}\n\ncarrying only seq and no code content.• Tests in
src/pkg/dashboard/api_matrix_test.gocovering 404-when-off, auth rejection with?kiosk=1and?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