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

An agent run's log says how long the run took to its first push, when its pull opens #5751

Merged opened this

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

Merged

A run's log now gets a `timing: first push …` line when the run's own watcher opens its pull at the first push.

shipped production is serving it deploy ad44386

opened this

A run's log now gets a timing: first push … line when the run's own watcher opens its pull at the first push.

The line reads timing: first push 2.0s after the run started — clone 1.0s · brief 1.0s · harness to first push 0.0s. It comes from the run's Stopwatch, and the end line still closes the log.

What changed

  • src/crew/early.ts: EarlyInput takes an optional onOpened callback. watchForPull calls it once, only after it has opened the pull. A throw is caught and logged as could not write the first-push timing: …, so it never reaches the watcher.
  • src/crew/runner.ts: passes the callback, which writes the line.
  • src/apps/timing.ts: Stopwatch.line takes an optional third argument, running, to name a step still in progress. It shows that step's time so far without taking its lap, so the end line's harness lap is unaffected.
  • test/crew-run-timing.test.ts: a new case holds the stand-in agent after its push and checks for the first-push line before the end line.

Tests

  • I ran test/crew-run-timing.test.ts, test/crew-early.test.ts and the timing tests. All pass.
  • I stashed the src changes and re-ran the timing file: the new test fails without them.
  • bun x tsc --noEmit could not run here (no type definitions for bun), so the forge's check is the first type check.

Left out

  • There is no test for the follow-up case (a run on an existing pull writes no first-push line). It holds by construction: continuing makes the watcher stop before it ever ticks, so the callback is never reached. A test would need a second run on the same pull.
  • If the watcher misses the push and landWork opens the pull at the end of the run, no first-push line is written. That matches "when its pull opens at its first push".

To try it, assign an agent an issue and open its run log. The line sits just above the timing: run ended … line.

Closes #3780

commented

A run's log now gets a timing: first push … line when the run's own watcher opens its pull at the first push.

The line reads timing: first push 2.0s after the run started — clone 1.0s · brief 1.0s · harness to first push 0.0s. It comes from the run's Stopwatch, and the end line still closes the log.

What changed

  • src/crew/early.ts: EarlyInput takes an optional onOpened callback. watchForPull calls it once, only after it has opened the pull. A throw is caught and logged as could not write the first-push timing: …, so it never reaches the watcher.
  • src/crew/runner.ts: passes the callback, which writes the line.
  • src/apps/timing.ts: Stopwatch.line takes an optional third argument, running, to name a step still in progress. It shows that step's time so far without taking its lap, so the end line's harness lap is unaffected.
  • test/crew-run-timing.test.ts: a new case holds the stand-in agent after its push and checks for the first-push line before the end line.

Tests

  • I ran test/crew-run-timing.test.ts, test/crew-early.test.ts and the timing tests. All pass.
  • I stashed the src changes and re-ran the timing file: the new test fails without them.
  • bun x tsc --noEmit could not run here (no type definitions for bun), so the forge's check is the first type check.

Left out

  • There is no test for the follow-up case (a run on an existing pull writes no first-push line). It holds by construction: continuing makes the watcher stop before it ever ticks, so the callback is never reached. A test would need a second run on the same pull.
  • If the watcher misses the push and landWork opens the pull at the end of the run, no first-push line is written. That matches "when its pull opens at its first push".

To try it, assign an agent an issue and open its run log. The line sits just above the timing: run ended … line.

Approved

Small and single-purpose. The first-push line is written only when the run's own watcher opens the pull. A throwing callback is caught and logged. The running argument leaves the harness lap untaken, so the end line is unchanged. The new test would fail without the change, and it checks the line comes before the end line. No input, auth or dependency surface is touched. I read the code only: I did not curl the preview or run the tests here.

Two things I would do next:

  1. Add a test that a continuing run on an existing pull writes no first-push line. It holds by construction today, but nothing pins it.
  2. Decide whether a pull opened at landing, because the watcher missed the push, should also get a line. Otherwise the log gives no timing for those runs.

The poll loop in the test is bounded at 30s. If it ever flakes, replace it with a signal from the stand-in.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs