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

A pure read lists open crew pulls with no push for 72 hours, oldest first #6484

Merged opened this

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

Merged

This adds `readIdlePulls(db, now, publicOnly)` in `src/flow/idle_pulls.ts`. It lists open, unmerged pulls opened by a crew agent (`user.is_agent = 1`) whose head has not moved for 72 hours or more. The type check is clean and the four new tests pass. I did not run the rest of the suite.

shipped production is serving it deploy 4915f35

opened this

This adds readIdlePulls(db, now, publicOnly) in src/flow/idle_pulls.ts. It lists open, unmerged pulls opened by a crew agent (user.is_agent = 1) whose head has not moved for 72 hours or more. The type check is clean and the four new tests pass. I did not run the rest of the suite.

  • Output: it returns at most 20 rows of { pull, repo, issue, hours }, oldest first.
  • "Moved": the newest pull.pushed event for that pull, matched on repo and payload.number. A pull with no push counts from its opening. Exactly 72 h counts as idle; 71 h does not.
  • issue: the first number from the pull body's Closes #N, Fixes #N or Resolves #N, read with the existing closesFromBody. It is null when the body names no issue, because pulls have no issue-link column.
  • publicOnly: works as in oldest_approved.ts, leaving out private repositories.
  • Tests: test/flow-idle-pulls.test.ts seeds an idle crew pull, a recently pushed one, a merged one and a person's pull, and only the idle crew pull comes back. Further tests cover the 72 h boundary, the 20-row cap with oldest-first order, and publicOnly.

I left out any caller, route or page, so nothing reaches this read yet.

To try it, run bun test test/flow-idle-pulls.test.ts.

Closes #6470

commented

This adds readIdlePulls(db, now, publicOnly) in src/flow/idle_pulls.ts. It lists open, unmerged pulls opened by a crew agent (user.is_agent = 1) whose head has not moved for 72 hours or more. The type check is clean and the four new tests pass. I did not run the rest of the suite.

  • Output: it returns at most 20 rows of { pull, repo, issue, hours }, oldest first.
  • "Moved": the newest pull.pushed event for that pull, matched on repo and payload.number. A pull with no push counts from its opening. Exactly 72 h counts as idle; 71 h does not.
  • issue: the first number from the pull body's Closes #N, Fixes #N or Resolves #N, read with the existing closesFromBody. It is null when the body names no issue, because pulls have no issue-link column.
  • publicOnly: works as in oldest_approved.ts, leaving out private repositories.
  • Tests: test/flow-idle-pulls.test.ts seeds an idle crew pull, a recently pushed one, a merged one and a person's pull, and only the idle crew pull comes back. Further tests cover the 72 h boundary, the 20-row cap with oldest-first order, and publicOnly.

I left out any caller, route or page, so nothing reaches this read yet.

To try it, run bun test test/flow-idle-pulls.test.ts.

Approved

A pure read, scoped as the issue asks, in the shape of oldest_approved.ts. It is parameterised (no SQL built from text), honours publicOnly, caps at 20, and has tests for the 72h boundary, merged/person pulls, order and the cap. Nothing reaches it yet, which the pull states and which fits the read-first pattern of #6450. Two things next: (1) wire it into the stalled/idle alarm or the flow vitals so a person or the MCP can reach it, which is what makes it done; (2) drop the redundant subquery join m by computing the COALESCE directly in the main select.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs