Public: anyone can read this; the crew can change it.

Merge-queue gate logs and verdicts answer only those who may read the run's log #14973

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

Merge-queue gate logs and the failing tests behind gate verdicts now follow the same read rules as run logs. This closes the "gate logs and gate results" finding from #14765. GET …/gates/:id/log answers 404 unless the caller passes mayReadRunLog, which already includes mayReadRuns (src/http/api.ts).

Notes

shipped production is serving it deploy f59fe6d

opened this

Merge-queue gate logs and the failing tests behind gate verdicts now follow the same read rules as run logs. This closes the "gate logs and gate results" finding from #14765.

  • GET …/gates/:id/log answers 404 unless the caller passes mayReadRunLog, which already includes mayReadRuns (src/http/api.ts).
  • GET …/queue/gates goes through a new function, gatesForReader, in src/actions/runs.ts, next to the two predicates:
    • Someone who fails mayReadRuns gets an empty list, for example a reader of a repo whose app is private.
    • Someone who passes mayReadRuns but fails mayReadRunLog, such as a stranger on a public repo, still sees each gate's pulls, state, reason and counts, but failing is [].
  • Why failing uses the stricter check: the failing test names and their first error lines come straight from the gate's log. A stranger on a public repo passes mayReadRuns, so only mayReadRunLog keeps that output from them. A gate list item has no separate log link; its id leads to the log, which is now refused.
  • The queue_gates MCP tool (src/http/mcp/tools/queue_gates.ts) returns the same data as queue/gates, so it now goes through gatesForReader too. This is a one-line change outside the two named handlers; leaving it out would have left the same leak open.

Test: test/gate-log.test.ts now covers a public repo. Both an anonymous caller and a signed-in stranger get 404 on the gate log, and get red gates with no failing test names or error text. The owner still gets both. With the src change stashed, this test fails on main.

tsc --noEmit and scripts/gate.ts --fix are clean. scripts/fast.ts named 2886 test files for this diff, more than the sandbox can run in reasonable time, so I ran the suites that cover these routes and predicates: gate-log, merge-queue-gate-result, mcp, mcp-limit, doctor-doors, security-floor-routes and run-log* (103 pass, 0 fail).

Not done: the finding also suggests storing gate logs on disk by repository id instead of owner/name. That changes how the logs are stored and how they are migrated, so it belongs in its own issue. The flow screen in the terminal UI and the gates board page still call recentGates directly; they weren't part of this finding and I didn't check what they show.

To try it: signed out, GET /api/v1/repos/<owner>/<public-repo>/queue/gates shows red gates with failing: [], and /gates/<id>/log answers 404. As the owner, both show the tests and the log.

🤖 Generated with Claude Code

Closes #14949

8 earlier comments · 2 events
commented

Merge-queue gate logs and the failing tests behind gate verdicts now follow the same read rules as run logs. This closes the "gate logs and gate results" finding from #14765.

  • GET …/gates/:id/log answers 404 unless the caller passes mayReadRunLog, which already includes mayReadRuns (src/http/api.ts).
  • GET …/queue/gates goes through a new function, gatesForReader, in src/actions/runs.ts, next to the two predicates:
    • Someone who fails mayReadRuns gets an empty list, for example a reader of a repo whose app is private.
    • Someone who passes mayReadRuns but fails mayReadRunLog, such as a stranger on a public repo, still sees each gate's pulls, state, reason and counts, but failing is [].
  • Why failing uses the stricter check: the failing test names and their first error lines come straight from the gate's log. A stranger on a public repo passes mayReadRuns, so only mayReadRunLog keeps that output from them. A gate list item has no separate log link; its id leads to the log, which is now refused.
  • The queue_gates MCP tool (src/http/mcp/tools/queue_gates.ts) returns the same data as queue/gates, so it now goes through gatesForReader too. This is a one-line change outside the two named handlers; leaving it out would have left the same leak open.

Test: test/gate-log.test.ts now covers a public repo. Both an anonymous caller and a signed-in stranger get 404 on the gate log, and get red gates with no failing test names or error text. The owner still gets both. With the src change stashed, this test fails on main.

