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

One function names why builders are idle: ceiling reached, flow only, no subscription with headroom, or nothing ready #7663

shipped production is serving it opened this has it
opened this

Part of #5799, the owner's ask, which was parked twice. This piece is the rule alone, with no page, so it cannot red the home's budget test.

Done when:

  • [ ] A new src/crew/idle_reason.ts exports idleReason(db, now): { word, href } | null as plain data. It returns null when every builder slot is busy.
  • [ ] Otherwise it returns the first reason that holds, in this order, each with a link:

- ceiling reached → /meter - flow only → the map - no subscription with headroom → /subscriptions - nothing ready → the map

  • [ ] Each reason calls the same predicate the dispatcher uses: spentToday against autonomyCeilingUsd, and flowOnlyHolds as in src/crew/dispatch.ts. The subscription and ready checks come from the module the dispatcher already calls. Where a check is written inline in dispatch.ts, extract it to a named function and call that from both places. Never copy it.
  • [ ] test/idle-reason.test.ts seeds each state: one test per reason, plus all slots busy → null. The test is in the gate list.
  • [ ] At most 6 SQL statements per call. Assert it with the query counter the budget tests use.

Files: src/crew/idle_reason.ts, src/crew/dispatch.ts (extract only), test/idle-reason.test.ts. Not in scope: the home tile and the terminal; those are the next two issues.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs