Public: anyone can read this; the crew can change it.
Access 3, terminal and games: SSH screens and game grants ask may() in shadow #18412
Merged 1h 48m ago, live in production
Terminal screens and game grant checks now also ask may(). The old checks still decide in every case; where may() answers differently, one row is counted in accessdisagreement, under door terminal or game . Terminal screens.
-
Reviews
Changes requested — before the latest pushRound 1, all changes in one list. Nothing here lets anyone in who was refused: the old checks still decide everywhere. The shadow is incomplete, so the counts would mislead.
- Box 1 (terminal screens) is only partly met. Some admin-gated screens name no
asks.crewbudgetsis gated onmayAct, the same gate ascrewfallback, which does askforge.administer. A screen with noasksnever produces aterminal <id>row, and nobody would notice. Go through every screen whose gate is the admin or an account and addasks. Where a screen is deliberately left out, say why in its own comment. - The test only checks that
asksis set on two named entries and that more than 50 entries askforge.administer. A screen that loses itsasksor gets the wrong one still passes. Add a test that, for each entry withasks, callsofferedwith an admin, a plain user, an agent and a signed-out session, and compares each answer toholds(...). Entries that part for a reason you accept (agent exclusions) go in a named allow-list. - Box 2 (game viewer checks) is only partly met. In the web
boxOf, the box page (service === '' && need === 'viewer') returns before any check, sogame.viewis never asked for the box page. Themetricstool without a service andcompactMetrics's per-servermayDoare not asked either. Route these throughmayOnGame, or say indocs/features/may.mdwhich viewer checks are not covered. - The terminal palette writes to the database on every build.
offerscallsaskBesidefor every entry each time the palette is built. A signed-out or agent session that parts on dozens of entries causes dozens of upserts per build, on the request path. Ask once per session, or memoise per (session, entry). docs/features/may.mdsays the terminal's Games screens go throughmayOnGame. Thenkey in the games screen still picks its box with a baremayDo(roleOn(...))inlistBoxes(...).find(...). Fix the text or the code.
ApprovedApproved. Round 2 asks met:
showsmoves the nothing-to-show condition ahead ofmay, so empty screens count no parting;offeredstays the whole answer (the bills, crew-budgets, cores, made-from and returns tests that call it directly are safe); the palette asks once per session per entry/account/gate answer; the Games screen keys and screens (n, server, settings, grants,l,w,a) and the box page'sseesGameBoxmatch what the doc says; the 18 unasked entries each say why. I tried to break it with: a signed-out palette rebuilt repeatedly (one row per entry, not one per build), a one-server grantee on the box page (an expected, documentedgame.viewparting that still opens the page), a helper service (nobody holds a role), a malformed or hostileresourceon/api/v1/may(422 by the box/service name patterns), a nonexistent box versus a box with no grant (bothnot_found), and anrotoken (the old check still decides). The disagreement counter is a bounded upsert, so no row growth.test/terminal-games-may.test.tspasses here (12). Non-blocking:operator()in the server screen now asks on each render, which writes a row only on a parting; if that ever turns noisy, memoise per screen. - Box 1 (terminal screens) is only partly met. Some admin-gated screens name no
-
Checks
shipped production is serving it deploy 55693b7
-
History
- Palette entries keep offered as the whole answer; the games-may test stops the loop sampler it starts (#18396) 093cd0d
- Rewrap game_may's comments (#18396) afe92a4
- Rewrap long comments; mayOnGame and seesGameBox share one way of asking beside (#18396) dd89a20
- Games: the box page, whole-box metrics and the terminal's game keys ask may beside the grant (#18396) 2a02adb
- Terminal: every admin- or account-gated screen asks may, once a session; the rest say why not (#18396) d2e2ce4
- Try: ask GET /api/v1/may?action=game.view&resource=<box> with a token, then SELECT * FROM access_disagreement after opening the terminal palette signed out (#18396) 226157f
- The terminal-and-games may test builds a real Session, not a cast (#18396) ea56856
- Access 3, terminal and games: palette gates and game grants ask may() beside the old check (#18396) 403c6d2
- A tab-forge read-only link can be revoked by the person who made it (#18402) bfd96cb
- Access 3, web pages: every page that gates on isAdmin or sign-in also asks may(), counted beside the old check (#18400) 8f27ed4
- A tab-forge app leaves as one spec file and comes back in, with or without its records (#18399) 081ac9e
- A person shares one imported session by a link that hides what the forge redacts (#18391) 080d52c
- Full suite red: test/data-browser.test.ts (#18394) b4310c7
- Red after landing: #18373 broke test/data-browser.test.ts (#18393) ab53312
- An imported session opens by reading its stored gzip line by line, not as one decoded string (#18387) a3b5b3e
- A big session is stored without holding the whole file twice: the import writes it to gzip in chunks and checks UTF-8 as it goes (#18385) 8ceefc1
- A person imports a Claude Code or Codex session from /traces in the browser (#18382) d8b1b2b
- A person saves a /traces search by name and reopens it from the list and the palette (#18381) db6a2d2
- small: an imported session's row in /traces opens its page (#18379) 067798c
- Full suite red: test/talk-build-no-crew.test.ts (#18380) fc3efe0
2 earlier comments
Terminal screens and game grant checks now also ask may(). The old checks still decide in every case; where may() answers differently, one row is counted in access_disagreement, under door terminal <entry> or game <door>.
Terminal screens. A palette entry can now name the action its gate stands for, in a new optional asks field on PaletteEntry (src/tui/screens/entries.ts). 81 entries gated on the admin name forge.administer, and 27 gated on having an account name forge.read, the same rule the web pages use. When the palette is built, it asks may() that action for the terminal's account beside offered. Screens gated on something else name no action and are not asked: a grant, a subscription, a telemetry role, or the admin plus another condition. Two partings will show up often:
- an admin agent on a screen that turns agents away;
- anyone signed out, on a screen that needs an account (
forge.readis open to everyone).
Game grants. The viewer, operator and owner of game_grant are now game.view, game.operate and game.own in src/core/may.ts. Forge admins own every box, and nobody holds a role on the forge's own helper container. No new table was added. src/games/store.ts gains grantOn (a person's own grants), which roleOn now uses, and its rank table now comes from may. src/games/game_may.ts mayOnGame runs the old mayDo(roleOn(…)) check, which still decides, and asks may() beside it. It is wired into the refusal points only:
- the box page's
boxOf; - the games MCP tool (
create_server/remove_server,metrics,config, the operator actions); - the game door API;
- the map;
- the terminal Games screens (shell, add and remove a server, sleep, power), map and spark.
The parting you should expect is an ro token operating a server through its grant.
Shared step. askBeside in src/core/access_disagreement.ts is now the one shadow step; http/may_beside.ts uses it. I left mayRepo alone: may already decides there, which is a different shape.
API. GET /api/v1/may now accepts resource=box or box/service for a game.* action. A box you hold no role on answers not_found, the same as one that doesn't exist. I updated the OpenAPI text for it.
Tests. test/terminal-games-may.test.ts covers each door: one deliberate disagreement writes a row, agreement writes none, and the old answer is the one returned. It also covers may()'s reasons for game actions and the API. docs/features/may.md names both doors.
Checks. The gate is clean (0 fail) and tsc --noEmit and the design lint pass. I ran the tests that cover this rather than the whole suite: 60 files, including the games, palette, may, OpenAPI, unused-exports, duplicate-import and page-budget suites, all passing. Some game tests tried to reach api.modrinth.com and were refused by the sandbox; they still passed.
Not done:
- Checks inside screens that only shape what is shown (key hints, lists filtered by role) are not counted.
- In the game files #18028/#18025/#18019/#18042 cover, only the grant check itself was touched, and nothing in
chat.ts,people.tsor the agent. - I couldn't record the plan on the issue: the
keep_plantool isn't available in this session.
To try: with a token, ask GET /api/v1/may?action=game.view&resource=<box>/<server>. Then open the terminal palette signed out and read SELECT * FROM access_disagreement ORDER BY seen DESC.
[{"go":"/api/v1/may?action=game.view&resource=net","look":"the JSON answer","expect":"may true for someone with a grant on box net, or not_found otherwise; a 422 for resource=Net!"}]
🤖 Generated with Claude Code
This round handles all five points from the review. The old checks still decide everywhere; may is still only asked beside them and counted.
1. Terminal screens (src/tui/screens/entries.ts). These entries now name asks:
forge.administer:crewbudgets,cores,valves,abstractions,series,refused-asks,now,disks,app-templates,devices,traffic-sourcesforge.read:bills,made-from,returns
Some gates also checked whether there is anything to show (a file on the forge, the forge's own key, runs, bills). That condition moves to a new optional shows on the entry. The palette asks shows first, and when it says no, the entry is not offered and may is not asked, so an empty screen counts no parting. The 18 entries that still name no action each say why in a comment next to their gate: they are offered to everyone, or gated on something may has no action for (a telemetry role, a subscription, an organization, a game grant, data to show).
2. Test (test/terminal-games-may.test.ts). For every entry with asks, the test calls offered with an admin, a plain user, an admin agent and a signed-out session, and compares each answer to holds(...).
- The agent was made an admin so that agent exclusions show up. 80 entries leave agents out, and they are in the named list
AGENTS_LEFT_OUT. - Signed out, the
forge.readscreens are expected to part, the same parting the web pages already count. NOT_ASKEDpins the entries that name no action, so an entry that loses itsasksfails the test.
3. Game viewer checks. A new seesGameBox in src/games/game_may.ts asks game.view over the box beside seesBox. It is used by:
- the web box page in
boxOf; - the games tool's
metricswithout a service. The per-server filter incompactMetricsnow goes throughmayOnGame.
A person whose grants are on one server only sees the box but holds no game.view over all of it. Those visits will be counted every time; docs/features/may.md names this as an expected parting. The doc also lists the viewer checks still not asked: list filters, and checks made again for background jobs (games/chat.ts, games/when_quiet.ts, games/shell.ts).
4. Palette writes. offers now asks may at most once per session for each entry, account, admin flag and gate answer, not on every build. A test builds the palette three times signed out and checks that only the first build writes rows.
5. Games screen. I fixed the code to match the doc. The n key's box pick now uses mayOnGame. So do the server, settings, plugin config, mods and grants screens and the l, w and a keys. The status lines drawn on screen are only display filters, and the doc lists them as not asked.
Checks. bun x tsc --noEmit, bun scripts/gate.ts --explain (0 fail) and bun scripts/design-lint.ts pass. scripts/fast.ts named 4,022 test files, so I chose 66 that cover the change: the may, palette, games, maintenance, crew, billing, returns, unused-exports, dup-imports and page-budget suites. 648 passed and 3 failed in that run:
- "the repository has no duplicate import beyond the allowlist" and "standby > answers 503 with Retry-After, and /healthz is 200" both passed when I ran their files again from the repository root.
- "a missing tree scans empty; any other read error throws" was not run again.
I did not run the full suite; the forge's check runs it on the push.
[{"go":"/games/<box> signed in as someone granted one server only","look":"the box page","expect":"the page opens as before, and access_disagreement gains one row for 'game page' / game.view with may 0"},
{"go":"ssh in with FORGE_APP_SSH signed out, open the palette twice","look":"SELECT door FROM access_disagreement","expect":"one 'terminal <entry>' row per account screen after the first open, none added by the second"}]
🤖 Generated with Claude Code
The terminal palette and the games doors now ask may beside the checks they already had, and count each disagreement in access_disagreement (#18396). The old check still decides everywhere.
Terminal. Each palette entry gated on the forge's admin or on having an account now names the action that gate stands for (asks: "forge.administer" or "forge.read"). addEntries asks may that action beside offered, once per session, and counts any disagreement under terminal <id>. An entry gated on something may has no action for (a telemetry role, a subscription, a game grant, or nothing at all) names no action and says why in a comment.
shows is the part of the gate that isn't about who is asking, such as a file the forge has. It's checked first, so a screen with nothing to show never asks may. offered is still the whole answer, so anything that calls it on its own gets the same result as before.
Games. may learns game.view, game.operate and game.own over a box or one of its servers. The box page, the whole-box metrics, the MCP game tools and the terminal's game keys ask these beside the grant check (src/games/game_may.ts).
Fixes after the last check. Three of the four red tests came from this pull:
- Bills and crew budgets: I had cut five entries'
offereddown to the who-is-asking check and moved the rest intoshows. The bills and crew-budgets tests calloffereddirectly, so they saw the wrong answer.offeredis the full condition again on bills, cores, crewbudgets, madefrom and returns. game-answer: the newtest/terminal-games-may.test.tscallsserve(), which starts the process's loop-lag sampler on a real timer and never stops it. Whengame-answerran later in the same shard on fake timers, it counted one extra timer. The new test now callsstopLoopWorst()inafterAll.
The fourth, large-blobs "the page lists it…", passes five runs on its own and alongside the new test, and goes through no code this pull changes. The check didn't blame this pull for it either, so it looks like a flake in that shard rather than a fix to make here.
The type check passes. The gate passes, apart from notes that the new test's helpers look like two existing ones. scripts/fast.ts named too many files to run, so I ran a chosen set: the 181 test files that import the changed entries or the palette, plus game-answer and large-blobs (1950 pass, 0 fail). The full suite was not run here; the forge's check runs it on this push.
To try it: open the terminal palette signed out, as a user and as an agent, then SELECT * FROM access_disagreement. You can also ask GET /api/v1/may?action=game.view&resource=<box> with a token.
🤖 Generated with Claude Code
Terminal screens and game grant checks now also ask
may(). The old checks still decide in every case; wheremay()answers differently, one row is counted inaccess_disagreement, under doorterminal <entry>orgame <door>.Terminal screens. A palette entry can now name the action its gate stands for, in a new optional
asksfield onPaletteEntry(src/tui/screens/entries.ts). 81 entries gated on the admin nameforge.administer, and 27 gated on having an account nameforge.read, the same rule the web pages use. When the palette is built, it asksmay()that action for the terminal's account besideoffered. Screens gated on something else name no action and are not asked: a grant, a subscription, a telemetry role, or the admin plus another condition. Two partings will show up often:forge.readis open to everyone).Game grants. The viewer, operator and owner of
game_grantare nowgame.view,game.operateandgame.owninsrc/core/may.ts. Forge admins own every box, and nobody holds a role on the forge's own helper container. No new table was added.src/games/store.tsgainsgrantOn(a person's own grants), whichroleOnnow uses, and its rank table now comes frommay.src/games/game_may.tsmayOnGameruns the oldmayDo(roleOn(…))check, which still decides, and asksmay()beside it. It is wired into the refusal points only:boxOf;create_server/remove_server,metrics,config, the operator actions);The parting you should expect is an
rotoken operating a server through its grant.Shared step.
askBesideinsrc/core/access_disagreement.tsis now the one shadow step;http/may_beside.tsuses it. I leftmayRepoalone:mayalready decides there, which is a different shape.API.
GET /api/v1/maynow acceptsresource=boxorbox/servicefor agame.*action. A box you hold no role on answersnot_found, the same as one that doesn't exist. I updated the OpenAPI text for it.Tests.
test/terminal-games-may.test.tscovers each door: one deliberate disagreement writes a row, agreement writes none, and the old answer is the one returned. It also coversmay()'s reasons for game actions and the API.docs/features/may.mdnames both doors.Checks. The gate is clean (0 fail) and
tsc --noEmitand the design lint pass. I ran the tests that cover this rather than the whole suite: 60 files, including the games, palette, may, OpenAPI, unused-exports, duplicate-import and page-budget suites, all passing. Some game tests tried to reach api.modrinth.com and were refused by the sandbox; they still passed.Not done:
chat.ts,people.tsor the agent.keep_plantool isn't available in this session.To try: with a token, ask
GET /api/v1/may?action=game.view&resource=<box>/<server>. Then open the terminal palette signed out and readSELECT * FROM access_disagreement ORDER BY seen DESC.🤖 Generated with Claude Code
Closes #18396