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

Access 3, games: mayOnGame answers alone for the box, server and game-door checks #18429

opened this

Merged 7h 19m ago, live in production

mayOnGame (src/games/gamemay.ts) now decides the box, server and game-door checks by may alone: holds(game.view | game.operate | game.own), read from the existing gamegrant row. The old mayDo(roleOn(…)) check it ran beside, and the door name it took, are gone, and every caller drops that argument.

Notes

opened this

mayOnGame (src/games/game_may.ts) now decides the box, server and game-door checks by may alone: holds(game.view | game.operate | game.own), read from the existing game_grant row. The old mayDo(roleOn(…)) check it ran beside, and the door name it took, are gone, and every caller drops that argument. There is no new grant table. One more check moves over: the container console on /infra (containerConsole in src/web/pages/games.ts) used its own inline grant check and now asks mayOnGame.

Decision on an ro token operating a server. may counts a token's scope, so what matters is who each door asks about. A new helper, askingFor(ctx) in src/http/page_may.ts, settles it the same way the infrastructure pages did (#18425):

  • A read (opening a page, GET on the door's API) asks about the account behind the request. An ro token opens what its account's grant opens.
  • A change (a page's POST, the door's POST, the MCP tool) asks with the credential that was sent. An ro token can view but can't operate or own anything.
  • The terminal and the map's pass ask as the account, as before.

seesGameBox is still checked side by side, deliberately. Someone whose grant is on one server only can see the box but has no game.view over the whole box. So seesBox still decides, and that expected disagreement is still counted under game page / game tool metrics.

Production disagreement rows. I could not read production's access_disagreement table: the sandbox blocks the database and nothing serves the table. Working from the code, the only rows mayOnGame could have written for game % were token-scope disagreements. The decision above now settles those, and new ones can't be written because nothing is asked side by side any more. The seesGameBox rows remain and are expected.

The inline-checks gate. src/design/door_checks.ts now also reads src/http/api/game_door.ts, src/http/games_map.ts and src/web/pages/games*.ts. It has a new grant check that flags an inline !mayDo(…) refusal and points at mayOnGame. It allows one existing line, games_client_pack.ts's visitor branch: it lets a visitor into a pack link rather than refusing anyone.

Left alone: the checks that only filter lists, and the background-job re-checks in games/chat.ts, games/when_quiet.ts and games/shell.ts. docs/features/may.md still lists them as "not asked yet", and its game section now says how the game checks work.

Tests. In test/terminal-games-may.test.ts, the old test that expected an ro token's operator grant to still pass and be counted is replaced; I changed it because the decision changed. It now checks that an ro token can view and nothing more, with no rows written. A new HTTP test covers the game door: the owner's ro token gets 200 on GET, 403 on POST lock; an rw token gets 200 on POST; a non-owner gets 404. test/door-inline-checks.test.ts now checks that the game files are scanned and that the grant check is found.

Checks run. These passed: bun x tsc --noEmit, 25 test files (game, may, door, MCP, cloud-container, dead-code and duplicate-import tests), scripts/gate.ts with no failures, and bun scripts/design-lint.ts. bun scripts/fast.ts couldn't narrow the run because page_may.ts is imported almost everywhere, so I picked those files myself. The forge's full check runs the rest. scripts/similar.ts was not run before writing askingFor; the gate's similarity check flagged only seesGameBox, and that is a false match.

Try it on the preview: with an ro token of a box's owner, GET /api/v1/games/<box>/door should answer 200 and POST {"op":"lock"} should answer 403. With an rw token, the POST should succeed. The games tool still refuses ro tokens at the MCP door, as before.

🤖 Generated with Claude Code

Closes #18427

4 earlier comments
commented

mayOnGame (src/games/game_may.ts) now decides the box, server and game-door checks by may alone: holds(game.view | game.operate | game.own), read from the existing game_grant row. The old mayDo(roleOn(…)) check it ran beside, and the door name it took, are gone, and every caller drops that argument. There is no new grant table. One more check moves over: the container console on /infra (containerConsole in src/web/pages/games.ts) used its own inline grant check and now asks mayOnGame.

Decision on an ro token operating a server. may counts a token's scope, so what matters is who each door asks about. A new helper, askingFor(ctx) in src/http/page_may.ts, settles it the same way the infrastructure pages did (#18425):

  • A read (opening a page, GET on the door's API) asks about the account behind the request. An ro token opens what its account's grant opens.
  • A change (a page's POST, the door's POST, the MCP tool) asks with the credential that was sent. An ro token can view but can't operate or own anything.
  • The terminal and the map's pass ask as the account, as before.

seesGameBox is still checked side by side, deliberately. Someone whose grant is on one server only can see the box but has no game.view over the whole box. So seesBox still decides, and that expected disagreement is still counted under game page / game tool metrics.

Production disagreement rows. I could not read production's access_disagreement table: the sandbox blocks the database and nothing serves the table. Working from the code, the only rows mayOnGame could have written for game % were token-scope disagreements. The decision above now settles those, and new ones can't be written because nothing is asked side by side any more. The seesGameBox rows remain and are expected.

The inline-checks gate. src/design/door_checks.ts now also reads src/http/api/game_door.ts, src/http/games_map.ts and src/web/pages/games*.ts. It has a new grant check that flags an inline !mayDo(…) refusal and points at mayOnGame. It allows one existing line, games_client_pack.ts's visitor branch: it lets a visitor into a pack link rather than refusing anyone.

Left alone: the checks that only filter lists, and the background-job re-checks in games/chat.ts, games/when_quiet.ts and games/shell.ts. docs/features/may.md still lists them as "not asked yet", and its game section now says how the game checks work.

Tests. In test/terminal-games-may.test.ts, the old test that expected an ro token's operator grant to still pass and be counted is replaced; I changed it because the decision changed. It now checks that an ro token can view and nothing more, with no rows written. A new HTTP test covers the game door: the owner's ro token gets 200 on GET, 403 on POST lock; an rw token gets 200 on POST; a non-owner gets 404. test/door-inline-checks.test.ts now checks that the game files are scanned and that the grant check is found.

Checks run. These passed: bun x tsc --noEmit, 25 test files (game, may, door, MCP, cloud-container, dead-code and duplicate-import tests), scripts/gate.ts with no failures, and bun scripts/design-lint.ts. bun scripts/fast.ts couldn't narrow the run because page_may.ts is imported almost everywhere, so I picked those files myself. The forge's full check runs the rest. scripts/similar.ts was not run before writing askingFor; the gate's similarity check flagged only seesGameBox, and that is a false match.

Try it on the preview: with an ro token of a box's owner, GET /api/v1/games/<box>/door should answer 200 and POST {"op":"lock"} should answer 403. With an rw token, the POST should succeed. The games tool still refuses ro tokens at the MCP door, as before.

🤖 Generated with Claude Code

commented

With this pull, mayOnGame is the only answer to every game grant check, whether on the box, a server or the game door. The inline mayDo(roleOn(…), need) check it used to sit beside is gone, along with its door name. Opening a page is a read and is asked of the account behind the request. A change is asked with the credential sent (askingFor, src/http/page_may.ts). So an ro token opens whatever its account's grant opens, and can operate nothing.

Review fix (container console): game pages that draw controls now ask operator with principalOf(ctx.auth), the same credential a POST would send. Before, an owner's ro token was shown Start, Stop, Restart and the command input, and every one of those posts was then refused. This covers:

  • containerConsole on /infra
  • the server rows on the box page
  • the box page's operator controls: a new server from words, removing a server
  • the server page (gameServicePage)
  • the blocks the server page's stream redraws

Tests: test/game-ro-controls.test.ts checks the console and /games/mc/survival with an owner's ro token (no power form, no command input) and with an rw token (both drawn). Both tests fail without the fix.

What I left alone:

  • chatBlock's operator check (src/web/pages/games.ts:417) only decides whose linked players are listed. It draws no control, so it stays as the account's view.
  • The owner-only pinned block on the server page is already behind act.
  • The door-inline-checks ratchet still only catches !mayDo(, as the review noted without asking for a change.
  • No terminal change: the terminal's game screens run under a session, never a token, so nothing they draw changes. The commit says so with a No door: line.

Checks run: bun x tsc --noEmit, bun scripts/gate.ts (0 fail; --fix changed nothing) and bun scripts/design-lint.ts pass. bun scripts/fast.ts named 2928 test files, too many to run here, so I picked the games, game door API, terminal games, game console, infra containers, door-inline-checks and page budget suites: 206 pass, 0 fail. The forge's check runs the full suite on this push.

To try it: sign in as a box owner, make an ro token, then open /games/<box>/<server> and its /infra container with that token. Logs show, but no power buttons and no command field. An rw token shows both.

🤖 Generated with Claude Code

commented

With this pull, mayOnGame is the only answer to every game grant check, whether on the box, a server or the game door. The inline mayDo(roleOn(…), need) check it used to sit beside is gone, along with its door name. Opening a page is a read and is asked of the account behind the request; a change is asked with the credential sent (askingFor, src/http/page_may.ts). So an ro token opens whatever its account's grant opens, and can operate nothing.

Review fix: game pages that draw controls now ask operator with principalOf(ctx.auth), the same credential a POST would send. An owner's ro token is no longer shown Start, Stop, Restart or the command input that its posts would be refused. This covers:

  • the container console on /infra
  • the server rows on the box page
  • the box page's operator controls: a new server from words, removing a server
  • the server page
  • the blocks the server page's stream redraws

test/game-ro-controls.test.ts checks both the console and the server page for an ro and an rw token; both tests fail without the fix.

Merge with main (#18424: web pages ask may alone):

  • src/http/page_may.ts keeps main's signedInPage, adminPage and personAdminPage, plus this branch's askingFor. Main deleted pageAction, so askingFor now names GET and HEAD as reads itself.
  • src/design/door_checks.ts combines both sides. It scans every web page (main's change) plus the game door's API and the map, and keeps this branch's inline game grant check (!mayDo().
  • The games_client_pack.ts entry in DOOR_LINES is removed, because main deleted the line it named.
  • test/door-inline-checks.test.ts keeps the expected scan paths from both sides.

What I left alone:

  • chatBlock's operator check (src/web/pages/games.ts:417) only decides whose linked players are listed; it draws no control.
  • The door-inline-checks ratchet still only catches !mayDo(, as the review noted without asking for a change.
  • No terminal change: the terminal's game screens run under a session, never a token, so nothing they draw changes.

Checks run after the merge:

  • bun x tsc --noEmit and bun scripts/gate.ts --explain pass (39 rules, 0 fail).
  • The door-inline-checks, game and infra suites, unused-exports, duplicate imports and the page budget suite pass, as does every test that uses page_may or askingFor: 223 pass, 0 fail.
  • The forge's check runs the full suite on this push.

To try it: open /games/<box>/<server> and its /infra container with an owner's ro token. Logs show, but no power buttons and no command field; an rw token shows both.

🤖 Generated with Claude Code

commented

The game doors now take a game grant check from mayOnGame alone, the answer may gives (#18427). mayOnGame drops its door argument and asks nothing in shadow beside the grant, so a mismatch between the two is no longer counted as a disagreement. Only whether a person can see a box is still asked in shadow, and a disagreement there is counted under game <door>. The game door's API and the map ask may. A read-only token can read a box its grant reaches, but it cannot operate or own one. The controls a page draws ask whether the person is an operator, using the credential the request sent.

This update merges main and its terminal palette change (#18431), which offers a screen by its asks through may(). Three files conflicted, and each keeps both sides:

  • src/design/door_checks.ts: the inline-check ratchet looks for both new kinds of gate. One is a game grant read inline (grant, where the fix is mayOnGame) from this branch. The other is a palette entry's own gate (entryGate) from main. The ratchet scans both sides' files: the game door's API and the map, plus the terminal's screens under src/tui/screens/. The comments describe both changes.
  • test/door-inline-checks.test.ts: the test checks that the scan reads the game door files and src/tui/screens/sentinel.ts.
  • test/terminal-games-may.test.ts: the header comment now says both things: the palette offers by may alone and counts nothing, and a game grant check is may's answer alone. The test bodies merged without conflict.

No test was changed beyond that. The type check passes and the gate finds no problem. scripts/fast.ts found the merge too broad to name tests from (2955 files), so I picked 18 suites myself: the door-check ratchet, the game, map, terminal-screen, palette and may suites, and the two both-doors suites. All 386 tests pass.

🤖 Generated with Claude Code

commented

mayOnGame (src/games/game_may.ts) now makes the box, server and game-door checks on its own. The game_grant rows are still the data behind game.view, game.operate and game.own, and there is no new grant table.

The ro token decision:

  • Reads: opening a page or a GET on the door's API is asked of the account behind the request, so an ro token opens whatever its account's grant opens.
  • Changes: a page's POST, the door's POST and the MCP tool are asked with the credential that was sent. An ro token can't operate or own anything: a page answers not found and the API answers 403.

Tests hold both sides, and docs/features/may.md describes it. test/door-inline-checks.test.ts now covers the game door files.

Not changed:

  • games/chat.ts, games/when_quiet.ts and games/shell.ts work as before, and docs/features/may.md still lists them as "not asked yet".
  • seesGameBox, which decides whether you see a box at all, still runs in shadow beside may.

The last check failed two tests in test/game-proxy-jars.test.ts. The cause was an earlier commit on this branch (e646ce994) that I had added beyond the issue: it made the pages draw their controls (Start/Stop/Restart, the command box, the plugin plan) only for a token allowed to change things. Those two tests read the plugin plan with an ro token, so it disappeared. That commit is now reverted; the tests are unchanged, and the pages draw what main draws. The leftover problem, where an ro token is shown controls that its POST then refuses, is its own issue, #18432.

Checks run locally, all passing: bun x tsc --noEmit, bun scripts/gate.ts, bun scripts/design-lint.ts, every test/game* and test/may* suite, test/door-inline-checks.test.ts, and the dead-code, duplicate-import and first-view-budget tests. bun scripts/fast.ts named 2954 test files, too many to run here, so I picked these myself; the forge runs the full check on this push.

Not checked: I couldn't reach production's access_disagreement table from here, so whether its game % rows are empty still needs looking at.

To try it: with an owner's ro token, GET /games/<box>/<server> opens the page, and POST Start on it is refused.

🤖 Generated with Claude Code

Sign in to join this conversation.

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

Keyboard shortcuts

Docs