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

A terminal on a machine or container needs a shell grant on that machine, a passkey check at open, and a record the machine's owner can read #18600

opened this

Merged 1h 23m ago, live in production

A machine or container now has a shell grant, a passkey-gated open and a record the owner can read. Nothing opens a terminal yet. The push is in, and the forge's check has not reported yet.

Notes

opened this

A machine or container now has a shell grant, a passkey-gated open and a record the owner can read. Nothing opens a terminal yet. The push is in, and the forge's check has not reported yet.

What changed

  • may() and the grant. shell is a new role in the existing game_grant table, between operator and owner, so no new grant table. may() answers it as game.shell over a machine or one container, and forge admins hold it as owners. Repository write alone is refused. The grants form on /games/<machine> and the terminal's grants screen now offer the role.
  • The passkey check. openShell in src/games/shell_open.ts refuses without the grant. It also refuses without a passkey signed in the same call, and a replayed or someone else's proof counts as none. Nothing is written when it refuses. It reuses passkeyProves, the same check as the game-door window.
  • The record. A new shell_open table holds one row per open: who, machine, container, opened, closed and why. The owner reads it under "Terminals opened" on /games/<machine> and with o in the grants screen. If the account is purged the row stays, because user_id is set to null and the name is kept.
  • Tests and docs. test/shell-open.test.ts covers the grant, the passkey refusals, the close and the owner-only page, and docs/features/game-box.md and may.md describe it. The related suites I ran pass, and so do tsc and the gate's rules (bun scripts/gate.ts has no failing rule).

What I left out

  • No route. No route or terminal calls openShell, as the issue asked. Reachability is deferred: the commit carries a No door: line, and the next issue wires it.
  • Operator rights. A shell holder also holds the operator rights on that machine, because the roles rank by order. Say if you want shell kept separate from operator.
  • The old SSH screens. I did not touch them, so the bypass risk named in the issue is not checked against them.

To try it Grant someone shell on /games/<machine>, then read "Terminals opened" there, or press o in the machine's grants screen in the terminal. bun test test/shell-open.test.ts runs the whole path.

I reused passkeyProves/proofChallenge, gameResource and the existing game_grant rank. scripts/similar.ts and the keep_plan and estimate tools were not run.

Closes #18502

4 earlier comments
commented

A machine or container now has a shell grant, a passkey-gated open and a record the owner can read. Nothing opens a terminal yet. The push is in, and the forge's check has not reported yet.

What changed

  • may() and the grant. shell is a new role in the existing game_grant table, between operator and owner, so no new grant table. may() answers it as game.shell over a machine or one container, and forge admins hold it as owners. Repository write alone is refused. The grants form on /games/<machine> and the terminal's grants screen now offer the role.
  • The passkey check. openShell in src/games/shell_open.ts refuses without the grant. It also refuses without a passkey signed in the same call, and a replayed or someone else's proof counts as none. Nothing is written when it refuses. It reuses passkeyProves, the same check as the game-door window.
  • The record. A new shell_open table holds one row per open: who, machine, container, opened, closed and why. The owner reads it under "Terminals opened" on /games/<machine> and with o in the grants screen. If the account is purged the row stays, because user_id is set to null and the name is kept.
  • Tests and docs. test/shell-open.test.ts covers the grant, the passkey refusals, the close and the owner-only page, and docs/features/game-box.md and may.md describe it. The related suites I ran pass, and so do tsc and the gate's rules (bun scripts/gate.ts has no failing rule).

What I left out

  • No route. No route or terminal calls openShell, as the issue asked. Reachability is deferred: the commit carries a No door: line, and the next issue wires it.
  • Operator rights. A shell holder also holds the operator rights on that machine, because the roles rank by order. Say if you want shell kept separate from operator.
  • The old SSH screens. I did not touch them, so the bypass risk named in the issue is not checked against them.

To try it Grant someone shell on /games/<machine>, then read "Terminals opened" there, or press o in the machine's grants screen in the terminal. bun test test/shell-open.test.ts runs the whole path.

I reused passkeyProves/proofChallenge, gameResource and the existing game_grant rank. scripts/similar.ts and the keep_plan and estimate tools were not run.

commented

I fixed both failing tests and pushed. The three test files that cover the change pass locally: the two that failed plus test/shell-open.test.ts. bun x tsc --noEmit is clean. I did not run the full suite; the forge runs it on this push.

  • mayShell: it was exported from src/games/shell_open.ts beside may(), which test/may-only.test.ts refuses. Nothing outside that file used it, so it is now module-private. The check still goes through holds(...) and may's game.shell action.
  • Event audience: openShell and closeShell emit machine.shell.opened and machine.shell.closed, which src/core/event_audience.ts hadn't classified. I added machine.shell. next to game.shell. in the admins' list, so a shell open is heard by the admins and not by readers.

No page, action or route changed, so the commit says No door: and why.

gate --fix reported two long comment lines in src/tui/screens/games.ts and src/web/pages/games.ts. It left them for the nightly rewrap.

commented

I've addressed all four of Sentinel's points and the role-label note, and pushed the changes to the branch. These tests pass locally: shell-open, tui-games, games, pages-budget, may-only and event-audience-coverage. tsc and design-lint are clean. I didn't run the full suite, which the forge runs on the push.

  • Page and terminal:
    • The explanatory paragraph under "Terminals opened" is gone.
    • Each row's title is the account name, and the meta no longer repeats it. It reads like survival: opened … closed … (idle), or machine: … when the terminal is on the machine itself. The terminal's o list uses the same words.
  • Stale opens:
    • closeStaleShells in src/games/shell_open.ts ends every still-open row with the reason "forge restarted".
    • docs/features/game-box.md says the caller that runs terminals (the next step) calls it once at boot.
    • The same note says closeShell takes a bare id and is reachable from no request.
  • Role label: the web grants form and the terminal grant prompt now say the shell role also operates the machine. The same line is in game-box.md.
  • Tests added:
    • In test/tui-games.test.ts: a non-owner pressing o sees the refusal and no rows, an owner sees the rows, and the grant prompt accepts shell.
    • In test/shell-open.test.ts: POST /games/net/grant with role=shell stores the grant for an owner and returns 404 for a non-owner. The machine.shell.* events are classified as admin-only. The restart sweep ends open rows once.
  • gate --fix: I ran it and it changed nothing. It still reports four files with comment lines over 100 columns, but none of those lines are ones this pull adds, so there was nothing of mine to commit.

I left out what the next step owns: nothing starts a terminal here, so the sweep has no caller yet.

commented

The dead-code check failed because nothing called closeStaleShells. It is now called on boot from src/engine/duties.ts, next to the other boot sweeps. That closes any shell record a restart left open, so the owner's record never shows a terminal as "still open" after it is gone.

I ran bun x tsc --noEmit, test/unused-exports.test.ts and test/shell-open.test.ts, and all pass. bun scripts/gate.ts also ran. Its only finding is a note about comment lines over 100 columns in files this change doesn't touch, which the nightly rewrap handles. I did not run the full suite; the forge runs it on the push.

The fix is pushed as 422e10cfb.

commented

The job-slices check failed because the new boot job, shell-sweep, was neither timed nor listed as untimed. I added it to UNTIMED in test/job-slices.test.ts, with the reason: it runs once on boot, does one SELECT, and does one UPDATE per record a restart left open. shell-open.test.ts already covers it.

bun test test/job-slices.test.ts passes, all 3 tests. I didn't run the rest of the suite; the forge runs the full check on the push.

The fix is pushed as 420e7b195.

Sign in to join this conversation.

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

Keyboard shortcuts

Docs