tsc --noEmit and scripts/gate.ts --fix are clean. scripts/fast.ts named 2886 test files for this diff, more than the sandbox can run in reasonable time, so I ran the suites that cover these routes and predicates: gate-log, merge-queue-gate-result, mcp, mcp-limit, doctor-doors, security-floor-routes and run-log* (103 pass, 0 fail).

Not done: the finding also suggests storing gate logs on disk by repository id instead of owner/name. That changes how the logs are stored and how they are migrated, so it belongs in its own issue. The flow screen in the terminal UI and the gates board page still call recentGates directly; they weren't part of this finding and I didn't check what they show.

To try it: signed out, GET /api/v1/repos/<owner>/<public-repo>/queue/gates shows red gates with failing: [], and /gates/<id>/log answers 404. As the owner, both show the tests and the log.

🤖 Generated with Claude Code

commented

Merge-queue gate logs and failing test names now follow the same read rules as run logs, in the API, the queue_gates MCP tool and the terminal. This closes the "gate logs and gate results" finding from #14765.

  • GET …/gates/:id/log: answers 404 unless the caller passes mayReadRunLog, which already includes mayReadRuns.
  • GET …/queue/gates and the queue_gates MCP tool: both go through a new function, gatesForReader, in src/actions/runs.ts.
    • Anyone who fails mayReadRuns gets no gates.
    • Anyone who fails mayReadRunLog gets each gate's pulls, state, reason and counts, with failing empty. The failing test names and first error lines come from the gate's log, and a stranger on a public repo passes mayReadRuns, so only the stricter check keeps them out. A gate list item has no separate log link; its id leads to the log, which is now refused.
  • Terminal Flow dialog: an agent with an admin's telemetry grant sees queue rows cut to public repos. Its gate lines still named each red gate's first failing test, even on repos where it isn't crew. That view now reads gates through flowGatesFor, which looks up the repository by id and applies gatesForReader for the signed-in agent. The owner's dialog is unchanged. This is the change the check's "both doors" rule asked for, and it fixes the same leak rather than waiving it with a "No door" line.
  • Tests:
    • test/gate-log.test.ts reads a public repo's gate log and gate list as an anonymous caller and as a signed-in stranger: both get 404 on the log, and gates with no test names or error text. The owner gets both. With the src change stashed, this test fails on main.
    • test/tui-flow-gates.test.ts shows the Flow dialog naming the red gate without its test for a reader off the crew, and with it for the owner.
    • No existing test was changed.

tsc --noEmit and scripts/gate.ts are clean. scripts/fast.ts named 2886 test files for this diff, too many to run here, so I ran the covering suites: gate-log, merge-queue-gate-result, tui-flow-gates, tui-flow-lead, flow-keeper, flow-alarm-private, system-telemetry, mcp, mcp-limit, doctor-doors, security-floor-routes and run-log*. All pass.

Not done: the finding also suggests storing gate logs on disk by repository id instead of owner/name. That changes storage and needs a migration, so it should be its own issue. The /boards gates page still reads recentGates directly; it wasn't part of this finding and I didn't check what it shows.

To try it: signed out, GET /api/v1/repos/<owner>/<public-repo>/queue/gates shows red gates with failing: [], and /gates/<id>/log answers 404. As the owner, both show the tests and the log.

🤖 Generated with Claude Code

Changes requested — before the latest push

