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

A game box owner can switch on "Run checks while servers sleep", and the forge sends it only trusted, fitting jobs #17599

opened this

Merged 10h 37m ago, live in production

A game box owner can now switch on "Run checks while servers sleep" on /games/ and on the terminal's box screen. Off is the default. tsc, the new and neighbouring tests, the gate and the design lint are green; I did not run the full suite or boot the app.

Notes

opened this

A game box owner can now switch on "Run checks while servers sleep" on /games/<box> and on the terminal's box screen. Off is the default. tsc, the new and neighbouring tests, the gate and the design lint are green; I did not run the full suite or boot the app.

What changed

  • The switch: POST /games/<box>/lend is owner-only and same-origin. The terminal shows the same line, and l flips it (src/games/lend.ts).
  • On: it enrols a lent-box-<name> runner, so the existing lent_scope.ts rules apply: public repos only, a cell required, 240 core-minutes a day, and an expiry set to the 365-day maximum.
  • Authors: logins are fixed when the switch goes on. They are the box repository's writers (its owner, teams and crew) plus the box's owners. If there are none it names -, never "anyone". This needed MEMBER_WRITABLE exported from core/audience.ts.
  • The claim: claimJob reads the runner's box_id and the box's spare memory from this forge's own samples, never from the box. It then claims only a job whose declared limits.memoryMiB is at most that spare. A job declaring no memory is never claimed. A box with a server not running or exited (waking, restarting) takes nothing, and neither does a box with no known spare or no box row. The spare reading is cached 30 s; the wake check is live (src/games/lend_fit.ts).
  • Off: it revokes the runner at once. The row stays, so its core-minutes are still counted.
  • Wiring: one additive migration adds check_runner.box_id. It is pinned, and the generated lists were regenerated. The docs are in game-box.md and lent-runners.md.
  • Tests: test/game-lend.test.ts covers off by default, owner-only and same-origin, an outsider's pull never claimed, a job bigger than spare or declaring none not claimed, nothing while a server wakes, and off revoking. test/tui-games.test.ts covers the terminal door.
  • Reused: enrolRunner, revokeRunner, claimJob, spareOf, spareSamples, grantsOf and roleOn. I moved noCanary into test/helpers/lent.ts for both lent test files.

Left out

  • No token delivery: the runner's token is not kept or shown, since the box's runner is the next issue. Until then the runner is enrolled but nothing can use it.
  • Authors are fixed: a writer added later is not picked up until the switch is turned off and on.
  • No memory means no claim: a box runner never takes a job that declares none, so repos without limits.memoryMiB get no help from it yet.
  • No terminal confirm: l flips the switch without asking first, since both directions are reversible.

Try it

  1. As an owner or admin, open /games/<box> and press Switch on under "Run checks while servers sleep".
  2. In the terminal, open the box screen and press l.
  3. /settings/runners then shows lent-box-<name>; Switch off revokes it.

No look is declared for the games page, and there is no review block because I did not load the page.

Closes #17577

5 earlier comments · 1 event
commented

A game box owner can now switch on "Run checks while servers sleep" on /games/<box> and on the terminal's box screen. Off is the default. tsc, the new and neighbouring tests, the gate and the design lint are green; I did not run the full suite or boot the app.

What changed

  • The switch: POST /games/<box>/lend is owner-only and same-origin. The terminal shows the same line, and l flips it (src/games/lend.ts).
  • On: it enrols a lent-box-<name> runner, so the existing lent_scope.ts rules apply: public repos only, a cell required, 240 core-minutes a day, and an expiry set to the 365-day maximum.
  • Authors: logins are fixed when the switch goes on. They are the box repository's writers (its owner, teams and crew) plus the box's owners. If there are none it names -, never "anyone". This needed MEMBER_WRITABLE exported from core/audience.ts.
  • The claim: claimJob reads the runner's box_id and the box's spare memory from this forge's own samples, never from the box. It then claims only a job whose declared limits.memoryMiB is at most that spare. A job declaring no memory is never claimed. A box with a server not running or exited (waking, restarting) takes nothing, and neither does a box with no known spare or no box row. The spare reading is cached 30 s; the wake check is live (src/games/lend_fit.ts).
  • Off: it revokes the runner at once. The row stays, so its core-minutes are still counted.
  • Wiring: one additive migration adds check_runner.box_id. It is pinned, and the generated lists were regenerated. The docs are in game-box.md and lent-runners.md.
  • Tests: test/game-lend.test.ts covers off by default, owner-only and same-origin, an outsider's pull never claimed, a job bigger than spare or declaring none not claimed, nothing while a server wakes, and off revoking. test/tui-games.test.ts covers the terminal door.
  • Reused: enrolRunner, revokeRunner, claimJob, spareOf, spareSamples, grantsOf and roleOn. I moved noCanary into test/helpers/lent.ts for both lent test files.

Left out

  • No token delivery: the runner's token is not kept or shown, since the box's runner is the next issue. Until then the runner is enrolled but nothing can use it.
  • Authors are fixed: a writer added later is not picked up until the switch is turned off and on.
  • No memory means no claim: a box runner never takes a job that declares none, so repos without limits.memoryMiB get no help from it yet.
  • No terminal confirm: l flips the switch without asking first, since both directions are reversible.

Try it

  1. As an owner or admin, open /games/<box> and press Switch on under "Run checks while servers sleep".
  2. In the terminal, open the box screen and press l.
  3. /settings/runners then shows lent-box-<name>; Switch off revokes it.

No look is declared for the games page, and there is no review block because I did not load the page.

commented

<!-- look-pages 88e45951f03e --> Look pages for 88e4595, from the gate:

  • look pages (none): this pull changes src/web/pages/games.ts but the forge could not trace the route of /, /docs, /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
the crew's run was interrupted: restart, resumes on the next pass — cancelled
commented

A game box owner can now switch on "Run checks while servers sleep" from /games/<box>. The forge then hands that box only trusted writers' pulls whose checks fit the box's spare memory.

The four checks the feedback named already pass on this branch, so I changed nothing and pushed nothing. The branch matches origin. I ran the checks locally:

  • test/unused-exports.test.ts, test/llms-budget.test.ts and test/module-state.test.ts pass.
  • bun x tsc --noEmit is clean. The diff has no as never in tests, and my new modules add no module-level Map, Set or array.
  • test/game-lend.test.ts, test/lent-runners.test.ts and test/tui-games.test.ts pass.
  • bun scripts/gate.ts --explain reads 0 failing rules out of 32. The three notes it left are:
    • A few comment lines over 100 columns, which the nightly rewrap handles on main.
    • A page-trace note: the gate could not infer which page src/web/pages/games.ts serves, so a reviewer decides.
    • Two near-duplicate function pairs, lentRunnerOf / getStoredBySubscription and boxById / boxNamed. They are one-line lookups, so I left them.

test/unused-exports.test.ts also prints that four exports are "no longer dead": pinCrawlLag, setCrawlClock, useWatchProbeByDefault and useReachByDefault. None are mine and the test still passes, so I left that to a follow-up with bun scripts/unused-exports.ts --write.

If the forge's check still fails on one of these, its log will show something my sandbox didn't reproduce. I couldn't run the tests that bind a port or a unix socket here.

To try it: open /games/<box> as its owner and press Switch on under Run checks.

Left out: no change to how the forge's own runners claim jobs.

commented

A game box owner can switch on "Run checks while servers sleep", and the forge sends the box only trusted, fitting jobs. This round addresses all six review points. I ran the tests that cover the change, plus tsc, design-lint and the gate. They are green. The only warning is the existing "no longer dead" export list in test/unused-exports.test.ts, which is not from this change. I could not run the tests that bind a port or a unix socket here.

  • Stale authors: a box's runner now reads its authors at every claim in claimJob, so a writer removed after switch-on is out at once. A new test adds a crew writer, claims their job, removes them, and the job is no longer claimed.
  • Owners as authors: lendAuthors (moved to src/games/lend_fit.ts) now returns only the repository's writers. A new test makes bob a box owner who does not write the repo, and his pull is not claimed.
  • Terminal non-owner: the test now drives bob as an operator. The screen shows no switch line, and l enrols nothing.
  • Duplicate wording: the page keeps the Run checks while servers sleep heading, and the line under it is now just the state and the one rule ("Off: this box runs none of the forge's checks."). The terminal keeps its own …: on. / …: off. line. The test string that expected the old text is updated.
  • One accent: the box page already has a primary "Run" button in the shell block, so "Switch on" and "Switch off" are both secondary now.
  • Look: the commit carries Looks: /games/net. The review block is below.

I changed the game-box.md how-to to match the new author rule.

Not done: lendAuthors still doesn't cache. It is one small query per claim from a box's runner.

To try it: open /games/<box> as its owner and press Switch on under Run checks. Remove a writer from the repo and their pull stops being claimed without toggling.

[
  {"go": "/games/net as the box's owner", "look": "the section headed Run checks while servers sleep", "expect": "one line under the heading reading 'Off: …', and a secondary Switch on button"},
  {"go": "press Switch on", "look": "the same section", "expect": "'On: only writers' public pulls that fit the spare memory, never while a server wakes.' and a Switch off button"},
  {"go": "/games/net as an operator who is not an owner", "look": "the page", "expect": "no such section"}
]
commented

I merged main into the branch and pushed it; the pull should merge cleanly again.

The only conflict was src/generated/migrations.ts. main stopped committing that file (#17213) and now reads migrations from their directory, so I took the deletion. Our 20261202190000-game-lend migration sits after main's newest (20261202184323), so it loads in order with its pin.

tsc is clean. The lend, lent-runners, terminal-games and both migration test files pass: 60 tests, 0 failures. I did not run the full suite, and the forge's check will run it on this push.

Nothing else about the pull changed: the author list is still read at claim time, and the switch, page wording and terminal behaviour are as in the last round.

commented

<!-- look-pages 5bf0e7962ec3 --> Look pages for 5bf0e79, from the gate:

  • look pages (none): "Looks: /games/net" 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 /, /docs, /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
Sign in to join this conversation.

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

Keyboard shortcuts

Docs