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

The forge computes the "idle crew" flow alarm (#5930) #6363

Merged opened this

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

Merged

The forge now computes the idle-crew alarm in `src/flow/alarm_idle_crew.ts`. Nothing draws it yet, as the issue asked. The five new tests pass and `bun x tsc --noEmit` is clean; I did not run the rest of the suite.

shipped production is serving it deploy e209d31

opened this

The forge now computes the idle-crew alarm in src/flow/alarm_idle_crew.ts. Nothing draws it yet, as the issue asked. The five new tests pass and bun x tsc --noEmit is clean; I did not run the rest of the suite.

What changed

  • alarmIdleCrew(db, now, { ceilingUsd }) returns { fired, since?, says }. The ceiling is an argument because the forge-wide cap lives in app config, not in the database.
  • It fires when all three hold:

- Ready work: at least one issue is ready, counted by the flow page's own "Ready" stage. - Under the ceiling: today's crew spend has not reached the forge cap, using the same rule that pauses builders. - 15 minutes idle: no agent run has started for 15 minutes or more.

  • since is when the last agent run started. says is one sentence, for example "2 issues are ready and no crew run has started for 16m."
  • When it does not fire, says gives the reason: nothing ready, ceiling reached, or a run started recently.
  • test/flow-alarm-idle-crew.test.ts covers:

- fires with the last run 16 minutes ago; - does not fire with a run 14 minutes ago, with no ready work, or with the ceiling reached; - fires when the ceiling is higher than today's spend.

now is passed in, so no test depends on the wall clock.

Left out

  • No banner, page, MCP tool or route; those are the separate issue.
  • With no agent run on record, the idle time counts from when the oldest ready issue began waiting.
  • I changed no other file, so the four alarms can land in parallel.

Try it Run bun test test/flow-alarm-idle-crew.test.ts.

🤖 Generated with Claude Code

Closes #6344

commented

The forge now computes the idle-crew alarm in src/flow/alarm_idle_crew.ts. Nothing draws it yet, as the issue asked. The five new tests pass and bun x tsc --noEmit is clean; I did not run the rest of the suite.

What changed

  • alarmIdleCrew(db, now, { ceilingUsd }) returns { fired, since?, says }. The ceiling is an argument because the forge-wide cap lives in app config, not in the database.
  • It fires when all three hold:

- Ready work: at least one issue is ready, counted by the flow page's own "Ready" stage. - Under the ceiling: today's crew spend has not reached the forge cap, using the same rule that pauses builders. - 15 minutes idle: no agent run has started for 15 minutes or more.

  • since is when the last agent run started. says is one sentence, for example "2 issues are ready and no crew run has started for 16m."
  • When it does not fire, says gives the reason: nothing ready, ceiling reached, or a run started recently.
  • test/flow-alarm-idle-crew.test.ts covers:

- fires with the last run 16 minutes ago; - does not fire with a run 14 minutes ago, with no ready work, or with the ceiling reached; - fires when the ceiling is higher than today's spend.

now is passed in, so no test depends on the wall clock.

Left out

  • No banner, page, MCP tool or route; those are the separate issue.
  • With no agent run on record, the idle time counts from when the oldest ready issue began waiting.
  • I changed no other file, so the four alarms can land in parallel.

Try it Run bun test test/flow-alarm-idle-crew.test.ts.

🤖 Generated with Claude Code

Approved

Approved. Pure function, now is passed in, reuses readPipeline, ceilingReached, spentTodayEverywhere and span, touches no other file, adds no dependency, and has five tests covering fire, near-miss, no work and ceiling. It is on-direction (#5930, flow alarm). Nothing draws it yet, as the issue asked, so no page, tty or MCP door applies. Next: (1) the query counts a queued run that has not started (COALESCE(started_at, created_at)) as a start, so a stuck queued run silences the alarm; consider started_at only, with a test. (2) Wire it to the flow page and tty in the follow-up issue so it is reachable.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs