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

Game door: a read-only switch and a one-hour write window the owner opens with a second factor #18304

opened this

Merged 4h 11m ago, live in production

Game builds asked from inside Minecraft now run only while the box's owner has a write window open. The owner opens one on /games/ with a passkey, and it lasts an hour unless they change the setting. Outside a window, a build asked in game is held for the player's approval on the forge instead of running.

Notes

opened this

Game builds asked from inside Minecraft now run only while the box's owner has a write window open. The owner opens one on /games/<box> with a passkey, and it lasts an hour unless they change the setting. Outside a window, a build asked in game is held for the player's approval on the forge instead of running. A lock switch makes the door read-only at once. tsc, the gate (0 fail), design-lint and the game, passkey, account-close, schema and door test files I picked all pass locally.

What changed

  • src/games/write_window.ts (new): the door's state (game_door table, one row per box) is open, closed or locked. Here are its rules:
    • Opening a window lifts a lock.
    • Locking ends any open window straight away.
    • A window simply stops counting once its end time passes; nothing has to clean it up.
    • The length is 5 to 720 minutes (an hour by default), shown with a one-line reason beside it.
  • src/games/door_hold.ts (new): when the window is closed, /forge yes or !forge yes no longer runs the build. It is held as a games create_server confirm through the existing held-action step (core/fence.ts hold), in the player's game conversation (game_talk, kept to reads plus the held games tool). The player answers it on the forge in Talk or Settings → Confirms; that runs the tool with all its own checks, once, within 10 minutes.
  • src/games/chat.ts (a few calls only):
    • The door is checked at the yes and again right before the commit, so a lock while the plan is being made still stops it.
    • New /forge lock command, for an operator of the server. It needs no code through the proxy, because all it can do is stop writes.
    • Every command row in game_chat now records the door and the player, and a build or lock also records the window it used (new write_window column: when that window opened, or closed / locked). The owner's command list on the page shows this.
  • Web: src/web/pages/games_door.ts (new) adds the owner's Game door block on /games/<box>, with Lock now, Allow writes from the game for N minutes (passkey) and the window length. It has two routes, POST /games/:box/door and /door/options, both owner-only and same-origin.
  • Terminal: the box screen in src/tui/screens/games.ts shows the door and locks it with w. A window can only be opened on the web, because it needs a passkey.
  • Reused: the account-close passkey code (challenge store, PROOF_FIELDS, passkeyProves) moved unchanged to src/actions/passkey_proof.ts, and closing an account and opening a window both use it. The browser side is one shared prove function, wired to both buttons. Grants still come from roleOn / mayDo; there is no new grant table.
  • account_purge now covers game_door.opened_by and locked_by: when that person's account is deleted, these name the former member.
  • docs/features/games.md has a new "The write window" section and /forge lock.

Tests

  • New test/game-write-window.test.ts:
    • a build outside the window is held, not run, and its audit row says closed;
    • the held confirm builds once when the player says yes, and a second yes does nothing;
    • inside a window the build runs and its audit row names the window;
    • /forge lock ends the window and refuses builds;
    • a lock between the yes and the commit stops the commit;
    • a window expires on its own;
    • the length is limited to 5–720 minutes;
    • on the page, Lock now works, a cross-origin post is refused, and an empty or forged passkey answer opens nothing.
  • test/game-chat.test.ts and test/game-door.test.ts now open a window in their setup. Those tests weren't wrong: the issue changes the default, and their builds now need a window.

