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

One Talk for game, web and iOS; the game door safe by design (write windows with a second factor, lock switch, servers by grant) #18280

opened this in answer to

Closed 4h 37m ago

This pull covers the write window, the lock, and the audit for the game door. The other issue items are not done, and one of them looks mostly done already. What changed Write window.

Notes

opened this

This pull covers the write window, the lock, and the audit for the game door. The other issue items are not done, and one of them looks mostly done already.

What changed

  • Write window. Game-door crew turns now run writes only inside a window the account opens on /games with a passkey: "Allow writes from Minecraft for N minutes", 60 by default, set between 5 and 480. Outside the window, or while locked, a write is held as the ordinary confirm. That is the same held action every door answers from. Before, such writes were refused outright (#18218).
  • Builds count as writes. !forge yes (building a new server) now needs an open window as well.
  • Lock. /forge lock in game (any linked name), a Lock button on /games, and K on the terminal's Games screen turn the door read-only at once and end the window. Only a passkey opens it again, and opening also lifts the lock. W on the terminal shows where the door stands.
  • Audit. Every write the door took, held or refused is kept in the new table game_door_write with the door, the Minecraft name and the window id. The last five show on /games.
  • Where it lives.
    • src/core/door_window.ts holds the window, lock and audit logic.
    • src/web/pages/games_door.ts holds the page block and the open and lock routes, under /games/@door/….
    • limitedOut in src/http/mcp/shared.ts now enforces the window.
    • Migration 20261204140000-door-window.
    • docs/features/games.md describes all of it.
  • Reused. The passkey challenge route (closeOptions) and button script from the account-close form, and askedFirst's confirm body, which is now one shared keepAsked.
  • Tests changed.
    • Three older tests (game-door, game-ask, conversation-door) expected a refusal, an open build, or the old help text. They now expect a hold, an open window for a build, and the new lock line in help.
    • New tests: write held outside the window, run inside it, held again after lock; the window ends by itself; builds refused outside the window and audited; !forge lock; web open and lock routes (forged or missing passkey opens nothing, cross-site post refused); and a held action answered from another door.
  • What I ran. tsc is clean and the gate passes. The game, conversation, boot-lazy and unused-export tests pass, except test/schema-migrations.test.ts, which also fails without my changes (a .claude directory in the sandbox temp path).

Not done

  • Single Talk engine. The game door already calls the same talk() and confirm path as the web, so I found no second chat engine to delete. src/games/chat.ts is the command parser (link, plan, yes, clear, lock) and the answer relay. Moving Talk out of the web page and wiring iOS to it is not done.
  • iOS. No iOS code is in this repo, so the passkey window and lock on iOS are not done. The held action lives on the existing confirm list, which an iOS app can already answer from.
  • Servers by grant. The proxy's server list, hub selector and whitelist are in the Java plugin and proxy, which I did not touch. /forge servers and /server already filter by grant (serversSeen).
  • Mojang and Floodgate identity. A link already binds the player's UUID, and a changed UUID drops it; a test for that exists. Mojang online-mode and Floodgate proofs are proxy-side and not done.
  • Auto-lock on leaving the network. Not done.
  • Security review. The fresh-context validator still has to run before merge.

Try: sign in on the preview and open /games. The "Minecraft writes" block shows closed, and Lock turns it to locked. In game, !forge lock does the same.

[
 {"go": "/games", "look": "the Minecraft writes block under the box list", "expect": "says Minecraft can read and changes are held; a minutes field, the passkey button (shown only with JavaScript and a passkey), and a Lock button"},
 {"go": "/games", "look": "press Lock: read-only now", "expect": "redirects back with the locked sentence, and the block's data-game-door is locked"},
 {"go": "/games", "look": "an account with no passkey", "expect": "the block says to add a passkey in Settings instead of showing the button"}
]

🤖 Generated with Claude Code

Closes #18247

Show 4 earlier items

7 earlier comments
commented

The both-doors check failed because src/web/pages/games_door.ts had no terminal door on record. The check's rule counts a page as having a door when a docs/features/*.md file names both the page and an existing src/tui/ file. The game-door write window and lock were already in the terminal (W for window state and K for lock, on the Games screen in src/tui/screens/games.ts). docs/features/games.md just never named the page.

I added one sentence to the Pages line of docs/features/games.md. It names games_door.ts and points to src/tui/screens/games.ts.

test/doorless.test.ts and test/feature-doors.test.ts pass (8 tests). The gate shows no failures, only an advisory similarity hint, and the fix is pushed as 411ea269e. I did not rerun the full suite or bun x tsc --noEmit this turn, and no code changed; the forge's check will run them.

commented

This push fixes two of the three red tests in the last check run. I couldn't run the third, the 1280 px /talk follow test, here because no Chromium starts in this sandbox. I did not push a change for it.

What was red and what changed

  • Account purge: game_door_window.user_id and game_door_write.user_id named a user but weren't in COVERED in src/core/account_purge.ts.
    • The window and lock row now goes with the person.
    • The audit row stays as shared history, rewritten to the former account like game_chat.
  • OpenAPI: the new POST /games/@door/options passkey challenge route had no row. I added src/contract/openapi/routes/postGamesDoorOptions.ts and regenerated the index.
  • Tests run: account-purge, openapi-covers-routes, openapi-coverage, openapi-routes and game-door-window pass (616 tests), and tsc is clean. The gate lists no failing rule. It still notes the windowMinutes / count similarity.

The 1280 px /talk test

  • Cause: I believe it is a flake rather than something this pull broke. The pull touches nothing on the /talk page.
  • Not done: I changed neither the test nor /talk. The final check run will show whether it fails again.

Each commit carries the issue number. The first says No door:, since it adds no page, action or tool.

What I chose not to do: the single Talk engine, servers by grant, and the iOS side are still not done. They stay as the earlier description says.

To try it: run bun test test/account-purge.test.ts test/openapi-covers-routes.test.ts test/game-door-window.test.ts.

🤖 Generated with Claude Code

commented

Still red on current main: choosing a template for a new forge > plan carries the template only when it is not blank. Fix it and push.

commented

Two of the three failures are fixed and pushed as 324c74c41. The third, the template test, passes for me but I couldn't find a cause.

Cause of the two openapi failures: I had described the game door's passkey challenge route, POST /games/@door/options, in the REST description. It is served at /games/…, not under /api/v1, so it shows up as described but not routed. It is the same kind of route as POST /settings/account/close/options.

Fix: in test/openapi-drift.test.ts I added it to the not-routed list and to the session-only list, next to the close form's route. Nothing in src/ changed.

Template test: "choosing a template for a new forge > plan carries the template only when it is not blank" passes when I run test/spawn-template-api.test.ts here. The check log shows it hitting a refused outside host (tpl--localhost:80), and that host was also refused in my sandbox. I'm treating it as a failure from that refused host rather than from this change, and I changed nothing for it. If it fails again on this push, it needs a look with its own log.

test/openapi-drift.test.ts and test/spawn-template-api.test.ts pass together (9 tests), and the gate showed no failures before the push. I did not rerun the full suite or bun x tsc --noEmit.

commented

Pushed as 5c1ec82c0. The gate passes with no failures. I ran tsc and the tests covering the change, not the full suite.

Changes, by review item

  1. Audit says "ran" too early.
    • limitedOut now only holds a write outside the window.
    • A new doorRan records "ran" at dispatch, after the asks-first and fence holds have passed.
    • In runJob the build is recorded "ran" only after commitServer succeeds. Failed plans are not audited.
    • A confirm that could not be kept (too many waiting, or too big) is recorded "refused", never "held".
    • Tests cover an asks-first tool inside an open window (not audited), the full-confirms case, and a build that fails in the window (not audited as ran).
  2. Shared passkey challenge. The door now has its own challenge store, tied to a purpose, and its own gameDoorOptions handler. A close challenge does not open the window, and a door challenge does not close an account; both are tested.
  3. What the window frees. I kept the window for reversible writes and did not narrow it to the games tool. The asks-first hold and the fence hold still run inside it. docs/features/games.md says so, and a test shows release_now held inside an open window. If you want only the games tool, that is a small change to limitedMay.
  4. Design.
    • The block states the door's state once, as a settings-block (the component named in docs/DESIGN.md).
    • The button reads "Allow writes" and the other button "Lock", with short flashes after each.
    • Rows show the player, the tool and the outcome in words ("ran", "held for your yes", "refused"). The door name and window id are gone from the page; the id stays in the audit table.
  5. Terminal. W opens a screen with the same rows as the page, through the shared writeSays. K still locks on one key, since locking only takes away. A test covers both.
  6. Tests.
    • The game-chat test no longer uses raw SQL or a swallowing try/catch.
    • viaPlayer is tested as empty-safe.
    • One existing conversation-door test now uses a conversation that has read nothing. The old one only passed because "ran" was written for a call the fence had held.
  7. Duplicate parsing. wholeNumber in src/core/whole_number.ts is the one bounded-integer parser, used by windowMinutes and start_refusal.ts.
  8. Scope. Opened #18310 to #18314: the single Talk engine, iOS, servers by grant, Mojang/Floodgate identity, and auto-lock. Each is linked to #18247 in its body.

Not changed: the gate hint that gameDoorOptions is 0.92 similar to closeOptions stays. The two are near copies that differ only in purpose, and I left them separate.

To try: open /games signed in. "Allow writes" needs a passkey, and Lock turns the block to locked. In the terminal's Games screen, W lists the last writes and K locks.

[{"go":"/games","look":"The Minecraft writes block: one sentence of state, an Allow writes button (with a passkey), a Lock button, and recent writes as rows","expect":"Rows read 'player · tool' with 'ran', 'held for your yes' or 'refused'; no window id and no door name"}]
commented

I fixed the failing check and pushed the fix to this branch.

test/conversation-door.test.ts imported ../src/core/fence.ts twice, on lines 15 and 16. That broke the duplicate-import rule. I merged the two into import { HELD_MAX, waitingFor } from "../src/core/fence.ts".

I ran test/conversation-door.test.ts and test/dup-imports.test.ts together. All 17 tests passed. I did not run bun x tsc --noEmit, scripts/gate.ts or the full suite. The forge will run the full check on this push.

This changes only a test file's imports, so behaviour is unchanged and there is nothing to try in the app.

🤖 Generated with Claude Code

commented

I merged main and pushed. Because main already carries a game door that does the same job, I dropped this branch's own door, so the branch's content is now identical to main. The pull therefore adds nothing to review. tsc, the gate and the touched suites (65 tests) pass, but I did not run the full suite.

The conflict. Pull #18304 landed the write window, the lock and the audit for issue #18296, which was split from this issue. Its door is per box, with the passkey proof in src/actions/passkey_proof.ts and the held build in src/games/door_hold.ts. This branch had built the same thing a second way, as a per-account window in src/core/door_window.ts. Keeping both would have meant two windows and two locks.

What I dropped. I took main's version of every file the two designs touched. I also deleted this branch's door_window module, its migration and pin, its postGamesDoorOptions OpenAPI route and test/game-door-window.test.ts.

What I tried and backed out. I ported this branch's other piece onto main's per-box window. That piece held a game conversation's other writes for the player's yes instead of refusing them. It broke test/game-door.test.ts ("any other write is refused, never run"). That test came from #18218 and passes on main, and I had no reason to call it wrong. I backed the change out rather than edit the test.

Still open from #18247.

  • Held actions for a game turn's non-games writes. main refuses them. A person has to choose between the two behaviours.
  • One Talk for game, web and iOS.
  • Removing the game door's own chat path in src/games/chat.ts.
  • Letting /forge lock work from a name with no role on the box, which was part of this branch's door.

Someone should decide whether the held-write change goes in as a follow-up that deliberately amends that test.

To try it, use the preview of #18280. The door is on /games/<box>.

🤖 Generated with Claude Code

commented

Closed by the crew: superseded, its change is already on main in 12350630.

Sign in to join this conversation.

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

Keyboard shortcuts

Docs