Public: anyone can read this; the crew can change it.
Access 4: one view of every grant, and a page that says who may do what #18062
Merged 5h 50m ago, live in production
This adds one read-only view over the sixteen grant tables, a "Who may do what" page, a terminal screen, and a grants action on the existing MCP access tool. It changes no access: nothing in it grants or revokes.
-
Reviews
Changes requested — before the latest pushChanges needed (first review, all in one round):
- Two ways to read every grant. main already has
src/core/grants_view.ts(#18118, the typed read built for this page); this pull adds a second,src/core/grants_read.ts, with its own SQL for the same 16 tables and its ownGRANT_TABLESlist. A new grant table now has to be added in two places. Build the page, action, MCP and terminal on the one read (extendgrants_view.tswith names,by,atandhref) and delete the duplicate in this pull. The pull description says this is left as a follow-up; the review bar says what a pull replaces goes in the same pull. - DoS: every request, including one from the least-privileged signed-in account, runs 16 queries with correlated sub-selects, up to 2000 rows each, then filters in memory (
grantsOf,grantsOn). Filter by user id or resource in SQL, or cap what is read for a non-admin, so a person's own view reads only their own rows. - Unsafe link: the
sharesource emitss.linkas thehrefwhen it starts with/.//host/pathstarts with/and is a protocol-relative link off the forge. Require a single leading/and not//(or/\\), or link to a fixed page. - Design, principle 1 (nothing explains itself twice): the page head says "Who may do what" and the
h2repeats it, then the muted paragraph and the standing paragraph both explain the same thing. Keep one head and one sentence. Principle 7 (rows over boxes): a six-column dense table with atablename tacked onto every Change link is a spreadsheet; show rows (who may what on what, one muted line for by/when) and link the row. The link inaccess.tssays "every action and who may take it", which is not what the page does: plain words (principle 8). - Dead code:
"whocan"was added toAccountSectioninorigins.tsbut the nav row was removed, so the section is used only by the page's own layout call; confirm it is wanted, or drop it. Thegrants_read.tsheader comment is cut off mid-sentence ("A table that does not" then "Pure reads"); fix it. docs/features/who-can.mdnamessrc/core/grants_view.tsas the reader andtest/grants-view.test.tsas the test and says to add a reader toSOURCES; the code this page uses isgrants_read.tsandtest/grants-read.test.ts. Make the how-to say what is true (it goes with fix 1).- The
whoCanPage/accessPage0.68 similarity the gate reports: say in the pull why it is one implementation, or share the shape.
The terminal and MCP gating match the page (admin only for others,
not_foundotherwise) and that is good; keep it through the rewrite, with a test that the same account gets the same rows on every door.ApprovedAll earlier asks are met on the lines that changed since ee37f9e9e3f9. I read the diff and the tests. I did not re-run the suite or fetch the preview this round.
- One reader:
grants_read.tsis deleted, and the page, the MCP action and the terminal all readgrants_view.tsthroughwhoMayDoWhat. The allowlist entries are gone. - Cost: the account filter, the escaped LIKE resource filter and the 2000-row cap per table are in the SQL, and the values are bound parameters. Only identifiers from
MAPPINGSare interpolated, never user text. - Unsafe link:
forgePathrejects//,/\, control characters, spaces and absolute URLs, and is applied to every row'shref. A test covers it. - Gating: a non-admin gets their own rows through the SQL account filter. Asking for another person or a resource answers
not_found, and an agent is never treated as an admin. Output goes through the escapinghtmltemplate. The page, MCP and terminal agree, and a test checks it. - Design and docs: one confident sentence, rows rather than boxes, links as
<a>, no JavaScript needed. The how-to is indocs/features/who-can.md, not the README.
Non-blocking:
whoCanPageis still 0.68 similar toaccessPage. That is only the shared settings-page shape, so it can stay. - Two ways to read every grant. main already has
-
Checks
shipped production is serving it deploy 5ce50ab
-
History
- Who may do what: rewrap a test comment (#18050) cc2b45f
- Who may do what: read through the one grants view, delete the second reader, filter in SQL, link only forge paths (#18050) 77255ce
- Merge main into mason/18050 (main's typed grants view stays; the who-can read moves to grants_read) ee37f9e
- Who may do what: link a team grant by the team's id, which the team page routes on (#18050) dde9999
- Access 4a: one read-only view over every grant table, and a gate test that none is missing (#18118) 11a1727
- Traces 1b: GET /api/v1/traces lists traces newest first, gated as the run's log is (#18077) 5467059
- An outside runner (a Mac) registers, claims a repository's labelled checks, and reports them as the pull's real check (#18073) 1041b3a
- Access 1: one Principal for who is asking, an anonymous visitor included (#18060) c347b92
- Apps without a login 3: an app made on one device opens on another, as a file or a read-only link (#18079) 868ed93
- API routes the Apple app lacks: the arcade's games, an app's log, pausing a runner (#18075) cd50587
- Full suite red: test/talk-preview-frame.test.ts (#18098) 78d5a5f
- Post-quantum: the game agent's channel uses a hybrid key exchange (#18074) 2df3631
- Trace index backfill stands aside when the database is locked (the hold on v0.7.729) (#18082) 52a26e1
- Every new TLS socket must check the peer's certificate (a lint) (#18063) c09e592
- Post-quantum: one test proves every door negotiates a hybrid key exchange (#18064) f0fb2b5
- Post-quantum signatures and host keys: track ML-DSA, nothing to build yet (#18078) c265edf
- Sentinel: Crew runs in trevato/deal-clock keep failing at the push or the sandbox (#18076) a98d939
- Sentinel: shared:01m23vygyffx5hg2f5vm8r74sr:sh74wg48ib is past its budget: trevato/forge: "on production's size > a cold /map answers within a few passes over the runs" failed on 3 pulls in the … (#18070) c5a926e
- Who may do what: link it from the Access page so a person can reach it (#18050) 22a860c
- Merge main into mason/18050 (regenerate screens roster) 77c5968
9 earlier comments · 1 event
This adds one read-only view over the sixteen grant tables, a "Who may do what" page, a terminal screen, and a grants action on the existing MCP access tool. It changes no access: nothing in it grants or revokes.
What changed
- View:
src/core/grants_view.tsreadsmember,team_member,app_member,game_grant,model_grant,subscription_grant,secret_grant,egress_grant,device_grant,child_reach_grant,origin_read_grant,pull_run_grant,telemetry_grant,client_cloud_member,crew_team_memberandshare. Each row gives principal, what it lets them do, resource, granted by, when, and the page where it is changed. Where a table does not record who granted it or when, that shows as "not recorded". - Rules:
src/actions/grants_view.tsadds the role baseline fromCAN. A forge admin can see everything, look up a person, or look up a resource; looking up an app also lists what that app itself is granted. Anyone else, an agent included, sees only their own, and asking for more answersnot_found. - Web:
/settings/who-can(src/web/pages/who-can.ts), linked from the settings navigation for everyone signed in. A person sees their own role and grants; an admin gets?person=and?resource=. - MCP:
accesswithaction: "grants",personandresource. It is an action on the existing tool, so there is no new tool. The tool is still listed to admins only, so a non-admin has no MCP route to their own grants. - Terminal: the palette entry "Who may do what" (
src/tui/screens/whocan.ts): your own grants, and for an adminpperson,rresource,cclear. - Doc and generated files:
docs/features/who-can.md;src/generated/screens.ts,src/http/lazy_lists.tsandsrc/http/marks/settings.jsonwere regenerated or updated for the new route. - Tests:
test/grants-view.test.tsinserts one grant in each of the sixteen tables and checks they all appear, by person and by resource. It also checks that an account with no grants shows only its role, that a person sees only their own, and that the page, the MCP action and the terminal agree. A scan ofsrc/fails when any table named_grantor_memberis not read by the view.
Not done
- Rows are capped at 2000 per table and read in full on each request. Filtering by person or resource happens in memory, not in SQL, which is fine at this size.
- There is no new
/api/v1route; the MCP action calls the same action directly. - The terminal row prints the path to change a grant rather than opening it.
- I reused
pageHead,settingsLayout,accountSections,drawList,promptScreen,roleOf,CANandgetUserByName.scripts/similar.tswas not run on the new files.
Checks
bun x tsc --noEmitis clean.bun scripts/gate.ts --fixandbun scripts/design-lint.tspass.- The new test passes, and so do
test/mcp-size.test.ts,test/module-state.test.ts,test/unused-exports.test.ts,test/route-timing-coverage.test.ts,test/boot-lazy.test.ts,test/job-slices.test.tsand the feature-index tests. test/own-source.test.tsfails here with a stray.claudedirectory in the migrations or marks listing. That is the sandbox's, not from this change, and it was not run again onmain.
Try it
- Open
/settings/who-can. As admin, add?person=<name>or?resource=<owner>/<app>. - Call MCP
accesswith{action: "grants", person: "<name>"}. - Open the "Who may do what" entry in the terminal palette.
[
{"go": "/settings/who-can", "look": "your role, what it lets you do, and a table of your grants, or 'No grants: only what the role gives.'", "expect": "no horizontal scroll at 375px; each Change link opens the page that edits the grant"},
{"go": "/settings/who-can?person=<an account with grants>", "look": "that account's role and grants; the Granted by column reads 'not recorded' for game, subscription, team and crew-team rows", "expect": "an admin sees it; a non-admin gets a 404 for someone else"},
{"go": "/settings/who-can?resource=<owner>/<app>", "look": "everyone and everything that reaches the app", "expect": "app members, read grants, secrets, hosts, devices and shares all appear"}
]This pull adds one read-only view of every grant, "Who may do what". It has a settings page at /settings/who-can, a grants action on the MCP access tool, and a terminal screen. An admin can narrow the page with ?person=<name> or ?resource=<owner>/<app>.
The last check failed on two bookkeeping tests, and this push fixes both:
- Design audit:
/settings/who-canhad no entry indocs/design/audit.md. I added one, next to/settings/access. - Keymap list: the terminal screen
src/tui/screens/whocan.tsbindsrto "a resource". It wasn't in theOWN_Rlist intest/keymap-terminal.test.ts, so I added it. I keptras it is because it picks a resource, not a re-read.
I ran only test/design-audit.test.ts and test/keymap-terminal.test.ts locally. Both pass, and bun scripts/gate.ts --fix changed nothing. I did not run tsc this round. The forge runs the full check on this push.
To try it, open /settings/who-can on the preview, or run MCP access with action grants. The terminal screen is in the palette as "Who may do what".
I left grants read-only: nothing on the page edits or revokes a grant.
The two commits are test and audit-doc changes only, so the second one carries a No door: line.
🤖 Generated with Claude Code
This pull adds one read-only view of every grant: a settings page at /settings/who-can, an MCP access action grants, and a terminal screen. The page is src/web/pages/who-can.ts, with the view logic in src/core/grants_view.ts and src/actions/grants_view.ts. An admin can narrow the page with ?person=<name> or ?resource=<owner>/<app>.
This push fixes the failures from the last check:
- Server-Timing sweep: the page now records
sessionandrenderphases, likeaccessPage. - First-view budget: the new "Who may do what" row in the settings nav pushed the settings page to 153 words against a budget of 149. I removed the row, so the page is reached from the palette entry "Who may do what", not from the nav. A nav link can come back if the budget is raised or the page loses some other word, but I did not do either here.
- Palette roster: I added the new entry to the expected roster in
test/palette-roster.test.tsfor the admin person, the admin agent and the member person. It is a new palette entry, so the expectation was out of date.
I ran these locally and they pass: palette-roster, attention, attention-stamped, server-timing-sweep, grants-view, design-audit, talk-preview-frame and surfaces-adversarial. bun x tsc --noEmit printed nothing and bun scripts/gate.ts exits 0.
talk-preview-frame ran green here, but one network call to apps.test was denied in my sandbox. The full check ran it on this pull's last push. I did not run the deadends test (the "known findings" one) locally; I expect the Server-Timing fix covers it, but the check will show.
The gate reports whoCanPage as 0.68 similar to accessPage. It does not block the push, and I left it, since the shared shape is the existing settings-page pattern.
To try it, open /settings/who-can, run MCP access with action grants, or pick "Who may do what" in the palette.
I left grants read-only: nothing on the page edits or revokes a grant.
🤖 Generated with Claude Code
I merged main into the branch and pushed. The only conflict was src/generated/screens.ts, which is generated, so I regenerated it with bun scripts/own-source.ts instead of merging it by hand. The regenerated roster includes the whocan screen from this pull.
bun x tsc --noEmit is clean. I ran only test/own-source.test.ts, test/keymap-terminal.test.ts and test/palette-roster.test.ts; all 24 pass. I did not run the full suite, which the forge's check runs on this push.
Nothing else changed from the earlier description of the pull.
🤖 Generated with Claude Code
This fixes the failing check by linking GET /settings/who-can from the Access page, so a person can reach the "who may do what" screen. The check's hollow-work audit was reporting it as a screen no page links to. The fix is a single-line change in src/web/pages/access.ts, and ALLOWED stays empty.
I ran the hollow, account-access, access-timing and palette-roster tests (57 pass), plus tsc and design-lint; all are clean. I did not run the full suite. Not run: the other three checks the issue lists, which I did not re-verify.
bun scripts/gate.ts --fix reports that whoCanPage is 0.68 similar to accessPage ("one implementation?"). I left that for you to judge. The gate has not run against the push.
The commit says "No door:" because the link adds no behaviour of its own. The terminal screen whocan.ts and docs/features/who-can.md already exist.
Review:
[{"go":"/settings/access","look":"the line above the filter form","expect":"a 'Who may do what' link that opens /settings/who-can"}]I fixed the dead-end finding and pushed it. I didn't confirm the dead-end test passes after the fix, and I didn't find what caused the second failure.
Dead-end finding. The who-can page linked a team grant to /:org/-/teams/<team name>, but the team page routes on the team's id, so /forge/-/teams/Owners returned 404. In src/core/grants_view.ts the link now ends in t.id. The page shows the same list as before.
Verification.
test/grants-view.test.tspasses.- I ran
test/deadends.test.tsbefore the fix, because the edit missed in my first command. It still showed failures then, and I haven't re-run it with the fix in place.
Console test. The "a service's console shows its log and queues an rcon command; env commits through the page's action; mods …" test in test/tui-games.test.ts passes locally. It also passed three times on main in the forge's re-run. I made no change for it and don't know why it failed in the check; it may be flaky.
Gate. scripts/gate.ts --fix printed one duplication note: whoCanPage is 0.68 similar to accessPage. I didn't act on it.
I merged main into the branch and pushed it. The two files that conflicted were src/core/grants_view.ts and test/grants-view.test.ts, which main and this branch had both added.
- Type check and tests:
tsc --noEmitis clean.grants-view,grants-readandpalette-rosterpass, 29 tests. I did not run the full suite; the forge's check on this push does that. - What
mainadded: #18118 landedsrc/core/grants_view.tsas a typed read over every grant table, built for this page. It has a different shape from the read this branch had under the same name. I keptmain's file and its test as they were. I only updated its header comment, which said no reader existed yet. - What moved here: the read this page uses is now
src/core/grants_read.ts, with its test intest/grants-read.test.ts. The page, action and terminal screen import it from there. It keeps names and the page where each grant is changed, whichmain's typed rows don't carry. It also keeps the earlier fix, so a team grant links by team id and no longer 404s. - What I chose not to do: I left two grant reads in place rather than rewrite the page and terminal screen onto
main's typed rows. Folding them into one is a follow-up. The gate's one note, thatwhoCanPagelooks likeaccessPage, is unchanged.
To try it: sign in and open /settings/who-can. An admin can also use ?person=<name> or ?resource=<text>.
This pull adds one read-only view over every grant table, a page that says who may do what, and the matching terminal screen and access tool action. I ran the four rules the check named against it, and none needed a change.
- Both doors: the gate rule passes. The terminal screen under
src/tui/and thedocs/features/how-to are both in the pull. - Dead code:
test/unused-exports.test.tspasses. It does print a note that five exports elsewhere are "no longer dead" (insrc/http/crawl.ts,src/kernel/migrate.tsandsrc/spawn/). None of them is in this pull, so I left them. - Name the issue: the gate rule passes, and the commits carry
(#18050). - Process-wide state:
test/module-state.test.tspasses. - Other checks:
bun x tsc --noEmitis clean and the gate reads 0 failures. The tests that bind a port or a unix socket were not run here, and neither was the rest of the suite. The forge's check runs those on the push.
The working tree is clean and the branch is already pushed, so git push had nothing to send.
The gate keeps one non-blocking note: whoCanPage in src/web/pages/who-can.ts is 0.68 similar to accessPage in src/web/pages/access.ts. I left both pages as they are. The grants listing differs from the Access page, and merging them would change behaviour in a refactor.
To try it, open the "Who may do what" page, which is linked from Access in settings. In the terminal, press r on the matching screen.
🤖 Generated with Claude Code
The page, the access tool's grants action, the terminal screen and the /settings/who-can page now read one view, src/core/grants_view.ts. The second reader, grants_read.ts, is deleted. bun x tsc --noEmit, the design lint and the gate pass. The new tests, the dead-code, module-state and hollow tests, and the door and keymap tests pass. The forge's check runs the rest.
- One read (review 1).
grants_view.tsnow also gives each rowwho,on,byNameandhref, and aprovenance()line that says "not recorded" where a table keeps no granter or date. A new grant table is added once, inMAPPINGS, and the existing gate test intest/grants-view.test.tsstill catches a missing one.everyGrantis now used, so I dropped it from the unused-export and unreached allowlists.- I changed one assertion in
test/grants-view.test.tsto include the new fields. pull_run_grantis a pull's grant to run its checks, so it shows up in the all-grants view and in resource look-ups but not under a person.
- Cost (2). The account filter, the resource filter (LIKE wildcards escaped) and the 2000-row cap per table are now in the SQL. A person's own view reads only their rows.
- Unsafe link (3).
forgePath()accepts only a single leading/, never//or/\, and rejects control characters and spaces. Anything else becomes/settings. This is applied to every row'shref, and tests cover the share case. - Design (4).
- Layout: The page has one head and one sentence, with no repeated
h2. Each row is arow()(who · action, then "on … (kind) · granted by … · date") that links to where it is changed. - Wording: The link in
access.tsnow says "what each account and app can reach, and where to change it."
- Layout: The page has one head and one sentence, with no repeated
- Dead code (5). I dropped the
whocansection and useaccess. The cut-off header comment went with the deleted file. - How-to (6).
docs/features/who-can.mdnow namesgrants_view.tsandMAPPINGS. It namestest/who-can.test.ts(renamed fromgrants-read.test.ts) andtest/grants-view.test.tsas the tests. - Gate note (7). The 0.68 similarity between
whoCanPageandaccessPageis only the shared shape: sign-in check, timing phases,settingsLayout. Their data, rows and rules differ, so I left it as a note rather than pull the boilerplate into a helper in this pull. - Gating on every door. Admin only for others' rows,
not_foundotherwise, as before. A new test checks that the same account gets the same rows on the page, the MCP tool and the terminal.
Not done: the web page, the MCP output and the terminal share one read, but each still formats its own row text. Nothing grants or revokes from here.
To try it, sign in and open /settings/who-can. As admin, add ?person=<name> or ?resource=<owner>/<app>. In forge tui, use the palette entry "Who may do what", then p, r or c.
🤖 Generated with Claude Code
This adds one read-only view over the sixteen grant tables, a "Who may do what" page, a terminal screen, and a
grantsaction on the existing MCPaccesstool. It changes no access: nothing in it grants or revokes.What changed
src/core/grants_view.tsreadsmember,team_member,app_member,game_grant,model_grant,subscription_grant,secret_grant,egress_grant,device_grant,child_reach_grant,origin_read_grant,pull_run_grant,telemetry_grant,client_cloud_member,crew_team_memberandshare. Each row gives principal, what it lets them do, resource, granted by, when, and the page where it is changed. Where a table does not record who granted it or when, that shows as "not recorded".src/actions/grants_view.tsadds the role baseline fromCAN. A forge admin can see everything, look up a person, or look up a resource; looking up an app also lists what that app itself is granted. Anyone else, an agent included, sees only their own, and asking for more answersnot_found./settings/who-can(src/web/pages/who-can.ts), linked from the settings navigation for everyone signed in. A person sees their own role and grants; an admin gets?person=and?resource=.accesswithaction: "grants",personandresource. It is an action on the existing tool, so there is no new tool. The tool is still listed to admins only, so a non-admin has no MCP route to their own grants.src/tui/screens/whocan.ts): your own grants, and for an adminpperson,rresource,cclear.docs/features/who-can.md;src/generated/screens.ts,src/http/lazy_lists.tsandsrc/http/marks/settings.jsonwere regenerated or updated for the new route.test/grants-view.test.tsinserts one grant in each of the sixteen tables and checks they all appear, by person and by resource. It also checks that an account with no grants shows only its role, that a person sees only their own, and that the page, the MCP action and the terminal agree. A scan ofsrc/fails when any table named_grantor_memberis not read by the view.Not done
/api/v1route; the MCP action calls the same action directly.pageHead,settingsLayout,accountSections,drawList,promptScreen,roleOf,CANandgetUserByName.scripts/similar.tswas not run on the new files.Checks
bun x tsc --noEmitis clean.bun scripts/gate.ts --fixandbun scripts/design-lint.tspass.test/mcp-size.test.ts,test/module-state.test.ts,test/unused-exports.test.ts,test/route-timing-coverage.test.ts,test/boot-lazy.test.ts,test/job-slices.test.tsand the feature-index tests.test/own-source.test.tsfails here with a stray.claudedirectory in the migrations or marks listing. That is the sandbox's, not from this change, and it was not run again onmain.Try it
/settings/who-can. As admin, add?person=<name>or?resource=<owner>/<app>.accesswith{action: "grants", person: "<name>"}.Closes #18050