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

A game box agent that does not check in after its update goes back to the one before #18023

opened this in answer to

Closed 10h 26m ago

A game box's new agent is now on trial until the forge answers one of its syncs, and if it never does, the box goes back to the previous agent (#18019). The ubuntu:24.04 run, which the issue asks for, was not done: this sandbox has no docker.

Notes

opened this

A game box's new agent is now on trial until the forge answers one of its syncs, and if it never does, the box goes back to the previous agent (#18019). The ubuntu:24.04 run, which the issue asks for, was not done: this sandbox has no docker.

The agent-script tests (test/game-agent-rollback.test.ts and the existing update test) pass as plain bash, and the gate and tsc are clean. I did not run the full suite. The unused-exports and module-state checks I ran pass. I never ran the FORGE_TEST_UBUNTU=1 docker path. It installs curl and jq inside the container, so it needs network access.

What changed

  • Keeping the old script: self_update copies the running script to agent.sh.prev before replacing it. It writes .agent.trial with the start time, the new sha and the old sha.
  • Trial guard: a guard at the very top of agent.sh replaces the new agent with the previous one in two cases:
    • Repeated starts: it has started more than FORGE_GAME_TRIAL_STARTS times (default 5) without an answered sync.
    • Too slow: it has run FORGE_GAME_TRIAL_S seconds (default 600) without one. The main loop checks this too, for an agent that runs but never syncs.
  • Proving the new agent: a 2xx sync answer ends the trial and clears the markers.
  • What the rolled-back agent does:
    • Saying so: it keeps .agent.back and sends agentBack: {sha, why} on every sync.
    • No retry: it never fetches that sha again, so a mismatch with the forge's sha cannot loop. A different agent shipping ends it.
    • Evidence kept: the failed script is kept as agent.sh.refused.
  • What the forge shows:
    • Storage: the sync is validated (a 64-hex sha, plain text under 200 characters) and stored in two new game_box columns, with a migration and its pin. The forge clears them when the box stops sending agentBack.
    • Display: the Games list row shows an "Agent" fact, and the box's terminal screen leads with "On its previous agent: the new one (…) was put back: …". Both come from agentBackLine.
    • Docs: the how-to is in docs/features/games.md, and the sync route description in OpenAPI mentions agentBack.
  • Tests: they cover keeping the previous script, the repeated-exit rollback, the timeout rollback, the sync saying why without refetching, and the forge's storing and clearing of agentBack.

What I left out

  • The guard is the new agent's own code. A new agent that dies before the guard runs is not caught. Closing that would need a systemd-side check.
  • A box that cannot reach the forge for the whole ten minutes is rolled back too, and stays on the old agent until a different sha ships. I did not add a later retry.
  • I did not extract a shared test helper. The gate notes the box and run helpers look like the ones in game-agent-update.test.ts.

To try it

  • Run bun test test/game-agent-rollback.test.ts.
  • Run it in ubuntu:24.04 with FORGE_TEST_UBUNTU=1 bun test test/game-agent-rollback.test.ts.
  • On a preview, open /games for a box whose agent was put back.

Commit lines carry Try:, Looks:/No look: and No door:. The box's terminal screen and the how-to already carry the change, and agent_back.ts is the shared helper.

🤖 Generated with Claude Code

Closes #18019

4 earlier comments
commented

A game box's new agent is now on trial until the forge answers one of its syncs, and if it never does, the box goes back to the previous agent (#18019). The ubuntu:24.04 run, which the issue asks for, was not done: this sandbox has no docker.

The agent-script tests (test/game-agent-rollback.test.ts and the existing update test) pass as plain bash, and the gate and tsc are clean. I did not run the full suite. The unused-exports and module-state checks I ran pass. I never ran the FORGE_TEST_UBUNTU=1 docker path. It installs curl and jq inside the container, so it needs network access.