Threat note

  • Words typed in game can come from a line any server shows a player. So a game write now needs a window opened with the owner's passkey, which a game session cannot provide.
  • The worst a game player can do outside a window is put a held confirm in their own account's queue, which they then have to approve on the forge with their own session. Writes are tied to the forge account, never to the Minecraft name.
  • Locking is open to any operator of a server and needs no confirmation, because all it can do is stop writes; only the owner can reopen.
  • Talk turns from the game were already limited to reads plus the held games tool (#18218), so they stay ungated.
  • Linking a name is not gated, so players can still link. It gives no role.

Not done: an iOS toggle, locking automatically when someone leaves the network, a lock through MCP, and the parent issue's server visibility by grant and identity parts. Those are the other parts of #18247. The keep_plan and estimate tools weren't available in this run, so the issue has no plan or estimate. I found no prompt-injection text in the repository or the issue.

Try it: on the preview, open /games/<box> as its owner and press Lock now, then Allow writes from the game with a passkey. In game, plan a server and /forge yes with the window closed: it answers "Held: …" with a link to Talk.

[
  {"go": "/games/<box>", "look": "the Game door block (owner only)", "expect": "says Closed with a 60-minute window, Lock now, Allow writes from the game for 60 minutes (needs a passkey), the length field and the reason beside it"},
  {"go": "/games/<box>", "look": "press Lock now", "expect": "a notice says Locked; the block now says Locked by <you> and Lock now is gone"},
  {"go": "/games/<box>", "look": "press Allow writes from the game and answer with a passkey", "expect": "the block says Open for writes for 60 more minutes", "ask": "Is it clear that the game door only reads while it is locked or closed?"},
  {"go": "terminal: Games, then b on a box", "look": "the Game door line, then press w", "expect": "the line turns to Locked by <you>"}
]

🤖 Generated with Claude Code

Closes #18296

7 earlier comments
commented

Game builds asked from inside Minecraft now run only while the box's owner has a write window open. The owner opens one on /games/<box> with a passkey, and it lasts an hour unless they change the setting. Outside a window, a build asked in game is held for the player's approval on the forge instead of running. A lock switch makes the door read-only at once. tsc, the gate (0 fail), design-lint and the game, passkey, account-close, schema and door test files I picked all pass locally.

What changed

  • src/games/write_window.ts (new): the door's state (game_door table, one row per box) is open, closed or locked. Here are its rules:
    • Opening a window lifts a lock.
    • Locking ends any open window straight away.
    • A window simply stops counting once its end time passes; nothing has to clean it up.
    • The length is 5 to 720 minutes (an hour by default), shown with a one-line reason beside it.
  • src/games/door_hold.ts (new): when the window is closed, /forge yes or !forge yes no longer runs the build. It is held as a games create_server confirm through the existing held-action step (core/fence.ts hold), in the player's game conversation (game_talk, kept to reads plus the held games tool). The player answers it on the forge in Talk or Settings → Confirms; that runs the tool with all its own checks, once, within 10 minutes.
  • src/games/chat.ts (a few calls only):
    • The door is checked at the yes and again right before the commit, so a lock while the plan is being made still stops it.
    • New /forge lock command, for an operator of the server. It needs no code through the proxy, because all it can do is stop writes.
    • Every command row in game_chat now records the door and the player, and a build or lock also records the window it used (new write_window column: when that window opened, or closed / locked). The owner's command list on the page shows this.
  • Web: src/web/pages/games_door.ts (new) adds the owner's Game door block on /games/<box>, with Lock now, Allow writes from the game for N minutes (passkey) and the window length. It has two routes, POST /games/:box/door and /door/options, both owner-only and same-origin.
  • Terminal: the box screen in src/tui/screens/games.ts shows the door and locks it with w. A window can only be opened on the web, because it needs a passkey.
  • Reused: the account-close passkey code (challenge store, PROOF_FIELDS, passkeyProves) moved unchanged to src/actions/passkey_proof.ts, and closing an account and opening a window both use it. The browser side is one shared prove function, wired to both buttons. Grants still come from roleOn / mayDo; there is no new grant table.
  • account_purge now covers game_door.opened_by and locked_by: when that person's account is deleted, these name the former member.
  • docs/features/games.md has a new "The write window" section and /forge lock.

Tests

  • New test/game-write-window.test.ts:
    • a build outside the window is held, not run, and its audit row says closed;
    • the held confirm builds once when the player says yes, and a second yes does nothing;
    • inside a window the build runs and its audit row names the window;
    • /forge lock ends the window and refuses builds;
    • a lock between the yes and the commit stops the commit;
    • a window expires on its own;
    • the length is limited to 5–720 minutes;
    • on the page, Lock now works, a cross-origin post is refused, and an empty or forged passkey answer opens nothing.
  • test/game-chat.test.ts and test/game-door.test.ts now open a window in their setup. Those tests weren't wrong: the issue changes the default, and their builds now need a window.

Threat note

  • Words typed in game can come from a line any server shows a player. So a game write now needs a window opened with the owner's passkey, which a game session cannot provide.
  • The worst a game player can do outside a window is put a held confirm in their own account's queue, which they then have to approve on the forge with their own session. Writes are tied to the forge account, never to the Minecraft name.
  • Locking is open to any operator of a server and needs no confirmation, because all it can do is stop writes; only the owner can reopen.
  • Talk turns from the game were already limited to reads plus the held games tool (#18218), so they stay ungated.
  • Linking a name is not gated, so players can still link. It gives no role.

Not done: an iOS toggle, locking automatically when someone leaves the network, a lock through MCP, and the parent issue's server visibility by grant and identity parts. Those are the other parts of #18247. The keep_plan and estimate tools weren't available in this run, so the issue has no plan or estimate. I found no prompt-injection text in the repository or the issue.

Try it: on the preview, open /games/<box> as its owner and press Lock now, then Allow writes from the game with a passkey. In game, plan a server and /forge yes with the window closed: it answers "Held: …" with a link to Talk.

[
  {"go": "/games/<box>", "look": "the Game door block (owner only)", "expect": "says Closed with a 60-minute window, Lock now, Allow writes from the game for 60 minutes (needs a passkey), the length field and the reason beside it"},
  {"go": "/games/<box>", "look": "press Lock now", "expect": "a notice says Locked; the block now says Locked by <you> and Lock now is gone"},
  {"go": "/games/<box>", "look": "press Allow writes from the game and answer with a passkey", "expect": "the block says Open for writes for 60 more minutes", "ask": "Is it clear that the game door only reads while it is locked or closed?"},
  {"go": "terminal: Games, then b on a box", "look": "the Game door line, then press w", "expect": "the line turns to Locked by <you>"}
]

🤖 Generated with Claude Code

commented

<!-- look-pages 876dd19a8be2 --> Look pages for 876dd19, from the gate:

  • look pages (none): "Looks: /games" is not a page of app.looks in forge.json; this pull changes src/web/pages/account.ts, src/web/pages/games.ts, src/web/pages/games_door.ts and 1 more but the forge could not trace the route of /, /admin/telemetry, /explore and 29 more (an inline or wrapped handler), so it could not infer a page; the reviewer decides. A "Looks: <path>" line naming the nearest page, or a "No look: <why>" line (10+ characters), says it
commented

Game door (#18296): a box's game door starts out read-only, and its owner can open a time-limited write window, confirmed with a passkey, or lock it again.

  • Write window: src/games/write_window.ts holds the door's state: locked, closed, or open until a set time. A window past its end counts as closed, so nothing has to sweep it. The owner sets the length, from 5 to 720 minutes.
  • Page side: the box page has a door section from src/web/pages/games_door.ts, with Lock, Open (needs a passkey) and a length setting. POST /games/:box/door/options issues the passkey challenge. The passkey check is now shared with account close through src/actions/passkey_proof.ts.
  • In game: !forge lock locks the door from the game. A !forge yes while the door is locked is refused. While it is closed, the build is held as a Talk confirm the player answers on the forge (src/games/door_hold.ts). The window is checked again right before the commit, and each audit row records which window the write used.
  • Terminal and docs: the terminal's games screen shows the door, and docs/features/games.md covers it.
  • Data: a migration adds the game_door table and game_chat.write_window. Deleting an account turns opened_by and locked_by into the former member.

This push fixes the failed check:

  • OpenAPI: the contract had no row for POST /games/{box}/door/options. It now has one, src/contract/openapi/routes/postGamesBoxDoorOptions.ts, and the index is regenerated.
  • Merge: the branch has latest main merged in.
  • N+1 test: "a pull's crew activity does not cost more as its agent runs grow" failed because the smaller case counted 2 more database statements than the larger one (107 vs 105). The test keeps the smallest count over only 2 runs, so other work in a busy check machine can land in both. This pull adds nothing to the pull page or to background work. The test passes 3 times out of 3 locally after the merge, so I left it unchanged.

What I left alone: the gate suggests merging openWindow/lockDoor and gameDoorOptions/closeOptions. They are similar but do different things, so they stay separate.

Checked: bun x tsc --noEmit and bun scripts/gate.ts pass, and test/surfaces-adversarial.test.ts, test/openapi-covers-routes.test.ts and test/openapi-routes.test.ts pass after the merge.

[
  {"go": "/games/<box>", "look": "the door section", "expect": "it shows the door as locked or closed, with Open (passkey), Lock and a minutes field", "ask": "Does the window's length and end read clearly?"},
  {"go": "/games/<box>", "look": "press Open and answer the passkey prompt", "expect": "a notice says the window is open until a time, and the section shows it open"},
  {"go": "/games/<box>", "look": "press Lock", "expect": "a notice says 'Locked: the game door only reads now.'"}
]

🤖 Generated with Claude Code

commented

<!-- look-pages 1a8ec3f6e5b8 --> Look pages for 1a8ec3f, from the gate:

  • look pages (none): "Looks: /games" is not a page of app.looks in forge.json; this pull changes src/web/pages/account.ts, src/web/pages/games.ts, src/web/pages/games_door.ts and 1 more but the forge could not trace the route of /, /admin/telemetry, /explore and 29 more (an inline or wrapped handler), so it could not infer a page; the reviewer decides. A "Looks: <path>" line naming the nearest page, or a "No look: <why>" line (10+ characters), says it
commented

The game door now has a read-only switch and a write window the owner opens with a passkey. The window lasts an hour by default, and the owner can lock it again early.

  • Owner's door: src/games/write_window.ts keeps the window and the lock, and src/games/door_hold.ts refuses writes to the box's chat while the door is shut. The page side is src/web/pages/games_door.ts, the terminal side is src/tui/screens/games.ts, and the how-to is docs/features/games.md.
  • Passkey check: POST /games/{box}/door/options gives the owner a one-use passkey challenge. The code that checks the passkey answer moved out of src/actions/account_close.ts into src/actions/passkey_proof.ts, so closing an account and opening a door use the same check.
  • OpenAPI contract: the description of this route follows POST /settings/account/close/options. It is listed in test/openapi-drift.test.ts as routed outside /api/v1 and as browser-session only (no API token). Its summary is now under the 90-character limit. These three checks were the ones that failed on the last push.
  • Database and account deletion: migration 20261204212305-game-door-window adds the window. When an account is deleted, whoever opened or locked a game door is shown as the former member.

The other two failures on the last push were "the terminal's variants screen" and "strangers at every door > event streams". They touch nothing this branch changes, and both passed in three local runs. I treated them as flaky under load and left them alone.

Before this push the OpenAPI tests and the type check passed, and the gate run before pushing reported no failures. The gate's --fix step also suggested that openWindow and lockDoor look alike, and that gameDoorOptions looks like the account-close closeOptions; I left both pairs separate.

To try it: as the box's owner, open /games/{box}, open the door with a passkey, post in the chat, then lock the door. A further post should be refused.

[
  {"go": "/games/{box}", "look": "the game door section", "expect": "the owner sees whether the door is shut or open and a button to open it with a passkey; anyone else sees only whether it is shut or open"},
  {"go": "/games/{box}", "look": "after opening the door with a passkey", "expect": "the door reads open until a stated time, and a lock button shuts it early"},
  {"go": "/api/v1/openapi.json", "look": "POST /games/{box}/door/options", "expect": "a one-line summary and no token requirement (browser session only)"}
]

🤖 Generated with Claude Code

commented

<!-- look-pages 9e8b26c54569 --> Look pages for 9e8b26c, from the gate:

  • look pages (none): "Looks: /games" is not a page of app.looks in forge.json; this pull changes src/web/pages/account.ts, src/web/pages/games.ts, src/web/pages/games_door.ts and 1 more but the forge could not trace the route of /, /admin/telemetry, /explore and 29 more (an inline or wrapped handler), so it could not infer a page; the reviewer decides. A "Looks: <path>" line naming the nearest page, or a "No look: <why>" line (10+ characters), says it
commented

The owner of a game box can now open its game door for an hour of writes with a passkey, and lock it again early. While the door is shut, the box's chat refuses writes.

  • The door: src/games/write_window.ts keeps the open window and the lock, and src/games/door_hold.ts refuses chat writes while the door is shut. The page side is src/web/pages/games_door.ts and the terminal side is src/tui/screens/games.ts. The how-to is docs/features/games.md.
  • Passkey proof: POST /games/{box}/door/options gives the owner a one-use passkey challenge. The passkey check moved out of src/actions/account_close.ts into src/actions/passkey_proof.ts, so closing an account and opening a door use the same check.
  • OpenAPI contract: the route is described the same way as POST /settings/account/close/options. test/openapi-drift.test.ts lists it as routed outside /api/v1 and as browser-session only, and its summary is under 90 characters.
  • Data: migration 20261204212305-game-door-window stores the window. When an account is deleted, whoever opened or locked a door becomes the former member.

There is no look page, and the latest commit has a No look: line saying why. The door section shows only on /games/{box}, and only to the box's owner. The look sampler sets up no game box, and /games is not in app.looks. test/game-write-window.test.ts checks the page's wording instead.

The game tests, the OpenAPI tests, test/unused-exports.test.ts and test/job-slices.test.ts pass on this branch, and so does the type check. The gate run before this push printed nothing about looks or failures.

On the earlier push, "the terminal's variants screen" and "strangers at every door > event streams" also failed in shard 2. This branch changes nothing they test, and both passed three times in a row here, so I treated them as flaky under load.

To try it: as the box's owner, open /games/{box}, open the door with a passkey, post in the chat, then lock the door. Another post should be refused.

[
  {"go": "/games/{box}", "look": "the game door section, signed in as the box's owner", "expect": "the door's state and a button to open it with a passkey; other visitors see only whether it is shut or open"},
  {"go": "/games/{box}", "look": "after opening the door", "expect": "open until a stated time, with a lock button that shuts it early"},
  {"go": "/api/v1/openapi.json", "look": "POST /games/{box}/door/options", "expect": "a one-line summary and no token requirement"}
]

🤖 Generated with Claude Code

commented

The game door lets a box's owner open a write window, one hour unless they set another length, using a passkey (a password does not open it). Outside the window, a build asked from the game is held for a yes on the forge instead of running. A lock ends the window at once, and builds are refused until the owner opens one again.

Review follow-ups in this push

  • Who may /forge lock: it now needs an operator of the whole box, the same check a yes uses, and anyone else is refused. On one point I disagree with the review: a viewer was already refused before this change, by the operator check at src/games/chat.ts:454. The real gap was an operator of a single server, who could shut the whole box's door. The new test in test/game-write-window.test.ts covers both a viewer and an operator of one server only. It fails without the fix and passes with it, and in both cases the owner's window stays open.
  • The passkey button: it is now btn(...) with the secondary variant, wrapped in the existing data-passkey="on" span, so the page has a single primary button. bun scripts/design-lint.ts passes.
  • Docs: docs/features/games.md now says the lock needs an operator of the box.
  • No look page: the door section shows only on /games/{box} and only to the box's owner. The look sampler sets up no game box, and /games is not in app.looks. The earlier commit says so in a No look: line.

The rest of the change

  • Window and hold: src/games/write_window.ts keeps the window and the lock. src/games/door_hold.ts holds a build asked outside the window and refuses it while the door is locked.
  • Page and terminal: the page block is src/web/pages/games_door.ts. On the terminal, w on the box screen locks the door.
  • Passkey check: the passkey check moved from src/actions/account_close.ts into src/actions/passkey_proof.ts, so closing an account and opening the door share it.
  • Contract: POST /games/{box}/door/options is in the OpenAPI description as routed outside /api/v1 and as browser-session only.
  • Data: migration 20261204212305-game-door-window adds the window. When an account is deleted, whoever opened or locked a door becomes the former member.

Before this push the game tests (62 pass), the design lint and the type check passed, and the gate reported nothing to fix.

To try it: as the box's owner, open /games/{box}, open the door with a passkey, then lock it from the game as a linked viewer. The viewer is refused and the window stays open.

[
  {"go": "/games/{box}", "look": "the Game door block, signed in as the box's owner with a passkey", "expect": "Lock now and the passkey button are both secondary; the page keeps one primary accent"},
  {"go": "/games/{box}", "look": "after a viewer types /forge lock in game", "expect": "the door still reads open until its stated time"},
  {"go": "/api/v1/openapi.json", "look": "POST /games/{box}/door/options", "expect": "a one-line summary and no token requirement"}
]

🤖 Generated with Claude Code

Sign in to join this conversation.

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

Keyboard shortcuts

Docs