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

Access 3b: MCP, pages, the terminal, games and infrastructure ask may(), one door per pull #18186

opened this

Merged 5h 54m ago, live in production

This pull moves the MCP door of Access 3b (#18092) onto may(). It is the first of the issue's boxes, since the issue asks for one door per pull. What changed New action forge.write in src/core/may.ts: "Change something as your account".

Notes

opened this

This pull moves the MCP door of Access 3b (#18092) onto may(). It is the first of the issue's boxes, since the issue asks for one door per pull.

What changed

  • New action forge.write in src/core/may.ts: "Change something as your account". Any signed-in account holds it; a token also needs scope rw.
  • src/http/mcp/tool_may.ts, the one place the MCP dispatch now asks:
    • adminAccount(db, user) asks forge.administer of the account. It is used by adminOnly, by listedTo: "admin", by the admin note, by talk listing, by destroysTo (which now takes db) and by askedFirst.
    • mayToolWrite(ctx, door) asks forge.write with the credential the call carries. It replaces the four scopeAllows(ctx.auth.scope ?? "ro", "rw") checks in src/http/mcp.ts. The old check still runs beside it, and when the two answers differ a row is added to access_disagreement under door mcp <tool>, as in 3a. may()'s answer decides.
  • Gate rule "MCP tools ask may" (src/kernel/mcp_door_checks.ts): fails a new inline isAdmin or scopeAllows(…, "rw") in src/http/mcp.ts or src/http/mcp/shared.ts. Only mayBoards is exempt, because that rule is checked inside each tool rather than at the door.
  • Visible change: forge.write now appears in can lists — GET /api/v1/user, MCP whoami_can, and the terminal's "What I can do" (You may:). docs/features/may.md and the OpenAPI text say so. The terminal gets no new screen, so the commit carries a No door: line.

Tests

  • New test/mcp-tools-may.test.ts. It pins both answers for a guest, a member and an admin signed in; ro, rw and admin tokens; and via, proposal, run and contribute tokens. None of them adds a disagreement row. It also checks that a disagreement is counted, and that the gate rule catches a new inline check.
  • Changed test/may.test.ts and test/tui-can.test.ts to expect forge.write in the lists.
  • Changed test/mcp-shared-gate.test.ts: its fake context had no app, and the door now reads ctx.app.db. The test was wrong-shaped, not the code.
  • Results: the type check passes, the gate passes, and about 2,100 tests pass across the MCP, may, gate and terminal suites. One gate-runner test fails ("where Chromium starts the gate runs the looks files"), because the sandbox has no Chromium; this change doesn't touch it.
  • Not run: the suites that need a unix socket or cells, and the full suite. The forge's check runs those.

Left out

  • needsAdminScope stays as scopeAllows(…, "admin"). It is about how far a token reaches, not a role. forge.administer asks only for scope rw, so moving it would let an admin's rw token see admin-scope tools.
  • mayBoards stays as it is.
  • Pages, SSH and the terminal screens, games and infrastructure are left for their own pulls.
  • I had no keep_plan or estimate tool in this run, so the issue has no plan and no time estimate.

Try it on the preview:

  • Call tools/call feed_dismiss on /mcp with an ro token: it is refused as read-only.
  • With a member's token, GET /api/v1/user shows forge.write in can.
  • With a non-admin token, calling scorecard answers "no tool named scorecard".

🤖 Generated with Claude Code

Closes #18092

commented

This pull moves the MCP door of Access 3b (#18092) onto may(). It is the first of the issue's boxes, since the issue asks for one door per pull.

What changed

  • New action forge.write in src/core/may.ts: "Change something as your account". Any signed-in account holds it; a token also needs scope rw.
  • src/http/mcp/tool_may.ts, the one place the MCP dispatch now asks:
    • adminAccount(db, user) asks forge.administer of the account. It is used by adminOnly, by listedTo: "admin", by the admin note, by talk listing, by destroysTo (which now takes db) and by askedFirst.
    • mayToolWrite(ctx, door) asks forge.write with the credential the call carries. It replaces the four scopeAllows(ctx.auth.scope ?? "ro", "rw") checks in src/http/mcp.ts. The old check still runs beside it, and when the two answers differ a row is added to access_disagreement under door mcp <tool>, as in 3a. may()'s answer decides.
  • Gate rule "MCP tools ask may" (src/kernel/mcp_door_checks.ts): fails a new inline isAdmin or scopeAllows(…, "rw") in src/http/mcp.ts or src/http/mcp/shared.ts. Only mayBoards is exempt, because that rule is checked inside each tool rather than at the door.
  • Visible change: forge.write now appears in can lists — GET /api/v1/user, MCP whoami_can, and the terminal's "What I can do" (You may:). docs/features/may.md and the OpenAPI text say so. The terminal gets no new screen, so the commit carries a No door: line.

Tests

  • New test/mcp-tools-may.test.ts. It pins both answers for a guest, a member and an admin signed in; ro, rw and admin tokens; and via, proposal, run and contribute tokens. None of them adds a disagreement row. It also checks that a disagreement is counted, and that the gate rule catches a new inline check.
  • Changed test/may.test.ts and test/tui-can.test.ts to expect forge.write in the lists.
  • Changed test/mcp-shared-gate.test.ts: its fake context had no app, and the door now reads ctx.app.db. The test was wrong-shaped, not the code.
  • Results: the type check passes, the gate passes, and about 2,100 tests pass across the MCP, may, gate and terminal suites. One gate-runner test fails ("where Chromium starts the gate runs the looks files"), because the sandbox has no Chromium; this change doesn't touch it.
  • Not run: the suites that need a unix socket or cells, and the full suite. The forge's check runs those.

Left out

  • needsAdminScope stays as scopeAllows(…, "admin"). It is about how far a token reaches, not a role. forge.administer asks only for scope rw, so moving it would let an admin's rw token see admin-scope tools.
  • mayBoards stays as it is.
  • Pages, SSH and the terminal screens, games and infrastructure are left for their own pulls.
  • I had no keep_plan or estimate tool in this run, so the issue has no plan and no time estimate.

Try it on the preview:

  • Call tools/call feed_dismiss on /mcp with an ro token: it is refused as read-only.
  • With a member's token, GET /api/v1/user shows forge.write in can.
  • With a non-admin token, calling scorecard answers "no tool named scorecard".

🤖 Generated with Claude Code

commented

Left #18092 open: 5 unticked items remain (Web pages: the page routes ask may(); inline isAdmin checks in them go.; SSH and the terminal screens ask may().; Games: game_grant's owner, operator and viewer become roles in the same model, using the existing grant, no new grant table.; …).

Sign in to join this conversation.

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

Keyboard shortcuts

Docs