What changed

  • Keeping the old script: self_update copies the running script to agent.sh.prev before replacing it. It writes .agent.trial with the start time, the new sha and the old sha.
  • Trial guard: a guard at the very top of agent.sh replaces the new agent with the previous one in two cases:
    • Repeated starts: it has started more than FORGE_GAME_TRIAL_STARTS times (default 5) without an answered sync.
    • Too slow: it has run FORGE_GAME_TRIAL_S seconds (default 600) without one. The main loop checks this too, for an agent that runs but never syncs.
  • Proving the new agent: a 2xx sync answer ends the trial and clears the markers.
  • What the rolled-back agent does:
    • Saying so: it keeps .agent.back and sends agentBack: {sha, why} on every sync.
    • No retry: it never fetches that sha again, so a mismatch with the forge's sha cannot loop. A different agent shipping ends it.
    • Evidence kept: the failed script is kept as agent.sh.refused.
  • What the forge shows:
    • Storage: the sync is validated (a 64-hex sha, plain text under 200 characters) and stored in two new game_box columns, with a migration and its pin. The forge clears them when the box stops sending agentBack.
    • Display: the Games list row shows an "Agent" fact, and the box's terminal screen leads with "On its previous agent: the new one (…) was put back: …". Both come from agentBackLine.
    • Docs: the how-to is in docs/features/games.md, and the sync route description in OpenAPI mentions agentBack.
  • Tests: they cover keeping the previous script, the repeated-exit rollback, the timeout rollback, the sync saying why without refetching, and the forge's storing and clearing of agentBack.

What I left out

  • The guard is the new agent's own code. A new agent that dies before the guard runs is not caught. Closing that would need a systemd-side check.
  • A box that cannot reach the forge for the whole ten minutes is rolled back too, and stays on the old agent until a different sha ships. I did not add a later retry.
  • I did not extract a shared test helper. The gate notes the box and run helpers look like the ones in game-agent-update.test.ts.

To try it

  • Run bun test test/game-agent-rollback.test.ts.
  • Run it in ubuntu:24.04 with FORGE_TEST_UBUNTU=1 bun test test/game-agent-rollback.test.ts.
  • On a preview, open /games for a box whose agent was put back.

Commit lines carry Try:, Looks:/No look: and No door:. The box's terminal screen and the how-to already carry the change, and agent_back.ts is the shared helper.

🤖 Generated with Claude Code

commented

<!-- look-pages 4982667cc770 --> Look pages for 4982667, from the gate:

  • look pages (none): this pull changes src/web/pages/games.ts 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

A game box's agent that is not answered by the forge no longer gets rolled back, and the web and terminal lines now have a test.

What changed

  • Forge outage: the ten-minute clock now starts at the first sync the forge answers with a non-2xx status, kept in .agent.bad. A box that gets no answer at all (forge down, network out) neither starts nor advances it.
  • Retry: a refused sha is fetched again after FORGE_GAME_RETRY_S (default six hours), measured from when .agent.back was written. A different sha is fetched at once, as before.
  • Start limit: the five-starts rule is unchanged. A crash-looping agent never reaches a sync, so it still rolls back.
  • Forge-down test: the forge is stopped, the agent runs twice with its time limit set to zero, and the new agent stays. There is no .agent.back or .agent.bad.
  • Error-answer test: the forge answers 500, the clock starts and the agent is put back. It stays barred, then a backdated .agent.back makes it fetch the sha again.
  • Page and screen test: it renders /games as an owner with agentBackSha set and checks for "On its previous agent…". It does the same for gameBoxScreen.
  • How-to: docs/features/games.md now has its own section, "When a new agent is put back". It covers what you see, what puts it back, what to do (nothing, or ship a fixed agent), and where to look (agent.sh.refused, .agent.back, the journal). I removed the old paragraph.

Not done

  • ubuntu:24.04 run: I did not do it. The sandbox has no docker. The tests still support it through FORGE_TEST_UBUNTU=1.
  • 360px wrap: I did not check it. No browser was available here. The Agent fact reuses the existing dl facts row with no new styling, and design-lint is clean.
  • Slow-to-start agent: an agent that hangs for a reason other than the network now stays on trial until the forge gives it an error answer. I judged that safer than rolling back on silence.
  • Reviewer's point 3: gate and tsc are clean.

Looks: /games

commented

<!-- look-pages 14689b0697df --> Look pages for 14689b0, from the gate:

  • look pages (none): "Looks: /games" is not a page of app.looks in forge.json; this pull changes src/web/pages/games.ts 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

Closed in favour of #18054, which builds the same issue (#18019): it keeps the previous agent and puts it back after no full sync in 3 minutes or 3 exits in 10, and was run on ubuntu:24.04. This pull was red. The branch is kept.

Sign in to join this conversation.

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

Keyboard shortcuts

Docs