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

Flaky test: a jar is checked and in place before the up, readable, and the old AutoStopper is aside #17874

opened this in answer to

Merged 26h 47m ago, live in production

The flake was a real race in src/games/agent.sh, and I've fixed it there rather than in the test. The fix is in queuejob. Cause.

Notes

opened this

The flake was a real race in src/games/agent.sh, and I've fixed it there rather than in the test. The fix is in queue_job.

Cause. queue_job skipped a duplicate up only while the same-sha job was still running. A job that had finished but not yet been reaped could still be queued again, because .compose-sha is only written at the reap. The agent then ran the same compose a second time, and the second job truncated .up.log. The test read an empty log (the failure I reproduced) or, less often, a doubled ups file.

Change. queue_job now treats a job whose .job.pid still exists as in flight. Its reap either makes the sha current or marks it failed, so nothing is lost.

Evidence. Running the test three at a time failed once in my first batch of three, with the empty-log failure. After the fix it passed 12 of 12 in the same setup, and the whole test/game-jars.test.ts file passes (24 tests). I also ran game-agent-exec, game-agent-limits, game-box and game-boot (22 pass), and tsc --noEmit is clean. bun scripts/gate.ts --fix changed nothing.

Not done. I added no new test. The window is a few milliseconds wide, so a test for it would itself be flaky. The existing test now passes where it used to fail. bun scripts/fast.ts named 2669 test files, so I picked the game-agent tests myself and did not run the full suite.

Reused. No new function. I only changed the condition in queue_job.

Closes #17873

commented

The flake was a real race in src/games/agent.sh, and I've fixed it there rather than in the test. The fix is in queue_job.

Cause. queue_job skipped a duplicate up only while the same-sha job was still running. A job that had finished but not yet been reaped could still be queued again, because .compose-sha is only written at the reap. The agent then ran the same compose a second time, and the second job truncated .up.log. The test read an empty log (the failure I reproduced) or, less often, a doubled ups file.

Change. queue_job now treats a job whose .job.pid still exists as in flight. Its reap either makes the sha current or marks it failed, so nothing is lost.

Evidence. Running the test three at a time failed once in my first batch of three, with the empty-log failure. After the fix it passed 12 of 12 in the same setup, and the whole test/game-jars.test.ts file passes (24 tests). I also ran game-agent-exec, game-agent-limits, game-box and game-boot (22 pass), and tsc --noEmit is clean. bun scripts/gate.ts --fix changed nothing.

Not done. I added no new test. The window is a few milliseconds wide, so a test for it would itself be flaky. The existing test now passes where it used to fail. bun scripts/fast.ts named 2669 test files, so I picked the game-agent tests myself and did not run the full suite.

Reused. No new function. I only changed the condition in queue_job.

commented

The flaky test/game-jars.test.ts test came from a race in src/games/agent.sh, and this update adds the deterministic test @juniper asked for.

What changed

  • The fix: queue_job skipped a repeat up only while the same-sha job was still running. A job that had ended but not yet been reaped could be queued a second time, because .compose-sha is only written at the reap. The second run truncated .up.log, which is the empty log the flaky test saw. queue_job now treats a job whose .job.pid is still there as in flight.
  • The test: "an up whose job has ended but is not reaped yet is not queued again; once reaped, it is" builds the state directly, with no timing. It writes .job.pid holding a dead pid, .job.sha=abc and .job.rc=0, then runs the agent's real job_running and queue_job, extracted from agent.sh. .jobs must stay empty. After .job.pid is removed, the same call must queue the up.
  • Checked against the old code: with main's agent.sh restored the test fails. With the fix it passes.

What I checked

  • test/game-jars.test.ts passes, 25 tests including the new one, and tsc --noEmit is clean.
  • Earlier, game-agent-exec, game-agent-limits, game-box and game-boot also passed.
  • I ran bun scripts/gate.ts --fix and it changed nothing. The gate notes one comment line over 100 columns in the test file and says the nightly rewrap handles it on main.
  • I did not run the full suite. scripts/fast.ts named 2669 files, so I picked these tests myself.

Left out: No new function was written; the fix changes one condition in queue_job. This touches no page, action, API route or MCP tool, so there is no terminal or docs/features/ side to change.

Sign in to join this conversation.

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

Keyboard shortcuts

Docs