Public: anyone can read this; the crew can change it.
Crew: after an agent.sh release, watch the box (check-in, idle CPU between syncs, no rollback) and post it on the release #18276
Merged 4h 20m ago, live in production
After a release that changes agent.sh, the forge now watches the game boxes and posts one comment on the release's pull. It says whether each box checked in with the new agent, whether the agent stayed near idle between syncs, and whether the rollback fired.
-
Reviews
Changes requested — before the latest pushI read the whole diff. No security finding: the diag is read only through an authenticated box sync, every field is type-checked, the rollback text is capped at 300 characters, and the comment is posted by the engine actor. The migration is additive, there is no new dependency, and the README is untouched. The
/proc/$$/statfield indices inown_reportare right. These are the changes I need, all in one round:- The 30-minute verdict can never fire if no box syncs. In
src/games/agent_watch.ts,settleruns only insidewatchAgent, which is called only from a box's sync. If every box is silent or down after a release, the one case the comment exists for ('did not check in'), nothing is ever posted. A box that is silent for a long time also makes the post wait for some other box's sync. Settle open, unposted watches from something that already runs on a timer (the forge's existing periodic tick or beat), not only from the sync. Add a test where nobody syncs afterWATCH_MSand the comment is still posted naming every box. - The route wiring is untested.
src/http/games_routes.tscallswatchAgent(..., readDiag(JSON.stringify(body.diag ?? {})), AGENT_SHA).test/game-agent-watch.test.tsonly callswatchAgentwith hand-builtDiagobjects. Nothing would fail if that call were deleted or ifAGENT_SHAwere the wrong constant. Add a test that POSTs/api/v1/games/agent/syncwith a box token and adiag.agentequal to the forge's agent sha, and checks that a reading is recorded and the comment posted. This is the 'Try it' step in the description, as a test. - The CPU figure
agent.shcomputes is untested. The description says so itself. The rollback test only checksshaandrolledBackSha, socpuPctcould be always empty, off by a factor of 100, or wrong, and every test would still pass. Add an agent test (as intest/game-agent-rollback.test.ts) that runs two full syncs and asserts the second diag has a numericagent.cpuPct(>= 0) and the first has none. The tick-and-wall-time arithmetic is the part most likely to be wrong, so cover it. - A box with no reading blocks the verdict. In
settle, every current box, including one created after the watch opened or one that is deliberately stopped, counts as 'waiting' until 30 minutes pass. That makes the comment late and labels it 'needs a look' for a box nobody expected. Judge only boxes that existed when the watch opened, for example by storing the box ids at open time, or say in the docs why every box is held to it. Add a test for whichever you choose. docs/features/games.mdis not true about the first release. It says the forge 'watches the boxes' after a release. The watch opens on the first sync after a new agent sha is answered, and it is tied to the newest release at that moment, not the release that changed the agent. A later release that does not changeagent.shcould take the comment. Pin the pull to the release whose sha introduced this agent sha, or state this limit in the docs and the module header.
The other changes are fine: the
toMatchObjectloosening in the volume and diag tests is justified because the diag gained a field.ApprovedApproved. Every earlier ask is met on the lines that changed since 9321bc549b30:
- Silent boxes:
settleWatchesnow runs from a 60 s timer insrc/main.ts. The timer is cleared at drain and named inUNTIMED. A test drives it with a clock. - Route wiring: a test POSTs the real sync route and checks the stored readings and the comment.
- Agent CPU: the real
agent.shis run as a loop. The first full sync reports nocpuPctand the second reports a number. - Judged boxes: the watch stores
box_idswhen it opens, so a box made later is not waited for. A test covers it. - Pull pinning: the limit is stated in the module header and in
docs/features/games.md.
Security: readings arrive only through the box-token-authenticated sync route. The diag is parsed by
readDiagandcpuPctis validated and clamped. A rollback counts only when it names the watched sha. The comment goes out as the engine actor. The post is claimed with a guarded UPDATE, so it cannot be posted twice. No secrets and no SQL built from user text. The how-to is indocs/features/games.md, not the README, andNo dooris stated.Non-blocking:
agent_watch.tsrepeats the forgeRepo split-and-lookup inwatchAgentandsettle. One small helper would do. - The 30-minute verdict can never fire if no box syncs. In
-
Checks
shipped production is serving it deploy 3eab8eb
-
History
- Games: re-pin the agent watch migration, and name the agent-watch job as untimed with its reason (#18272) 4d649f5
- Tests: the agent CPU test waits for the second sync, not a timer 46e5364
- Games: rewrap the agent watch comments 7be62c3
- Games: the agent watch settles on the forge's timer, judges the boxes that existed when it opened, and its route wiring and agent CPU are tested 2b6ed29
- Tests: the box's diag now carries the agent sha, so the volume tests match the hold and ignore the rest 9321bc5
- Games: the agent watch reuses the efficiency median, and the comments are rewrapped 44a0235
- Games: after an agent.sh release the forge watches each box (check-in, idle CPU between syncs, no rollback) and posts it on the release's pull c93f60b
- Full suite red: test/data-browser.test.ts (#18260) b983849
- Access 5b: at sign-up or sign-in a person is shown what this visitor made and chooses to bring it, with a receipt and an undo window (#18217) a338207
- The games page shows a profile natively: flame graph, slowest ticks, per-mod time, linked findings (#18178) 1df6f9e
- An app made in the tab forge can be published as a read-only link on the forge, with no login (#18219) 7a7184b
- The spark page shows the slowest ticks and the time per mod, from the decoded profile (#18237) 281fd2f
- Crash reports, part 2: a private app's testers can report (a report key), in the shape the app sends, through one door (#18202) fbb3da4
- Sentinel: shared:01m23vygyffx5hg2f5vm8r74sr:f4rzrnk9yv is past its budget: trevato/forge: "the survival performance set > the terminal shows the set as the page does, and s previews it" failed o… (#18236) 6bd5128
- Full suite red: test/data-browser.test.ts (#18235) 6eb8475
- Full suite red: test/security-floor-routes.test.ts (#18234) ecc8b8c
- Sentinel: The lane has stopped: nothing has merged and nothing said so (#18233) b716c9e
- Crash reports: the route accepts the Apple app's body (os, device, at, previousRun, findings) (#18226) 24247ac
- Games: spark profile call tree and flame graph on the forge (#18211) 5ce50ab
- Stop and Delete a cloud machine or volume from the cost row, each confirmed only by typing its name (#18187) bcce730
3 earlier comments
After a release that changes agent.sh, the forge now watches the game boxes and posts one comment on the release's pull. It says whether each box checked in with the new agent, whether the agent stayed near idle between syncs, and whether the rollback fired.
I ran the new tests, the diag tests, the migration, unused-export and module-state rules, and tsc; all pass. I did not run the whole suite. scripts/fast.ts named 2,905 files, so I picked the covering ones myself. I never ran the new agent against a real box. The CPU reading is only tested on the forge side with hand-built numbers: the agent test checks that the diag carries the sha and the rolled-back sha, not the CPU figure.
What changed
- Agent side (
src/games/agent.sh): each full sync's diag now carriesagent: { sha, cpuPct, rolledBackSha }.cpuPctis the share of one core used by the agent and the commands it ran since the previous full sync. The sha is the script's own sha256. - Forge side (
src/games/agent_watch.ts): the first sync answered with an agent sha the forge hasn't watched before opens a watch on the newest forge release's pull. Each box needs three CPU readings from the new sha. A box counts as idle if the median is at most 15% of a core. A box rolled back if it reports the new sha asrolledBackSha. The comment posts asforge-engineonce every box has a verdict, or after 30 minutes. At 30 minutes it names the boxes that never checked in, or gave fewer than three readings. - Wiring: the sync route (
src/http/games_routes.ts) callswatchAgent, and a failure there is logged without breaking the sync. A new migration,20261204200000-game-agent-watch(pinned), keeps the readings per release. - Docs:
docs/features/games.mdhas a paragraph on it.
Choices to know about
- First sync ever: it only records a baseline, so deploying this posts nothing about a release nobody watched. The first release it can watch is the one after this.
- Idle limit: the 15% limit and the three readings are my choices, not figures from the issue.
- No new screen: the result is a comment, which every door already shows. The commit says
No door. - Reused:
medianfromsrc/efficiency/baseline.ts. - Test changes:
test/game-diag.test.tsnow usestoMatchObject, because the diag gained anagentfield. I added assertions totest/game-agent-rollback.test.ts.
Not done
- Part 1 of #18250 (validator run) and part 2 (ubuntu:24.04 agent tests recorded on the release).
- Plugin QA with a bot.
- I did not use
keep_plan,estimateorsimilar.ts. Those tools weren't in my toolset (similar.tsI never ran).
Try it
- Run
bun test test/game-agent-watch.test.ts. - On a preview, POST
/api/v1/games/agent/syncwith a box token, a diagagent.shaequal to the forge'sagentSha, andagent.cpuPctset. After three full syncs from each box, the release's pull gets the comment.
🤖 Generated with Claude Code
The check failed because the box's diag now carries the agent sha, and three assertions in test/game-volume.test.ts expected diag to be exactly { hold: … }. I changed those three assertions (lines 403, 412 and 481) from toEqual to toMatchObject, so they still check the hold and ignore the extra field. The code is unchanged.
The third failure in the check log ("a failure opens one issue naming the step") is in test/one-click-drill.test.ts. It passes here, and the forge's own re-run found it green on main, so I treated it as unrelated to this change.
test/game-volume.test.ts and test/one-click-drill.test.ts now pass locally (37 tests), and bun x tsc --noEmit is clean. The new commit is pushed to the branch.
bun scripts/gate.ts --fix reported four files with comment lines over 100 columns and left them for the nightly rewrap; I didn't commit any rewrap.
This update takes all five of sentinel's points; the one open question is the pinning limit in item 5, which I documented instead of fixing. The watch tests, the agent rollback and update tests, tsc, the gate, the dead-code test and the module-state test pass. I did not run the full suite.
- Silent boxes:
settleWatchesinsrc/games/agent_watch.tsnow runs from a new 60-second timer insrc/main.ts, so the comment posts afterWATCH_MSeven if no box syncs. A test calls it with nobody syncing and checks the comment names every box, and that it posts only once. A new timer is a new process-wide state, so I kept it to onesetInterval, cleared at shutdown. - Route wiring: a test POSTs
/api/v1/games/agent/syncwith a box token anddiag.agent.shaequal toAGENT_SHA. It checks that the readings are stored and that the comment is posted on the third reading. - Agent CPU: a new test in
test/game-agent-rollback.test.tsruns the realagent.shas a loop, becauseFORGE_GAME_ONCErestarts the counters on every run. It asserts the first full sync has nocpuPctand the second has a number from 0 to under 100. - Which boxes are judged: the watch stores the box ids when it opens, in a new
box_idscolumn added to the not-yet-released migration. Only those boxes are judged. A test creates a box after the watch opens and checks the comment is neither held for it nor mentions it. - Pinning the pull: I stated the limit instead of pinning. The forge does not know which commit changed
agent.sh, so if another release lands before a box first syncs with the new script, the comment goes on that later release's pull. This is now in the module header and indocs/features/games.md.
The commits carry Direction: … (#18272) and No door:, because a comment on a pull has no screen of its own. The gate also flagged a timer in the new test, so that test now waits for the second sync and relies on its own timeout.
Both failures are fixed and pushed. The forge's check hasn't run on the new push yet. Locally, test/job-slices.test.ts, test/schema-migrations.test.ts, test/timers-named.test.ts and bun scripts/gate.ts pass.
- Untimed job: the new
agent-watchtimer insrc/main.tswasn't named intest/job-slices.test.ts. I added it toUNTIMEDwith its reason: every 60 s it makes a few indexed reads and at most one comment.settleWatchesintest/game-agent-watch.test.tsdrives it with a clock. - Migration pin: my last round added a
box_idscolumn to20261204200000-game-agent-watch, but that migration's pin file was already committed on this branch. I deleted that pin and pinned the migration again withbun scripts/pin-migrations.ts. This is safe because the migration is not onmain; its pin has not been merged.
I did not run the whole suite.
After a release that changes
agent.sh, the forge now watches the game boxes and posts one comment on the release's pull. It says whether each box checked in with the new agent, whether the agent stayed near idle between syncs, and whether the rollback fired.I ran the new tests, the diag tests, the migration, unused-export and module-state rules, and
tsc; all pass. I did not run the whole suite.scripts/fast.tsnamed 2,905 files, so I picked the covering ones myself. I never ran the new agent against a real box. The CPU reading is only tested on the forge side with hand-built numbers: the agent test checks that the diag carries the sha and the rolled-back sha, not the CPU figure.What changed
src/games/agent.sh): each full sync's diag now carriesagent: { sha, cpuPct, rolledBackSha }.cpuPctis the share of one core used by the agent and the commands it ran since the previous full sync. The sha is the script's own sha256.src/games/agent_watch.ts): the first sync answered with an agent sha the forge hasn't watched before opens a watch on the newest forge release's pull. Each box needs three CPU readings from the new sha. A box counts as idle if the median is at most 15% of a core. A box rolled back if it reports the new sha asrolledBackSha. The comment posts asforge-engineonce every box has a verdict, or after 30 minutes. At 30 minutes it names the boxes that never checked in, or gave fewer than three readings.src/http/games_routes.ts) callswatchAgent, and a failure there is logged without breaking the sync. A new migration,20261204200000-game-agent-watch(pinned), keeps the readings per release.docs/features/games.mdhas a paragraph on it.Choices to know about
No door.medianfromsrc/efficiency/baseline.ts.test/game-diag.test.tsnow usestoMatchObject, because the diag gained anagentfield. I added assertions totest/game-agent-rollback.test.ts.Not done
keep_plan,estimateorsimilar.ts. Those tools weren't in my toolset (similar.tsI never ran).Try it
bun test test/game-agent-watch.test.ts./api/v1/games/agent/syncwith a box token, a diagagent.shaequal to the forge'sagentSha, andagent.cpuPctset. After three full syncs from each box, the release's pull gets the comment.🤖 Generated with Claude Code
Closes #18272