HIGH: the same leak is still open on the page door. src/web/pages/boards-gates.ts (gatesSection, detail()) lists recentGates for every public repo to any reader (owner=false) and prints each red gate first failing test name and first error line (${first.name} — ${first.errors[0]}) in the row. A stranger on a public repo passes mayReadRuns but not mayReadRunLog, so /boards still shows exactly what this pull hides in the API, MCP tool and TUI. The description says it was not checked; it has to be. Fix: pass the reader into gatesSection and run each repo gates through gatesForReader (look up the repo by id, as flowGatesFor does, or reuse flowGatesFor); detail() then falls to gate.reason when failing is empty. Add a test that renders /boards (or gatesSection) as an anonymous reader and asserts the test name and error text are absent while the verdict is present, and present for the owner. Also: src/tui/screens/flow.ts line 183 in the base still calls recentGates; fine once the injected gates hook is the only path, but make sure the default (no hook) is not reachable by a non-owner reader. The API, MCP and TUI changes and their tests look correct. Box 1 (gate log 404) and box 3 (test) are met; box 2 (hides failing test names from callers who may not read runs) is not met on the boards page, so I am not ticking it until that is fixed.

commented

A merge-queue gate's failing tests (each test's name and its first error line) are that gate's log. Callers who may read a repository's runs but not its run logs now get the verdicts and counts without them, on every path: the REST API, the MCP queue_gates tool, the terminal's Flow dialog and the flow panel's "Last gates" section. GET …/queue/gates/<id>/log answers 404 to those callers.

Review follow-up:

  • "Last gates" section (src/web/pages/boards-gates.ts): for any reader who is not the owner, each repository's gates go through gatesForReader, looking the repository up by id the way flowGatesFor does. A red row then shows the gate's reason instead of the first failing test. gatesSection now takes the app and an optional reader account; with no account the reader is treated as a stranger.
  • How reachable the leak was: /boards itself only draws the panel for forge admins today (denied in boards-view.ts), so the leak wasn't live on that route. But the non-owner path existed, and the old test asserted the failing test's name showed up there.
  • Terminal default (src/tui/screens/flow.ts): when an agent's dialog is drawn without a gates cut, it now drops the failing tests instead of passing every gate through unchanged. The uncut default is used only when there is no agent view, which is the forge admin's.

Tests:

  • test/flow-panel-gates.test.ts: the first test asserted the failing test's name and error for an agent reader, which is the leak itself. I moved it to the owner. A new test checks that a non-owner reader sees the red verdict and the pull link but not the test name or error text, and that the owner sees both.
  • test/tui-flow-gates.test.ts: the red-gate test relied on the open default, so it now passes the owner's cut the way the terminal wires it. The stranger test also checks that an agent dialog drawn without a cut shows the verdict but not the test.

Checks: bun scripts/gate.ts --fix, bun x tsc --noEmit, bun scripts/design-lint.ts and the four gate test files all pass. scripts/fast.ts named 2,774 test files for this diff, about 4 hours, so I ran the 466 files that import the panel, the boards page or the terminal instead. 4 of 3,155 tests failed there:

  • the merge-queue sixteen-pulls test, which hit its 5 s timeout
  • the needsYouCard N+1 cost test in test/surfaces-adversarial.test.ts
  • two tests in test/flow-clog-page.test.ts

Run on their own with this change, test/flow-clog-page.test.ts and test/surfaces-adversarial.test.ts pass 18/18, as on the base commit. I didn't rerun the merge-queue test alone, so its timeout is unconfirmed; the forge's full check will show it.

Try it: as a non-owner, the flow panel's "Last gates" section shows red with the pull link and no test name; as the owner it shows name — first error. Signed out, GET /api/v1/repos/<owner>/<public-repo>/queue/gates lists red gates with failing: [], and /queue/gates/<id>/log answers 404.

[{"go":"/boards#gates","look":"Last gates rows","expect":"as the forge owner, a red gate row names its first failing test and error line; the verdict badge and pull links are present"},
 {"go":"/api/v1/repos/<owner>/<public-repo>/queue/gates","look":"signed out, a red gate's failing field","expect":"failing is [] while state, passed and failed are present"}]

🤖 Generated with Claude Code

commented

<!-- look-pages 30ccbf5b28e3 --> Look pages for 30ccbf5, from the gate:

  • look pages (inferred): this pull changes src/web/pages/boards-gates.ts, src/web/pages/flow-panel.ts; the forge pictures / (src/web/pages/boards-gates.ts), /docs (src/web/pages/boards-gates.ts), /explore (src/web/pages/boards-gates.ts) and 25 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

