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

Access 4c: the grants view as an MCP tool and a terminal screen #18130

opened this

Merged 8h 46m ago, live in production

The grants view from #18104 can now be read by agents, through MCP whoamican with kind: "grants", and in the terminal, through a new Who may do what entry in the ctrl-k palette. A forge admin who is a person sees every grant. Everyone else sees only grants held by their own account.

Notes

opened this

The grants view from #18104 can now be read by agents, through MCP whoami_can with kind: "grants", and in the terminal, through a new Who may do what entry in the ctrl-k palette. A forge admin who is a person sees every grant. Everyone else sees only grants held by their own account. That includes every agent, even one whose account is an admin, so a token never shows more than its own account holds.

  • One gate, one set of words: the tool and the screen both go through the new src/actions/who_may.ts. whoMay(app, user) picks every grant or only the caller's own (passed to everyGrant(db, account)). grantWords(g) turns each grant into one line, e.g. user <id> may member on forge · by <id> · 2026-12-04 · member, and whoMayHeading writes the sentence above the list. The tool answers { scope, says, grants }, and each grant carries its line.
  • No new tool: this is a third kind on the existing whoami_can tool, which also keeps the MCP tool list small. Its description gained one clause; the tool-list size test passes.
  • Terminal: src/tui/screens/who_may.ts is read-only, j/k move, and the palette offers it to every signed-in account.
  • Cleanup: src/core/grants_view.ts now has callers, so it is off both "nothing calls this yet" allow lists and its header comment says who reads it.
  • Docs: docs/features/who-may.md covers both the tool and the terminal screen.

Test: test/who-may.test.ts calls the tool with a read-only token. As admin, the answer includes both members' rows. As plain member bob, every row is bob's own. The terminal shows bob the same sentence and lines, never carol's id, and shows the admin every grant. Without the gate, bob would see carol's row and the test would fail.

Changed an existing test: test/palette-roster.test.ts pins the full palette list for each kind of account, so it was right to fail. I added the new entry to its three lists.

