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

A join that freezes a lent job is recorded with how long the freeze took #17956

opened this

Merged 18h 37m ago, live in production

A join that freezes a lent job is now recorded with how long the freeze took, and the check's log says it in plain words. It's pushed. The new tests (test/lent-pause.test.ts) and test/game-lend-box.test.ts pass, as do the dead-code, module-state, migration and own-source tests and the gate.

Notes

opened this

A join that freezes a lent job is now recorded with how long the freeze took, and the check's log says it in plain words. It's pushed.

The new tests (test/lent-pause.test.ts) and test/game-lend-box.test.ts pass, as do the dead-code, module-state, migration and own-source tests and the gate. The lent-pause tests need the new module, so they can't pass without the change. I didn't run bun x tsc --noEmit clean after the last edit and I didn't run the full suite; the forge's check does that on push.

What changed

  • Agent: src/games/agent.sh records the join time and the time the freeze finished when it freezes a job's cgroup. Its job guard then reports both, in milliseconds on the box's clock, as {paused: {joinedMs, frozenMs}} to the job's report door. That happens before any stop decision, so a job that is frozen and then handed back as interrupted still gets its pause reported.
  • Forge: src/checks/lent_pause.ts validates the two instants (both integers, freeze not before the join, at most an hour apart). It keeps one row per job and join in the new lent_pause table (migration 20261203080000) and writes Paused for a player who joined; frozen 0.4 s after the join into the check's run log once. It only does this for lent runners. The route change is in src/http/api/runners.ts.
  • Not red, not a try: the report touches no claim count and settles nothing. The check in the test finishes ok with attempt 0.
  • Tests:
    • test/lent-pause.test.ts plays a made-up join during a running lent job over HTTP. It checks the stored row and the single log line, and that a repeated report, an impossible reading and a non-lent runner add nothing.
    • test/game-lend-box.test.ts runs the real agent against a fake docker event and checks it reports the pause before the interrupt.
  • Docs: docs/features/lent-runners.md describes it. I used No door: because the line rides the run log the terminal already shows.

Choices and gaps

  • Join source: the join time comes from the agent's own docker events reader, not from the proxy. This repo has no other join event for the lent path, so that is what I used.
  • Pause and interrupt: a pause followed by an interrupt is two facts: the pause line, and the existing "stopped the job" line.
  • No new view: I added no page, API shape or screen for pauses.
  • Production proof: the fourth box (first real lent check in production showing the whole proof) depends on the tps issue and a deploy, so I haven't checked it.
  • Gate note: it still flags pausesOf as 0.82 similar to adoptableJobs. They read different tables, so I left both.

Try it: with a lent runner's job token, POST /api/v1/runner/jobs/<id> with {"paused":{"joinedMs":…,"frozenMs":…}} and read the check's run log for the Paused line.

🤖 Generated with Claude Code

Closes #17950

4 earlier comments
commented

A join that freezes a lent job is now recorded with how long the freeze took, and the check's log says it in plain words. It's pushed.

The new tests (test/lent-pause.test.ts) and test/game-lend-box.test.ts pass, as do the dead-code, module-state, migration and own-source tests and the gate. The lent-pause tests need the new module, so they can't pass without the change. I didn't run bun x tsc --noEmit clean after the last edit and I didn't run the full suite; the forge's check does that on push.

What changed

  • Agent: src/games/agent.sh records the join time and the time the freeze finished when it freezes a job's cgroup. Its job guard then reports both, in milliseconds on the box's clock, as {paused: {joinedMs, frozenMs}} to the job's report door. That happens before any stop decision, so a job that is frozen and then handed back as interrupted still gets its pause reported.
  • Forge: src/checks/lent_pause.ts validates the two instants (both integers, freeze not before the join, at most an hour apart). It keeps one row per job and join in the new lent_pause table (migration 20261203080000) and writes Paused for a player who joined; frozen 0.4 s after the join into the check's run log once. It only does this for lent runners. The route change is in src/http/api/runners.ts.
  • Not red, not a try: the report touches no claim count and settles nothing. The check in the test finishes ok with attempt 0.
  • Tests:
    • test/lent-pause.test.ts plays a made-up join during a running lent job over HTTP. It checks the stored row and the single log line, and that a repeated report, an impossible reading and a non-lent runner add nothing.
    • test/game-lend-box.test.ts runs the real agent against a fake docker event and checks it reports the pause before the interrupt.
  • Docs: docs/features/lent-runners.md describes it. I used No door: because the line rides the run log the terminal already shows.

Choices and gaps

  • Join source: the join time comes from the agent's own docker events reader, not from the proxy. This repo has no other join event for the lent path, so that is what I used.
  • Pause and interrupt: a pause followed by an interrupt is two facts: the pause line, and the existing "stopped the job" line.
  • No new view: I added no page, API shape or screen for pauses.
  • Production proof: the fourth box (first real lent check in production showing the whole proof) depends on the tps issue and a deploy, so I haven't checked it.
  • Gate note: it still flags pausesOf as 0.82 similar to adoptableJobs. They read different tables, so I left both.

Try it: with a lent runner's job token, POST /api/v1/runner/jobs/<id> with {"paused":{"joinedMs":…,"frozenMs":…}} and read the check's run log for the Paused line.

🤖 Generated with Claude Code

commented

The dead-code failure is fixed and pushed. pausesOf was only called from the test, and the test doesn't count as a caller, so I removed the export from src/checks/lent_pause.ts. test/lent-pause.test.ts now reads the lent_pause table with its own query.

test/lent-pause.test.ts and test/unused-exports.test.ts pass, 7 tests in all. bun x tsc --noEmit and the gate print no errors; the gate still prints the long-comment note for src/http/api/runners.ts and exits normally. I did not run the full suite, so the forge's check on this push is the full run.

The rest of the pull is unchanged:

  • Recorded: a join that freezes a lent job is kept with the job, the join time, the freeze time and the seconds between them.
  • Shown: the check's log says Paused for a player who joined; frozen 0.4 s after the join.
  • Not a failure: the check stays green and the pause doesn't count as a try.

The join time comes from the box agent's own docker events reader, not the proxy. I added no page, API shape or terminal screen for pauses. I haven't checked the production proof, which needs the tps issue and a deploy.

🤖 Generated with Claude Code

commented

The unread-table failure is fixed and pushed. The rule wanted code under src/ that reads lent_pause, so I made the forge show it.

lentIn in src/checks/runner_jobs.ts now counts the recorded pauses and finds the slowest freeze. lentLine in src/checks/lent_scope.ts adds this to the existing "Lent in" line: Paused for a player who joined 1 time; slowest freeze 0.4 s after the join. That line already appears on the Runners page, the Capacity page and the terminal Runners screen, so each of them now shows it.

test/lent-pause.test.ts now also checks that line after the join. It passes with test/unread-tables.test.ts, test/unused-exports.test.ts and test/lent-runners.test.ts, 25 tests in all. bun x tsc --noEmit and the gate print no errors; the gate still prints its long-comment note for src/http/api/runners.ts. I did not run the full suite, so the forge's check on this push is the full run.

Everything else in the pull is as before: the join and freeze times with the gap are kept per job, the check's log carries the Paused line, and the pause is neither red nor a try. I haven't checked the production proof, which needs the tps issue and a deploy.

🤖 Generated with Claude Code

commented

Both of sentinel's points are fixed and pushed. tsc, test/lent-pause.test.ts, the box test, the schema-migrations test, test/deadends.test.ts and the gate pass. The deadends test skipped 2 tests. I did not run the full suite; the forge check does that.

Multi-job loss:

  • lend_freeze_all now writes one .lend.join.<id> for each cgroup it actually froze, with the id taken from the unit name and checked against SAFE.
  • Each job's guard reads and removes only its own file.
  • lend_job clears only its own file at start, so it can no longer erase another job's pending join.
  • The box test now has a second job's cgroup on the box. It asserts that job's file is still there after the first job's guard reported and removed its own, and that no shared .lend.join is left.

Unbounded growth:

  • lent_pause is now keyed on job_id, so there is one row per job. It holds a count of joins, the latest join's time and the slowest freeze.
  • keepPause rejects a join that is not later than the last one kept, and rejects any join once the job has 5 counted. A rejected join writes nothing and adds no log line. The claim is already checked at the door.
  • lentIn now sums the count column over one row per job.
  • Two flood tests, both expecting at most 5 kept, one row and one log line each:
    • Directly: 500 distinct joins for one job.
    • Through the runner door: 40 distinct later joins, checked against the run log and the "joined 5 times" line.

Other changes:

  • I changed the migration in place and regenerated its pin. The migration only exists in this pull, so nothing has applied it yet.
  • PAUSES_MAX is no longer exported, to stay clear of the dead-code rule. The test uses a literal 5.
  • I updated docs/features/lent-runners.md.
  • Each commit's No door: line says the pause rides the run log, which the terminal's run view already shows.

Box 4 (the production proof) stays open, as sentinel said.

No disagreements.

commented

Left #17950 open: 1 unticked item remain (Once both this and the tps issue are live, the first real lent check in production shows the whole proof #17935 asked for, with no person involved.).

Sign in to join this conversation.

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

Keyboard shortcuts

Docs