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

On a 1-CPU forge a look waits while a crew run is working, and is taken after it ends #11724

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

On a 1-CPU forge the looks service now takes no look while a crew run is active. The waiting look is taken on the first sweep after the run ends.

shipped production is serving it deploy eb2664b

opened this

On a 1-CPU forge the looks service now takes no look while a crew run is active. The waiting look is taken on the first sweep after the run ends.

  • The hold: in src/looks/service.ts, the drain loop checks crewHoldsCore(cpus(), activeCrewRuns()) before each look. When it is true, the look goes back to the front of the queue, so its place is kept, and the loop stops. Every sweep now restarts the loop first, so a held look is picked up once the run is gone. src/looks/capture.ts and its Gate(1) are untouched.
  • Injection: LooksOptions gains cpus and activeCrewRuns. They default to forgeCpus() and listActive(db, "agent").length.
  • Tests: the new test/looks-one-core.test.ts covers three cases. With 1 CPU and an active run, two sweeps take no look. When the run ends, the next sweep takes it. With 2 CPUs and an active run, the look is taken at once. The 1-CPU test fails with service.ts stashed. The 2-CPU test passes without the change, as expected, since it checks the hold doesn't apply with two cores. It uses a real production deploy and a fake capture, so it needs no chromium and no crew loop.
  • Allow-list: I removed src/core/one_core.ts from scripts/unreached-allow.json.

bun x tsc --noEmit is clean and test/looks-one-core.test.ts passes in the sandbox. bun scripts/gate.ts printed no output, and I didn't check its exit code.

test/looks.test.ts has 3 failures in the sandbox because the real chromium can't start here (socket() failed: Operation not permitted). They fail the same way on the base commit, and I edited no existing tests.

I didn't touch checks or snapshots.

Closes #11598

commented

On a 1-CPU forge the looks service now takes no look while a crew run is active. The waiting look is taken on the first sweep after the run ends.

  • The hold: in src/looks/service.ts, the drain loop checks crewHoldsCore(cpus(), activeCrewRuns()) before each look. When it is true, the look goes back to the front of the queue, so its place is kept, and the loop stops. Every sweep now restarts the loop first, so a held look is picked up once the run is gone. src/looks/capture.ts and its Gate(1) are untouched.
  • Injection: LooksOptions gains cpus and activeCrewRuns. They default to forgeCpus() and listActive(db, "agent").length.
  • Tests: the new test/looks-one-core.test.ts covers three cases. With 1 CPU and an active run, two sweeps take no look. When the run ends, the next sweep takes it. With 2 CPUs and an active run, the look is taken at once. The 1-CPU test fails with service.ts stashed. The 2-CPU test passes without the change, as expected, since it checks the hold doesn't apply with two cores. It uses a real production deploy and a fake capture, so it needs no chromium and no crew loop.
  • Allow-list: I removed src/core/one_core.ts from scripts/unreached-allow.json.

bun x tsc --noEmit is clean and test/looks-one-core.test.ts passes in the sandbox. bun scripts/gate.ts printed no output, and I didn't check its exit code.

test/looks.test.ts has 3 failures in the sandbox because the real chromium can't start here (socket() failed: Operation not permitted). They fail the same way on the base commit, and I edited no existing tests.

I didn't touch checks or snapshots.

commented

I merged main into the branch and pushed; the only conflict was scripts/unreached-allow.json.

main had dropped src/apps/cpu_rule.ts from the list, and this branch had dropped src/core/one_core.ts. I kept both removals, so the list now holds only page_budget.ts, page_budget_read.ts, pod.ts and qr.ts.

After the merge, bun scripts/gate.ts printed nothing, bun x tsc --noEmit was clean, and test/looks-one-core.test.ts passes (2 tests). I did not re-run test/looks.test.ts after the merge. The forge's check will run the full suite on this push.

Approved

The hold is correct and small: the drain loop puts a held look back at the front of the queue, and each sweep restarts the loop. CPU and run counts are injectable, the test is in-process, and the preview answers / with 200. Two things I would do next: (1) the MAX_WAIT_MS drop check runs after the hold check, so a look held for a long crew run is dropped only once the run ends, and the first sweep after a long run may drop it instead of taking it. Decide whether the wait budget should pause while held, and add a test. (2) The 2-CPU test passes without the change; it is a control, which is fine, but name it that in the test title. Also check the exit code of bun scripts/gate.ts, not just its output.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs