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

A machine stays trustworthy under load: power cycle, live status, a memory check, a patient healer #18472

opened this

Merged 3h 1m ago, live in production

A game box's page now shows live state, and its owner can plan and confirm a power cycle of its machine. The memory check and the healer's patience were already on main, so I added only tests for new code. tsc, design-lint, gate.ts and the tests I ran for this change pass.

Notes

opened this

A game box's page now shows live state, and its owner can plan and confirm a power cycle of its machine. The memory check and the healer's patience were already on main, so I added only tests for new code. tsc, design-lint, gate.ts and the tests I ran for this change pass. I did not run the whole suite, the check's unix-socket suites, or any look or review step, and did not try the app in a browser.

Live state. /games/<box> opens with checked in 4 s ago · load 58.0 · memory 7.7 of 8.0 GiB used, with a "silent" mark after a minute without a check-in. Under it, one line per container the viewer may see: starting · its log moved 12 s ago, starting · its log has been still for 5 min, ready, stopped, asleep. A new stream, GET /games/<box>/@live, rewrites those lines after each check-in (about 20 lines of JS). The terminal's box screen (b) opens with the same lines. The words live in src/games/live.ts.

Power cycle. Only the owner of the whole box can do it. The page plans it first at ?cycle=1; the terminal does the same with P on the box screen. The plan says what is lost (everything in memory, servers stop unsaved) and what is kept (disks, address). Confirming brings the plan's digest back to POST /games/<box>/@cycle. The server refuses a plan that is old (10 minutes), altered, or from a non-owner, and refuses a read-only cloud account. It also refuses a second cycle within 5 minutes. Each attempt, refused or done, writes a cloud audit row and a game.cycle event, which only the person who cycled can read. The cloud calls are Hetzner reset, DigitalOcean power_cycle and OVHcloud hard reboot, in the new cycleMachine on Driver. Egress is unchanged, since they use the same API hosts. The logic is in src/games/cycle.ts.

Already on main, not redone.

  • Memory check: box_memory.ts refuses a start or a mod add with no room, with the numbers.
  • Healer: heal.ts slowStart waits while a starting container's log moves, up to 10 minutes after it came up, and restarts only when it stalls.

Left out.

  • MCP tool: there is none for the power cycle.
  • Cycle button: it is "primary", not "danger", because the plan page is the confirmation the danger-button test wants.
  • spanWords: it duplicates maintain/schedule.ts span on purpose; the check-in age needs seconds, which span lacks.
  • Minecraft kind: the spark-on-survival item stays there, as the issue says.

Both-doors rule: I used a No door: commit line, since the doors are the existing games screen and a new section of docs/features/game-box.md.

The new tests are in test/game-machine.test.ts: the three driver calls, the live words, the owner-only plan, refusals, a cycle that reaches the cloud once with its audit row, the 5-minute wait, the read-only account, and the page, stream and confirm route gating.

Try: open /games/<box> as the box's owner. The live line is at the top, and "Plan a power cycle" sits under Console.

[
  {"go": "/games/<box>", "look": "the top of the page", "expect": "one line with check-in age, load and memory, then one line per container with its progress"},
  {"go": "/games/<box>?cycle=1", "look": "the Machine block", "expect": "Will, Lost and Kept lines and a Power cycle now button; an operator sees neither the block nor the button", "ask": "Is the plan plain enough to confirm under pressure?"}
]

🤖 Generated with Claude Code

Closes #18465

5 earlier comments
commented

A game box's page now shows live state, and its owner can plan and confirm a power cycle of its machine. The memory check and the healer's patience were already on main, so I added only tests for new code. tsc, design-lint, gate.ts and the tests I ran for this change pass. I did not run the whole suite, the check's unix-socket suites, or any look or review step, and did not try the app in a browser.

Live state. /games/<box> opens with checked in 4 s ago · load 58.0 · memory 7.7 of 8.0 GiB used, with a "silent" mark after a minute without a check-in. Under it, one line per container the viewer may see: starting · its log moved 12 s ago, starting · its log has been still for 5 min, ready, stopped, asleep. A new stream, GET /games/<box>/@live, rewrites those lines after each check-in (about 20 lines of JS). The terminal's box screen (b) opens with the same lines. The words live in src/games/live.ts.

Power cycle. Only the owner of the whole box can do it. The page plans it first at ?cycle=1; the terminal does the same with P on the box screen. The plan says what is lost (everything in memory, servers stop unsaved) and what is kept (disks, address). Confirming brings the plan's digest back to POST /games/<box>/@cycle. The server refuses a plan that is old (10 minutes), altered, or from a non-owner, and refuses a read-only cloud account. It also refuses a second cycle within 5 minutes. Each attempt, refused or done, writes a cloud audit row and a game.cycle event, which only the person who cycled can read. The cloud calls are Hetzner reset, DigitalOcean power_cycle and OVHcloud hard reboot, in the new cycleMachine on Driver. Egress is unchanged, since they use the same API hosts. The logic is in src/games/cycle.ts.

Already on main, not redone.

  • Memory check: box_memory.ts refuses a start or a mod add with no room, with the numbers.
  • Healer: heal.ts slowStart waits while a starting container's log moves, up to 10 minutes after it came up, and restarts only when it stalls.

Left out.

  • MCP tool: there is none for the power cycle.
  • Cycle button: it is "primary", not "danger", because the plan page is the confirmation the danger-button test wants.
  • spanWords: it duplicates maintain/schedule.ts span on purpose; the check-in age needs seconds, which span lacks.
  • Minecraft kind: the spark-on-survival item stays there, as the issue says.

Both-doors rule: I used a No door: commit line, since the doors are the existing games screen and a new section of docs/features/game-box.md.

The new tests are in test/game-machine.test.ts: the three driver calls, the live words, the owner-only plan, refusals, a cycle that reaches the cloud once with its audit row, the 5-minute wait, the read-only account, and the page, stream and confirm route gating.

Try: open /games/<box> as the box's owner. The live line is at the top, and "Plan a power cycle" sits under Console.

[
  {"go": "/games/<box>", "look": "the top of the page", "expect": "one line with check-in age, load and memory, then one line per container with its progress"},
  {"go": "/games/<box>?cycle=1", "look": "the Machine block", "expect": "Will, Lost and Kept lines and a Power cycle now button; an operator sees neither the block nor the button", "ask": "Is the plan plain enough to confirm under pressure?"}
]

🤖 Generated with Claude Code

commented

<!-- look-pages 8bd35de88c7c --> Look pages for 8bd35de, from the gate:

  • look pages (none): this pull changes src/web/games_machine.ts, src/web/pages/games.ts but the forge could not trace the route of /, /admin/telemetry, /explore and 28 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 check failed because three route lists didn't know the new GET /games/:box/@live stream. I added it to each list and pushed the fix as ce3dc4acf.

  • test/no-polling.test.ts: I added the route to NOT_WALKED with its reason.
  • test/security-floor-routes.test.ts: I added the same entry to UNSEEDED. I changed this list pre-emptively; the check log didn't name it, but it carries the same entry for the sibling @shell/stream route.
  • test/budgets/unfixtured/games-box-live.json: this is a new file, modelled on the @shell/stream one, so the page-budget test knows the seed can't fill the route.

No application code changed, and the tests only list the route; test/game-machine.test.ts covers the stream's behaviour.

test/no-polling.test.ts, test/pages-budget.test.ts and test/security-floor-routes.test.ts pass locally. The rest of the suite was not rerun here.

🤖 Generated with Claude Code

commented

I've answered the look-pages note with a No look: commit line, pushed as 7843319a3. The gate now reports no look finding. The first commit's Looks: games line was not a page of app.looks, so the gate couldn't use it.

I used No look: because none of the app.looks pages in forge.json shows a game box. A game box needs a box the seed doesn't make. test/game-machine.test.ts checks the page's words instead.

I made no code change. I didn't re-run the four tests you listed, which passed earlier on this branch. This push touches no source.

The review block from my earlier description still applies:

[
  {"go": "/games/<box>", "look": "the top of the page", "expect": "one line with check-in age, load and memory, then one line per container with its progress"},
  {"go": "/games/<box>?cycle=1", "look": "the Machine block", "expect": "Will, Lost and Kept lines and a Power cycle now button; an operator sees neither the block nor the button", "ask": "Is the plan plain enough to confirm under pressure?"}
]

🤖 Generated with Claude Code

commented

This push fixes the ceiling check, the one failure that was this pull's own. The tools/list size failure is a different matter, covered below.

What changed: src/games/cycle.ts took its cloud driver bare, with driverOf(row.target). test/pinned-ceiling.test.ts requires every cloud driver to go through capped, the account-ceiling wrapper. The driver is now wrapped as capped(app, row.name, driverOf(row.target)). cycleMachine is unaffected, and a power cycle makes no machine, so it never trips the ceiling's admit check. The test counts approved driver uses, and I raised that count from 18 to 19 to match.

Checks run: test/pinned-ceiling.test.ts and test/game-machine.test.ts pass, 25 tests. tsc --noEmit is clean. The gate's --fix found nothing to rewrap; it printed two "one implementation?" notes about duplicate test helpers (asked, mk), which I left alone.

Left alone: the tools/list size test (test/mcp-size.test.ts) fails because plan.issues.owner has a 91-byte description. The check log shows the same failure on main at 9745f39, so I did not touch it. I didn't re-run that test or grep for plan.issues.owner in this session, so I haven't confirmed the field isn't something this pull added.

To try: bun test test/pinned-ceiling.test.ts test/game-machine.test.ts.

commented

I've pushed fixes for all four of @sentinel's findings to the same branch.

  1. Replay: a plan can now be used once. performCycle refuses a digest whose stamp is not newer than the machine's last successful cycle, with "That plan was already used". A replay at 5:01 no longer cycles a machine that just came up.
  2. Failed cloud call: if the cloud call fails, the code writes a cycle:failed audit row after the attempt row. lastCycle ignores an attempt that a later failed row follows, so the owner can retry straight away. The attempt is still audited before the call.
  3. Silent claim: the live head line now ends with · silent when the box has not checked in. The doc and the liveHead comment say so.
  4. Page design: the Will, Lost and Kept lines are now dl.status-rows rows. I removed the idle explanatory sentence beside the "Plan a power cycle" button.

Tests: I added one test for single-use plans and one for the retry after a failed call. test/game-machine.test.ts passes 10 of 10, three runs in a row. I also fixed an existing flake in it. It swapped the digest's last character for "0", which left the digest unchanged one time in sixteen.

I ran the dup-imports, module-state, page-budget and unused-exports suites, which pass. I ran tsc and design-lint, which are clean. test/pinned-ceiling.test.ts passes.

Disagreement: I did not touch test/mcp-size.test.ts. That tools/list size failure is also red on main, and I did not confirm it is unrelated to this pull.

Sign in to join this conversation.

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

Keyboard shortcuts

Docs