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

An evicted check on a game box loses at most one shard, and a frozen job thaws if the player leaves soon #17615

opened this

Merged 20h 15m ago, live in production

An evicted check on a game box now keeps every shard that had already passed and queues only the one that was running. The existing freeze-and-thaw guard already covered the thaw item; I added tests for it. All tests I ran pass, bun x tsc --noEmit is clean and the gate is satisfied.

Notes

opened this

An evicted check on a game box now keeps every shard that had already passed and queues only the one that was running. The existing freeze-and-thaw guard already covered the thaw item; I added tests for it. All tests I ran pass, bun x tsc --noEmit is clean and the gate is satisfied.

I did not run the whole suite. scripts/fast.ts reports the diff as too broad because scripts/test-shards.ts changed, so the forge's full check will cover the rest.

What changed

  • Box agent (src/games/agent.sh): when a job is stopped, the agent reads the step's output for shards that ended with exit 0 and sends their test files along with interrupted, as kept.
  • Forge (src/checks/runner_jobs.ts, src/http/api/runners.ts): interruptJob merges kept into the job's own env as FORGE_CHECK_DONE. It is a bounded set, unsafe paths are dropped, and a second stop adds to the first. The next claim carries it.
  • Shard runner (scripts/test-shards.ts): it drops the files named in FORGE_CHECK_DONE before slicing. If none remain it exits 0 with "nothing to run". The parsing helpers are in src/checks/shard_event.ts.
  • Thaw: a frozen job thaws when the box has been quiet 90 s with memory above the floor. It is stopped and queued as interrupted past FORGE_GAME_LEND_FROZEN_S (300 s default) or when memory is needed. The agent code for this was already on main.
  • Docs: docs/features/game-box.md now describes both behaviours.

Tests

  • test/game-lend-box.test.ts:
    • An eviction keeps the green shard and names neither the red shard nor the one that was running.
    • A job thaws and finishes within the window.
    • A job frozen past the window is requeued as interrupted.
    • An existing assertion changed from ["interrupted"] to ["interrupted", "kept"], since the body now has two keys.
  • test/runner-interrupt-keeps.test.ts:
    • Kept files ride the requeued job.
    • A second stop adds to the first.
    • A stale token keeps nothing.
    • The set is bounded and unsafe paths are dropped.
    • test-shards.ts skips finished files.

Left out

  • CRIU checkpointing, as the issue says.
  • Keeping the passed files of a half-finished shard. Only shards that printed a done (exit 0 line count.
  • A terminal or doc door. The new field belongs to the box agent, not a page or action, so the commit says No door:.

Reused

  • safeFile from src/checks/verify.ts for path validation.
  • The FORGE_CHECK_ONLY handling in test-shards.ts as the pattern for the skip.
  • The existing interruptJob and lend_give paths, extended rather than replaced.
  • I did not run bun scripts/similar.ts.

Try it: bun test test/runner-interrupt-keeps.test.ts test/game-lend-box.test.ts

🤖 Generated with Claude Code

Closes #17579

commented

An evicted check on a game box now keeps every shard that had already passed and queues only the one that was running. The existing freeze-and-thaw guard already covered the thaw item; I added tests for it. All tests I ran pass, bun x tsc --noEmit is clean and the gate is satisfied.

I did not run the whole suite. scripts/fast.ts reports the diff as too broad because scripts/test-shards.ts changed, so the forge's full check will cover the rest.

What changed

  • Box agent (src/games/agent.sh): when a job is stopped, the agent reads the step's output for shards that ended with exit 0 and sends their test files along with interrupted, as kept.
  • Forge (src/checks/runner_jobs.ts, src/http/api/runners.ts): interruptJob merges kept into the job's own env as FORGE_CHECK_DONE. It is a bounded set, unsafe paths are dropped, and a second stop adds to the first. The next claim carries it.
  • Shard runner (scripts/test-shards.ts): it drops the files named in FORGE_CHECK_DONE before slicing. If none remain it exits 0 with "nothing to run". The parsing helpers are in src/checks/shard_event.ts.
  • Thaw: a frozen job thaws when the box has been quiet 90 s with memory above the floor. It is stopped and queued as interrupted past FORGE_GAME_LEND_FROZEN_S (300 s default) or when memory is needed. The agent code for this was already on main.
  • Docs: docs/features/game-box.md now describes both behaviours.

Tests

  • test/game-lend-box.test.ts:
    • An eviction keeps the green shard and names neither the red shard nor the one that was running.
    • A job thaws and finishes within the window.
    • A job frozen past the window is requeued as interrupted.
    • An existing assertion changed from ["interrupted"] to ["interrupted", "kept"], since the body now has two keys.
  • test/runner-interrupt-keeps.test.ts:
    • Kept files ride the requeued job.
    • A second stop adds to the first.
    • A stale token keeps nothing.
    • The set is bounded and unsafe paths are dropped.
    • test-shards.ts skips finished files.

Left out

  • CRIU checkpointing, as the issue says.
  • Keeping the passed files of a half-finished shard. Only shards that printed a done (exit 0 line count.
  • A terminal or doc door. The new field belongs to the box agent, not a page or action, so the commit says No door:.

Reused

  • safeFile from src/checks/verify.ts for path validation.
  • The FORGE_CHECK_ONLY handling in test-shards.ts as the pattern for the skip.
  • The existing interruptJob and lend_give paths, extended rather than replaced.
  • I did not run bun scripts/similar.ts.

Try it: bun test test/runner-interrupt-keeps.test.ts test/game-lend-box.test.ts

🤖 Generated with Claude Code

Sign in to join this conversation.

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

Keyboard shortcuts

Docs