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
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.
-
Reviews
Changes requested — before the latest pushI read the diff and the remaining callers. The core change holds: mayOnGame answers by may alone, every caller dropped the door argument, and the door API test shows an ro token reading and being refused 403 on POST. One finding to fix: the container console shows controls an ro token is then refused. The new ratchet also only catches
!mayDo(; I note that without asking for a change.ApprovedRound check since 4c2beb0f1877. The drawn-controls commit (e646ce994) is reverted and the games pages draw what main draws again; the rest of the diff is merges of main (#18424, #18431). Nothing new on the game door in these lines.
What I tried against mayOnGame and askingFor: an ro token on POST (page answers not found, door API 403, MCP asks with the credential sent); a non-owner on the door API (404); a HEAD request (treated as a read, same as GET); a revoked grant on the map pass (rechecked at every file); a signed-out caller (principalOfUser(undefined) holds nothing). All refused as they should be. mayOnGame no longer counts anything, and the new
grantratchet has a test that would fail without it.Non-blocking: an owner's ro token is still shown controls that its POST then refuses (page and /infra console). This is a display fault, not a hole, since the write is refused. It is tracked as #18432. Non-blocking: the ratchet only catches
!mayDo(, so amayDo(...)written positively would slip past it.Approved.
-
Checks
shipped production is serving it deploy e9eb675
-
History
- Revert the drawn game controls asking with the credential sent (#18427) 8cfe6c2
- Merge main into mason/18427: the terminal's palette offers by may alone (#18431) beside the game doors 198b1fb
- Access 3, terminal: the palette offers a screen by its `asks` through may(); the entries' own gates go (#18431) 55693b7
- Merge main into mason/18427: web pages ask may alone (#18424) beside the game doors 3ebaa06
- Access 3, web pages: the two known partings are decided, then each page's own isAdmin and sign-in check is deleted and may() alone decides (#18430) d4ae8b7
- Games: the controls a page draws ask operator with the credential sent (#18427) e646ce9
- Rewrap a comment in the game grant tests 4c2beb0
- Access 3, games: mayOnGame answers alone for the box, server and game-door checks (#18427) 27c06c1
- Access 3, terminal, games and infrastructure: the entries' own gates are deleted once may() has been asked beside them and agrees (#18428) be10e7a
- An imported session's page has a red Delete that asks for its title typed (#18423) 22c9252
- Access 3, terminal and games: SSH screens and game grants ask may() in shadow (#18412) fea5438
- A person deletes one of their imported sessions from its page, by typing its name (#18371) 3d2fa7b
- An imported session is deleted through the API by its owner who sends its exact title (#18390) 2c0a8b8
- Access 3, MCP: the scope floor is read from the disagreement count, then deleted (#18418) e374d6c
- A pull that adds a migration runs test/data-browser.test.ts in its fast tier (#18419) 105485a
- Access 3b, web pages: the remaining admin gates (a local user?.isAdmin, isAdmin !== true || agent) ask adminPage beside them (#18413) b9d6e88
- A new inline isAdmin check in a moved door fails the gate (#18410) e472288
- Access 3, infrastructure and clouds: the admin-only routes ask may() in shadow (#18409) 7855bb1
- Full suite red: test/data-browser.test.ts (#18411) 7f3333e
- Sentinel: backup was degraded 14 minutes today: The last restore drill 2026-12-06 failed at restore. The backup check last ran 2026-12-06T09:25:52.363Z (1 min ago); 39… (#18407) 24f4503
4 earlier comments
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,
GETon the door's API) asks about the account behind the request. Anrotoken opens what its account's grant opens. - A change (a page's
POST, the door'sPOST, the MCP tool) asks with the credential that was sent. Anrotoken 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
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:
containerConsoleon /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
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.tskeeps main'ssignedInPage,adminPageandpersonAdminPage, plus this branch'saskingFor. Main deletedpageAction, soaskingFornow names GET and HEAD as reads itself.src/design/door_checks.tscombines 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.tsentry inDOOR_LINESis removed, because main deleted the line it named. test/door-inline-checks.test.tskeeps 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 --noEmitandbun scripts/gate.ts --explainpass (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_mayoraskingFor: 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
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 ismayOnGame) from this branch. The other is a palette entry's own gate (entryGate) frommain. The ratchet scans both sides' files: the game door's API and the map, plus the terminal's screens undersrc/tui/screens/. The comments describe both changes.test/door-inline-checks.test.ts: the test checks that the scan reads the game door files andsrc/tui/screens/sentinel.ts.test/terminal-games-may.test.ts: the header comment now says both things: the palette offers bymayalone and counts nothing, and a game grant check ismay'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
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
GETon the door's API is asked of the account behind the request, so anrotoken opens whatever its account's grant opens. - Changes: a page's
POST, the door'sPOSTand the MCP tool are asked with the credential that was sent. Anrotoken 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.tsandgames/shell.tswork as before, anddocs/features/may.mdstill lists them as "not asked yet".seesGameBox, which decides whether you see a box at all, still runs in shadow besidemay.
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
mayOnGame(src/games/game_may.ts) now decides the box, server and game-door checks bymayalone:holds(game.view | game.operate | game.own), read from the existinggame_grantrow. The oldmayDo(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(containerConsoleinsrc/web/pages/games.ts) used its own inline grant check and now asksmayOnGame.Decision on an
rotoken operating a server.maycounts a token's scope, so what matters is who each door asks about. A new helper,askingFor(ctx)insrc/http/page_may.ts, settles it the same way the infrastructure pages did (#18425):GETon the door's API) asks about the account behind the request. Anrotoken opens what its account's grant opens.POST, the door'sPOST, the MCP tool) asks with the credential that was sent. Anrotoken can view but can't operate or own anything.seesGameBoxis still checked side by side, deliberately. Someone whose grant is on one server only can see the box but has nogame.viewover the whole box. SoseesBoxstill decides, and that expected disagreement is still counted undergame page/game tool metrics.Production disagreement rows. I could not read production's
access_disagreementtable: the sandbox blocks the database and nothing serves the table. Working from the code, the only rowsmayOnGamecould have written forgame %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. TheseesGameBoxrows remain and are expected.The inline-checks gate.
src/design/door_checks.tsnow also readssrc/http/api/game_door.ts,src/http/games_map.tsandsrc/web/pages/games*.ts. It has a newgrantcheck that flags an inline!mayDo(…)refusal and points atmayOnGame. 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.tsandgames/shell.ts.docs/features/may.mdstill 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 anrotoken's operator grant to still pass and be counted is replaced; I changed it because the decision changed. It now checks that anrotoken can view and nothing more, with no rows written. A new HTTP test covers the game door: the owner'srotoken gets 200 onGET, 403 onPOST lock; anrwtoken gets 200 onPOST; a non-owner gets 404.test/door-inline-checks.test.tsnow 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.tswith no failures, andbun scripts/design-lint.ts.bun scripts/fast.tscouldn't narrow the run becausepage_may.tsis imported almost everywhere, so I picked those files myself. The forge's full check runs the rest.scripts/similar.tswas not run before writingaskingFor; the gate's similarity check flagged onlyseesGameBox, and that is a false match.Try it on the preview: with an
rotoken of a box's owner,GET /api/v1/games/<box>/doorshould answer 200 andPOST {"op":"lock"}should answer 403. With anrwtoken, thePOSTshould succeed. The games tool still refusesrotokens at the MCP door, as before.🤖 Generated with Claude Code
Closes #18427