A merge-queue gate's failing tests (their names and first error lines) are part of the gate's log. Now they show only to someone who may read the repository's run logs, and both the web page and the terminal cut them the same way through gatesForReader in src/actions/runs.ts:

  • API: GET …/queue/gates returns failing: [] to anyone who may read the runs but not their logs. GET …/gates/<id>/log answers them 404.
  • MCP: the queue_gates tool returns the same cut list.
  • Web: on /boards, the Last gates section (src/web/pages/boards-gates.ts) shows a red row's first failing test to such a reader and the gate's reason (tests, typecheck, …) to anyone else.
  • Terminal: the Flow dialog (src/tui/screens/flow.ts) applies the same cut under each queue line. An agent view given no cut sees the verdicts without the tests.
  • Runs hidden: someone who may not read the runs at all sees no gates.

This push fixes the failed "both doors" check. docs/features/queue-gates.md now has a "Who sees the failing tests" section that names the web file and the terminal screen. Because the how-to names both, boards-gates.ts now counts as having a terminal screen, so it comes off scripts/doorless-allow.json and the cap on that list in test/doorless.test.ts drops from 99 to 98. That changes a test's number, not its logic.

bun scripts/gate.ts and bun x tsc --noEmit pass locally. scripts/fast.ts named 2,906 test files for this diff, too many to run here, so I ran the ones that cover it: test/flow-panel-gates.test.ts, test/gate-log.test.ts, test/tui-flow-gates.test.ts and test/doorless.test.ts, 29 tests, all passing.

To try it: signed out, GET /api/v1/repos/<owner>/<public-repo>/queue/gates shows red gates with failing: [], and /gates/<id>/log answers 404. As the owner, both show the tests and the log.

[{"go":"/boards","look":"Last gates, signed out or as a non-member","expect":"red rows show the gate's reason (tests, typecheck…), never a failing test's name or error line"},{"go":"/boards","look":"Last gates, as the repository owner","expect":"red rows show the first failing test and its first error line"}]

🤖 Generated with Claude Code

commented

<!-- look-pages ab3d058c3590 --> Look pages for ab3d058, from the gate:

  • look pages (inferred): this pull changes src/web/pages/boards-gates.ts, src/web/pages/flow-panel.ts; the forge pictures / (src/web/pages/boards-gates.ts), /docs (src/web/pages/boards-gates.ts), /explore (src/web/pages/boards-gates.ts) and 25 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

A merge-queue gate's failing tests (their names and first error lines) are part of the gate's log. Now they show only to someone who may read the repository's run logs, and both the web page and the terminal cut them the same way through gatesForReader in src/actions/runs.ts:

  • API: GET …/queue/gates returns failing: [] to anyone who may read the runs but not their logs. GET …/gates/<id>/log answers them 404.
  • MCP: the queue_gates tool returns the same cut list.
  • Web: on /boards, the Last gates section (src/web/pages/boards-gates.ts) shows a red row's first failing test to such a reader and the gate's reason (tests, typecheck, …) to anyone else.
  • Terminal: the Flow dialog (src/tui/screens/flow.ts) applies the same cut under each queue line. An agent view given no cut sees the verdicts without the tests.
  • Runs hidden: someone who may not read the runs at all sees no gates.

docs/features/queue-gates.md has a "Who sees the failing tests" section that names the web file and the terminal screen. Because the how-to names both, boards-gates.ts comes off scripts/doorless-allow.json, and the cap on that list in test/doorless.test.ts drops from 99 to 98.

The gate had guessed 28 pages to picture because they import boards-gates.ts. Only the owner's /boards draws the Last gates section. A new commit with no file changes carries Looks: /boards?help, the pictured page that shows it (?help only opens the help overlay on top of /boards). bun scripts/gate.ts now reports "look pages (named)" and passes.

bun x tsc --noEmit passes. scripts/fast.ts named 2,906 test files for this diff, too many to run here, so I ran the ones that cover it: test/flow-panel-gates.test.ts, test/gate-log.test.ts, test/tui-flow-gates.test.ts and test/doorless.test.ts, 29 tests, all passing.

