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

opened this

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.

Notes

opened this

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.read is 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.ts or the agent.
  • I couldn't record the plan on the issue: the keep_plan tool 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

Closes #18396

2 earlier comments
commented

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.read is 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.ts or the agent.
  • I couldn't record the plan on the issue: the keep_plan tool 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

commented

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-sources
  • forge.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.read screens are expected to part, the same parting the web pages already count.
  • NOT_ASKED pins the entries that name no action, so an entry that loses its asks fails 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 metrics without a service. The per-server filter in compactMetrics now goes through mayOnGame.

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

commented

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' offered down to the who-is-asking check and moved the rest into shows. The bills and crew-budgets tests call offered directly, so they saw the wrong answer. offered is the full condition again on bills, cores, crewbudgets, madefrom and returns.
  • game-answer: the new test/terminal-games-may.test.ts calls serve(), which starts the process's loop-lag sampler on a real timer and never stops it. When game-answer ran later in the same shard on fake timers, it counted one extra timer. The new test now calls stopLoopWorst() in afterAll.

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

Sign in to join this conversation.

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

Keyboard shortcuts

Docs