Not done:

  • The "Who may do what" web page (#18105) isn't built yet. These words live in who_may.ts so the page can use the same ones.
  • The screen shows account ids, not usernames, because the view returns ids.
  • No filtering or paging.

Checks run: bun x tsc --noEmit and bun scripts/gate.ts --explain are clean apart from one note. The note says whoMayScreen resembles forgeUsageScreen and the test's terminal helper resembles one in tui-machines.test.ts; I kept them separate. scripts/fast.ts named about 1,000 test files, too many to run here. I ran these instead, and they pass:

  • who-may, grants-view, mcp-size, tui-can, delete-tier
  • module-state, unreached, unused-exports, mcp-doc-*
  • palette-entries, palette-roster, doorless, feature-doors, hollow, talk-whoami

Try it on the preview: call MCP whoami_can with {"kind":"grants"} as an admin and as a member, or SSH in and pick Who may do what from ctrl-k.

🤖 Generated with Claude Code

Closes #18106

2 earlier comments · 1 event
commented

The grants view from #18104 can now be read by agents, through MCP whoami_can with kind: "grants", and in the terminal, through a new Who may do what entry in the ctrl-k palette. A forge admin who is a person sees every grant. Everyone else sees only grants held by their own account. That includes every agent, even one whose account is an admin, so a token never shows more than its own account holds.

  • One gate, one set of words: the tool and the screen both go through the new src/actions/who_may.ts. whoMay(app, user) picks every grant or only the caller's own (passed to everyGrant(db, account)). grantWords(g) turns each grant into one line, e.g. user <id> may member on forge · by <id> · 2026-12-04 · member, and whoMayHeading writes the sentence above the list. The tool answers { scope, says, grants }, and each grant carries its line.
  • No new tool: this is a third kind on the existing whoami_can tool, which also keeps the MCP tool list small. Its description gained one clause; the tool-list size test passes.
  • Terminal: src/tui/screens/who_may.ts is read-only, j/k move, and the palette offers it to every signed-in account.
  • Cleanup: src/core/grants_view.ts now has callers, so it is off both "nothing calls this yet" allow lists and its header comment says who reads it.
  • Docs: docs/features/who-may.md covers both the tool and the terminal screen.

Test: test/who-may.test.ts calls the tool with a read-only token. As admin, the answer includes both members' rows. As plain member bob, every row is bob's own. The terminal shows bob the same sentence and lines, never carol's id, and shows the admin every grant. Without the gate, bob would see carol's row and the test would fail.

Changed an existing test: test/palette-roster.test.ts pins the full palette list for each kind of account, so it was right to fail. I added the new entry to its three lists.

Not done:

  • The "Who may do what" web page (#18105) isn't built yet. These words live in who_may.ts so the page can use the same ones.
  • The screen shows account ids, not usernames, because the view returns ids.
  • No filtering or paging.

Checks run: bun x tsc --noEmit and bun scripts/gate.ts --explain are clean apart from one note. The note says whoMayScreen resembles forgeUsageScreen and the test's terminal helper resembles one in tui-machines.test.ts; I kept them separate. scripts/fast.ts named about 1,000 test files, too many to run here. I ran these instead, and they pass:

  • who-may, grants-view, mcp-size, tui-can, delete-tier
  • module-state, unreached, unused-exports, mcp-doc-*
  • palette-entries, palette-roster, doorless, feature-doors, hollow, talk-whoami

Try it on the preview: call MCP whoami_can with {"kind":"grants"} as an admin and as a member, or SSH in and pick Who may do what from ctrl-k.

🤖 Generated with Claude Code

commented

This pull lets an MCP client ask whoami_can with kind: "grants" for who may do what. A forge admin sees every grant; anyone else sees only their own, each grant with a line of text. A terminal screen shows the same list.

This update merges main. Both sides had rewritten the doc string of src/http/mcp/tools/whoami_can.ts. The merged doc keeps main's new actions field (what you may do across the forge, by the names GET /api/v1/may takes) and this branch's kind: "grants".

With both changes in, the Talk tool list was 18,503 bytes, 3 over the 18,500 limit test/mcp-talk-tools.test.ts holds it to. The test says not to raise that limit in a feature pull, so the tool's description became "What you may do: your role, each action yes or no." It had been "What you can do: your role and each action, yes or no." The test was right and was not changed.

All 1,325 tests in test/mcp*.test.ts pass, and so do the who-may and whoami tests; bun x tsc --noEmit is clean. The full set scripts/fast.ts named was too large to run here (about 76 minutes), so the forge's check on this push covers the rest. The gate's only notes flag code that looks similar to other code, as before the merge.

To try it, call the whoami_can MCP tool with {"kind":"grants"}, once as a forge admin and once as an ordinary account. The admin should see every grant and the ordinary account only its own.

🤖 Generated with Claude Code

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

MCP whoami_can now takes kind: "grants", so anyone signed in can ask who may do what. A forge admin who is a person gets every grant, and anyone else, any agent included, gets only their own. The answer is { scope, standing, grants }.

This merges main, which had since landed Access 4 (#18062): the shared action whoMayDoWhat in src/actions/grants_view.ts, the terminal screen "Who may do what" (src/tui/screens/whocan.ts), and an admin-only MCP door (access with action: "grants"). The only conflict was a doc comment in src/core/grants_view.ts, and main's version is kept.

To avoid two copies of the same feature, whoami_can now calls main's action with no filter. This branch's own copies are deleted: src/actions/who_may.ts, src/tui/screens/who_may.ts, its who-may palette entry and docs/features/who-may.md. That changes this tool's answer from what earlier commits on the branch returned: scope is now all or self (it was everyone or yours), and the says sentence and each row's line are gone.

  • Terminal side: main's whocan screen.
  • Docs: docs/features/who-can.md now names whoami_can as the MCP door for everyone, and access as the admin's door with person and resource filters.
  • Tests: test/who-may.test.ts now covers only the MCP door: an admin sees everyone's grants, a member sees only their own. I dropped its terminal half because the gate flagged its helper as a near-copy of another test's, and test/who-can.test.ts from main already checks the screen.

Type check, the gate, and test/who-may, who-can, grants-view, palette-roster, mcp-talk-tools (the Talk list size limit) and talk-page all pass.

To try it: call MCP whoami_can {"kind":"grants"} as a member, then as an admin, and compare with Settings → Who may do what (/settings/who-can).

🤖 Generated with Claude Code

Sign in to join this conversation.

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

Keyboard shortcuts

Docs