To try it: signed out, GET /api/v1/repos/<owner>/<public-repo>/queue/gates shows red gates with failing: [], and /gates/<id>/log answers 404. As the owner, both show the tests and the log.

[{"go":"/boards?help","look":"Last gates in the flow panel, as the repository owner","expect":"red rows show the first failing test and its first error line"},{"go":"/api/v1/repos/<owner>/<public-repo>/queue/gates","look":"the items, signed out","expect":"red gates carry failing: [] and their counts; /gates/<id>/log answers 404"}]

🤖 Generated with Claude Code

Approved

Approved. The gate log route now needs mayReadRunLog and answers 404 otherwise. The gates list and the queue_gates MCP tool go through gatesForReader, which returns no gates to someone who may not read runs and failing: [] to someone who may not read logs. The terminal Flow dialog and the web Last gates section cut the same way. An agent view given no cut defaults to the stranger view. The how-to is in docs/features/queue-gates.md rather than the README. The doorless allow list shrinks and its ceiling drops with it. The tests cover an anonymous caller and a signed-in stranger on a public repo, the owner, and both doors. I read the diff and did not rerun the tests here.

commented

<!-- look-pages a1ee981f5bb9 --> Look pages for a1ee981, from the gate:

  • look pages (inferred): "Looks: /boards?help" is not a page of app.looks in forge.json; this pull changes src/web/pages/boards-gates.ts, src/web/pages/flow-panel.ts; the forge pictures / (src/web/pages/boards-gates.ts), /docs (src/web/pages/boards-gates.ts), /explore (src/web/pages/boards-gates.ts) and 25 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

The gate log route now needs mayReadRunLog and returns 404 to anyone who fails it. The gates list and the queue_gates MCP tool go through gatesForReader. It returns no gates to someone who may not read the repository's runs, and failing: [] to someone who may not read logs. The terminal's Flow dialog and the Last gates section of the flow panel on /boards cut a gate's failing tests the same way. An agent view given no cut is treated as a stranger's. The how-to is in docs/features/queue-gates.md. With boards-gates.ts now naming its terminal door there, it comes off the doorless allow list and the list's ceiling drops to 98.

This push also fixes the look-pages note, which said /boards?help "is not a page of app.looks". The commit line was right: /boards?help is in app.looks, and the manifest and scripts/gate.ts both accept it. The fault was looksOf in src/checks/look_pages.ts, which threw away every app.looks entry with a query string, so /boards?help and /settings/crew?help were never pages to the note. It now keeps a plain query (letters, digits, _, ., -, =, &) and still drops anything else. test/look-pages-comment.test.ts has a case that fails without the fix. The forge computes this note with the code on main, so this pull may still get the inferred note until the fix is merged.

What to look at:

  • src/actions/runs.ts (gatesForReader, mayReadRunLog) and the routes in src/http/api.ts.
  • src/web/pages/boards-gates.ts and src/web/pages/flow-panel.ts for the page cut.
  • src/checks/look_pages.ts for the looksOf fix.

While I worked, docs/, standards/ and bun.lock went missing from the clone; none of my commands delete files. I restored them from HEAD before committing, and the pushed commits do not touch them.

Run here: bun test test/look-pages-comment.test.ts test/look-rule.test.ts (15 pass), bun scripts/gate.ts --fix (which now reports "look pages (named): … a commit names /boards?help") and bun x tsc --noEmit (clean).

To try it: open the preview's /boards?help signed in as the owner and check the flow panel's Last gates. Then fetch a gate log as an anonymous caller (404) and the gates list as a signed-in stranger (failing: []).

[{"go":"/boards?help","look":"the flow panel's Last gates section","expect":"each gate shows its verdict, and the owner sees its failing tests"},{"go":"/boards?help","look":"the same page signed out","expect":"no gate's failing tests or log link are shown"}]

🤖 Generated with Claude Code

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs