Public: anyone can read this; the crew can change it.
A game box runs a claimed check in a cell with no reach to Docker, worlds or its token, and a join freezes it at once #17607
Merged 16h 41m ago, live in production
The box side of "Run checks while servers sleep" is written and tested against stand-ins, but it has never run on a real box and I did not produce the tps/mspt and wake-time proof.
-
Reviews
Changes requested — before the latest pushChanges needed (src/games/agent.sh unless noted). The forge side (
interruptJob,lendAnswer, the route and the tests for them) is sound. The box side has two high findings, and the issue's proof box is missing.HIGH 1: a job's output is unbounded on the box's own disk.
lend_stepredirects the step's stdout and stderr to$work.out, and that file is outside the capped tmpfs, root-owned, on the box's root disk. A check that prints for its 600 s can fill the disk that holds the game worlds, andjq --rawfilethen loads the whole file into memory. Fix: put the output inside the capped tmpfs, or pipe it throughhead -c <cap>(say 1 MiB), and read only the tail. Add a test that floods output.HIGH 2: on a real box (
LEND_HOST=1) the checkout cannot work.$workis a tmpfs owned byforge-jobwith mode 0700.mkdir -p "$work/src"then runs as root, sosrcis root-owned, andas_job ... git initruns asforge-joband cannot write into it. Every job would be handed back with 'could not fetch the commit'.$work/envandresolv.confare written as root too, which is fine only because they are readable. Fix:chownsrcto the job user, or create it as that user. The tests setFORGE_GAME_LEND_HOST=0, so the real branch (useradd, tmpfs mount, setpriv, iptables) has no test at all. Add stand-ins formount,setprivandidso it runs, or a test that checks the ownership of what the cell is given.MEDIUM 3:
lend_checkoutputs the job token inenv GIT_CONFIG_VALUE_0=Authorization: Bearer $tok, which is argv. It is readable in/proc/<pid>/cmdlineandps, while the comment says 'never on a command line'. Fix: export it in the environment of theas_jobcall (GIT_CONFIG_VALUE_0=... as_job ..., orsetprivwith the variable inherited), or pass it on stdin. Then correct the comment.MEDIUM 4:
lend_net_readyskips IPv6 whenip6tablesis missing, so the install step's IPv6 traffic to the game network is unfiltered. Treat a missingip6tablesas not ready when the host has IPv6, or disable IPv6 in the cell. The-dranges also leave out the box's own public address, which is reachable through Docker's published ports; reject it too.LOW 5:
interruptJobhas no bound. A lent runner can claim and interrupt one job forever, and none of those claims count towardMAX_CLAIMS, so that check never lands. Also,resultkeeps 'interrupted: ...' after the job is claimed again, so a later lease expiry would be logged as 'stopped the job' inrunner_step.ts. Clearresulton claim, or note why not. If you add no bound, say so in the pull.DOC/PROOF: issue box 4 asks for proof in the pull (tps and mspt with and without a job, and wake time on a join). The docs say it is 'not done', so the box stays open. Box 1's 'network caps' is also only partly done: the install step has no bandwidth cap, and the pull lists it as left out. Run it on a real box and put the numbers in the pull, or split box 4 off into its own issue and say so.
When fixing, also add a
No door:line to the commit (agent and runner API only, no page or TUI change), if the gate asks.ApprovedEvery earlier ask is met on this head: the step output is capped and kept on the job's own tmpfs, the checkout is made as the job user, the job token is in the environment of the call and not on argv, the reject rule covers the box's own v4 and v6 addresses, and a repeated interruption keeps its claim. Non-blocking: the
ulimit -fis set on thesystemd-runclient, not on the unit's processes, because systemd starts those, so the real bound on a flooding step is the tmpfs size and the guard. The tail is capped at 64 KiB either way. Non-blocking: the install step has no bandwidth cap, and the proof of tps, mspt and wake time on a real box is still owed. Open an issue for each. -
Checks
shipped production is serving it deploy 49845bf
-
History
- A box's job output is capped, its checkout is the job user's, its token off argv, its network rule covers the box's own addresses, and a repeated interruption counts (#17578) 68523a0
- The box is sent its runner's token once, and a new one when it has none (#17578) cb22002
- Rewrap comments fce8a3e
- A game box runs a claimed check in a cell with no reach to Docker, worlds or its token, and a join freezes it at once 604ec64
- A game box owner can switch on "Run checks while servers sleep", and the forge sends it only trusted, fitting jobs (#17599) 9c89a64
- Migrations are read from their directory when the forge is bundled: two pulls that each add one merge in either order (#17213) 11c2487
- The hollow audit no longer forces a full collection every 64 files: half its CPU, a lower peak (#17600) 954e20f
- Merge pull request #17601 from sold/floor-paths-bind 1cfbdc6
- The app stand-ins of security-floor-paths bind 127.0.0.1, so no other process answers for them fbfc6e3
- A failed cloud read says the host, status and code, in plain characters (#17598) f8c7b30
- The check's tsc runs eight checkers, not four (#17574) 88d036f
- A game box says how many spare core-hours a week its sleeping servers leave, against what the forge's checks use (#17589) 7c6f863
- Talk: a dev server is handed its own address whole, so an app made from the template comes up instead of hanging 60 s (#17595) 8f632d3
- Template: a FORGE_APP_URL that is no address is warned of, not thrown (#17596) f43af8d
- Merge pull request #17554 from sold/cloud-tree c52e927
- Turning the crew on names who turned it on, by every door: the Autonomy knob no longer leaves a repository paused as "nobody" (#17588) ac9e135
- A closing forge forgets its repositories in every process-wide map keyed by repository (#17594) ddf713b
- Date the cloud inventory migration after main's newest (#17532) b0ed311
- List Cloud resources straight after Infrastructure in the palette (#17532) f5b6e08
- Wrap a paragraph of CLOUD.md and a comment (#17532) 81c27ce
3 earlier comments · 1 event
The box side of "Run checks while servers sleep" is written and tested against stand-ins, but it has never run on a real box and I did not produce the tps/mspt and wake-time proof. Two things were not run for real: bubblewrap here refuses user namespaces, so the cell's arguments were only checked against a recording stand-in, and starting anything on a real box needs your go. The boot, agent-update, lend, runner, TUI-games and openapi suites pass (1065 tests), and tsc and bun scripts/gate.ts are clean apart from "similar function" hints I judged to be noise.
What changed
- Runner token to the box. The sync answers
lend: {token}once to a box that says it holds none, andlend: {off: true}after the switch goes off. If the forge restarted before delivery or the reply was lost, the old runner is revoked and a new one enrolled, so the box is never left without one. The token lives only in forge memory until sent and in/opt/forge-game/.runner.auth(mode 600). - The cell (
src/games/agent.sh).- Claiming. One job per tick, only when no container started in the last 90 s, no compose job is running, and at least 768 MiB is available.
- Per-step cell. Each step is its own systemd unit with a memory, cpu and task cap and a cgroup to freeze. It runs as the unprivileged user
forge-jobin bubblewrap with--unshare-all,/usrread-only, only the checkout at/work, and a cleared environment. The cell sees no/run(the Docker socket), no/opt/forge-game(agent.env, the box's token) and no data volume. - Network. The check step has no network. The install step shares it, but iptables rejects that user's traffic to private, loopback, link-local and shared-range addresses.
- Disk. The checkout is a size-capped tmpfs.
- Handed back, not run. The box hands a job back (the forge runs it) when the job names egress hosts, declares no memory, or needs a tool the box lacks (exit 126/127); after a missing tool it rests 10 minutes.
- Join order.
- A
docker eventsreader stops claiming and freezes every job cgroup at once; nothing waits on a job. - A guard checks twice a second and, still frozen with memory under the floor or frozen for 5 minutes, kills the job and answers
interrupted. - A quiet box thaws it.
- A
interrupted(src/checks/runner_jobs.ts). A new report onPOST /api/v1/runner/jobs/:id: the job goes back to queued with no result and its claim not counted. It is never red and never a try ofMAX_CLAIMS, and the check's log says so.- Boot. New boxes install
bubblewrap,gitandiptables; an older box runs no jobs until they are there. - Tests.
test/runner-interrupted.test.tsevicts one job more thanMAX_CLAIMStimes and checks its claim count stays at 0 and the old token is dead.test/game-lend-box.test.tsruns the real agent against a fake forge: token handling, cell contents, red only by exit code, hand-back cases, and a join that freezes first and then stops and answersinterrupted.test/game-lend.test.tscovers the token answer.
- Docs.
docs/features/game-box.md,docs/features/runners.mdand the openapi route text.
What I left out or want you to know
- No toolchain on the box. It has no bun. A job needing one is handed back until the owner puts a toolchain in
/opt/forge-job-tools, which the cell mounts at/opt/tools. This also means almost every real job is handed back today, so the feature does little until a toolchain is provided. - The claim loop runs in the agent, not in a cell. The claim loop and the checkout are the agent's own shell code. They hold the runner token in a file no cell can see, and each job step is cell-run. I did not nest a second runner inside a cell.
- Not done here: seeds, install caching, and bandwidth caps on the install step's network.
- Ubuntu 24.04 may block it. Its AppArmor restriction on unprivileged user namespaces may need a bubblewrap profile for the cell to start.
To try
bun test test/runner-interrupted.test.ts test/game-lend-box.test.ts test/game-lend.test.ts.- To exercise it on a box, switch "Run checks while servers sleep" on at
/games/<box>once you give the go.
No new code this turn. I re-ran each check you named against the branch and none fails here. The branch was already pushed (git push said "Everything up-to-date"), so the forge's own check has to say whether it still refuses. If it does, its log is the next thing to read.
- Both doors:
bun scripts/gate.ts --explainpasses. The commits carry "No door:" lines, because the sync answer and the runner report are machine routes with no page or terminal view of their own. - Name the issue: the Direction line in
604ec64c2ends with (#17578), and the gate passes. - Tests with real input: the two new test files,
test/game-lend-box.test.tsandtest/runner-interrupted.test.ts, contain noas neveroras unknown as. - Dead code:
bun scripts/unused-exports.tsreports nothing in the files I touched. The two exports I added,interruptJobandlendAnswer, both have callers.
bun x tsc --noEmit is clean, and the four covering test files pass (45 tests). The gate's two notes are not gate failures. The duplicate-function notes are advisory and I left them; the comment-width note says the nightly rewrap handles it on main.
Pull description
A game box can now run a claimed check while servers sleep, and a join stops it at once.
- Box agent:
src/games/agent.shclaims jobs with the runner token the sync delivers once. It runs each step as an unprivileged user in a bubblewrap cell under its own cgroup, with no reach to Docker, worlds or that token. On a join it stops claiming, freezes the cgroup and stops the job. - Interrupted jobs: a stopped job is reported as interrupted, not red and not a try.
POST /api/v1/runner/jobs/<id>with{"interrupted":"a server woke"}on a held job queues it again with no result (src/checks/runner_jobs.ts,src/http/api/runners.ts). - Token:
lendAnswersends the box its runner's token once, and a new one when it has none (src/games/lend.ts). - Left out: no page or terminal change, since the switch and its words already exist. The sync and runner routes are machine routes, and
docs/features/game-box.mdandrunners.mdcover them.
To try it, run bun test test/runner-interrupted.test.ts test/game-lend-box.test.ts.
🤖 Generated with Claude Code
This push fixes the box-side findings and the forge-side bound on interruptions. Box 4's proof (tps, mspt and wake time) is still not delivered. The gate, tsc and the covering tests pass here. The tests cover the cell's argv, user and ownership calls, and firewall rules only through stand-ins. Nothing here ran against a real box with real mount, setpriv or iptables.
Fixed, box side (src/games/agent.sh):
- Output (HIGH 1): a step's output now goes to
$work/out, inside the job's capped tmpfs. A file-size limit also stops any write past 1 MiB (FORGE_GAME_LEND_OUT_KIB). A flooding step is killed with SIGXFSZ, so the job reports "killed (signal 25)" rather than an unbounded disk. Only the last 64 KiB is read. The new flood test passes. - Checkout ownership (HIGH 2):
srcis created throughas_job, so the job user owns it. New host-mode tests (FORGE_GAME_LEND_HOST=1) use stand-ins forid,mount,setpriv,hostname,iptables,ip6tablesanduseradd. They check that the tmpfs is mounted with the job's uid and gid, and thatmkdirand git run throughsetpriv --reuid=forge-job. - Token (MEDIUM 3): the job token is now in the environment of the
as_jobcall, not on argv. The tests check that it reaches git by environment and appears in nosetpriv, git or bwrap argument. The comment is corrected. - Network (MEDIUM 4): the reject rule now also covers the box's own addresses, v4 and v6. A missing
ip6tableson a host with a non-loopback IPv6 address now hands the install step back instead of skipping IPv6. That last case is covered by a test, but it only asserts the handback when the machine running the test has such an address.
Fixed, forge side:
- Interruptions (LOW 5): the first interruption of a job still gives its claim back. A job already interrupted keeps its claim, so a runner that interrupts forever brings the check to
MAX_CLAIMSand the forge runs it itself. A lapsed lease clearsresult, sorunner_step.tsno longer says "stopped the job" for a silent runner. Both are tested intest/runner-interrupted.test.ts.
Also: docs/features/game-box.md describes the output cap and the address rule.
Not done:
- Box 4 proof: I have no real box in this sandbox. The box stays open, and a person should run it on a box and add the numbers, or split it into its own issue.
- Box 1 bandwidth: the install step still has no bandwidth cap.
Left #17578 open: 2 unticked items remain (When the switch is on, src/games/agent.sh runs the runner and each job in a cell (bubblewrap) with no route to the Docker socket, the game network, the data volume or agent.env, and with disk and network caps.; Proof in the pull: tps and mspt (src/games/metrics.ts) of an awake server with and without a job beside it, and the wake time on join with a job running.).
The box side of "Run checks while servers sleep" is written and tested against stand-ins, but it has never run on a real box and I did not produce the tps/mspt and wake-time proof. Two things were not run for real: bubblewrap here refuses user namespaces, so the cell's arguments were only checked against a recording stand-in, and starting anything on a real box needs your go. The boot, agent-update, lend, runner, TUI-games and openapi suites pass (1065 tests), and
tscandbun scripts/gate.tsare clean apart from "similar function" hints I judged to be noise.What changed
lend: {token}once to a box that says it holds none, andlend: {off: true}after the switch goes off. If the forge restarted before delivery or the reply was lost, the old runner is revoked and a new one enrolled, so the box is never left without one. The token lives only in forge memory until sent and in/opt/forge-game/.runner.auth(mode 600).src/games/agent.sh).forge-jobin bubblewrap with--unshare-all,/usrread-only, only the checkout at/work, and a cleared environment. The cell sees no/run(the Docker socket), no/opt/forge-game(agent.env, the box's token) and no data volume.docker eventsreader stops claiming and freezes every job cgroup at once; nothing waits on a job.interrupted.interrupted(src/checks/runner_jobs.ts). A new report onPOST /api/v1/runner/jobs/:id: the job goes back to queued with no result and its claim not counted. It is never red and never a try ofMAX_CLAIMS, and the check's log says so.bubblewrap,gitandiptables; an older box runs no jobs until they are there.test/runner-interrupted.test.tsevicts one job more thanMAX_CLAIMStimes and checks its claim count stays at 0 and the old token is dead.test/game-lend-box.test.tsruns the real agent against a fake forge: token handling, cell contents, red only by exit code, hand-back cases, and a join that freezes first and then stops and answersinterrupted.test/game-lend.test.tscovers the token answer.docs/features/game-box.md,docs/features/runners.mdand the openapi route text.What I left out or want you to know
/opt/forge-job-tools, which the cell mounts at/opt/tools. This also means almost every real job is handed back today, so the feature does little until a toolchain is provided.To try
bun test test/runner-interrupted.test.ts test/game-lend-box.test.ts test/game-lend.test.ts./games/<box>once you give the go.Closes #17578