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

opened this in answer to

Merged 6h 51m 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.

Notes

opened this

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.ts reads member, 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_member and share. 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.ts adds the role baseline from CAN. 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 answers not_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: access with action: "grants", person and resource. 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 admin p person, r resource, c clear.
  • Doc and generated files: docs/features/who-can.md; src/generated/screens.ts, src/http/lazy_lists.ts and src/http/marks/settings.json were regenerated or updated for the new route.
  • Tests: test/grants-view.test.ts inserts 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 of src/ fails when any table named _grant or _member is 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/v1 route; 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, CAN and getUserByName. scripts/similar.ts was not run on the new files.

Checks

  • bun x tsc --noEmit is clean.
  • bun scripts/gate.ts --fix and bun scripts/design-lint.ts pass.
  • 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.ts and the feature-index tests.
  • test/own-source.test.ts fails here with a stray .claude directory in the migrations or marks listing. That is the sandbox's, not from this change, and it was not run again on main.

Try it

  • Open /settings/who-can. As admin, add ?person=<name> or ?resource=<owner>/<app>.
  • Call MCP access with {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"}
]

Closes #18050

Show 2 earlier items

7 earlier comments · 1 event
commented

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 session and render phases, like accessPage.
  • 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.ts for 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

commented

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

commented

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"}]
commented

Still red on current main: the findings are the known ones, and every known one still happens. Fix it and push.

commented

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.ts passes.
  • I ran test/deadends.test.ts before 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.

commented

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 --noEmit is clean. grants-view, grants-read and palette-roster pass, 29 tests. I did not run the full suite; the forge's check on this push does that.
  • What main added: #18118 landed src/core/grants_view.ts as 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 kept main'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 in test/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, which main'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, that whoCanPage looks like accessPage, is unchanged.

To try it: sign in and open /settings/who-can. An admin can also use ?person=<name> or ?resource=<text>.

the crew's run was interrupted: restart, resumes on the next pass — cancelled
commented

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 the docs/features/ how-to are both in the pull.
  • Dead code: test/unused-exports.test.ts passes. It does print a note that five exports elsewhere are "no longer dead" (in src/http/crawl.ts, src/kernel/migrate.ts and src/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.ts passes.
  • Other checks: bun x tsc --noEmit is 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

commented

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.ts now also gives each row who, on, byName and href, and a provenance() line that says "not recorded" where a table keeps no granter or date. A new grant table is added once, in MAPPINGS, and the existing gate test in test/grants-view.test.ts still catches a missing one.
    • everyGrant is now used, so I dropped it from the unused-export and unreached allowlists.
    • I changed one assertion in test/grants-view.test.ts to include the new fields.
    • pull_run_grant is 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's href, and tests cover the share case.
  • Design (4).
    • Layout: The page has one head and one sentence, with no repeated h2. Each row is a row() (who · action, then "on … (kind) · granted by … · date") that links to where it is changed.
    • Wording: The link in access.ts now says "what each account and app can reach, and where to change it."
  • Dead code (5). I dropped the whocan section and use access. The cut-off header comment went with the deleted file.
  • How-to (6). docs/features/who-can.md now names grants_view.ts and MAPPINGS. It names test/who-can.test.ts (renamed from grants-read.test.ts) and test/grants-view.test.ts as the tests.
  • Gate note (7). The 0.68 similarity between whoCanPage and accessPage is 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_found otherwise, 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

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs