Public: anyone can read this; the crew can change it.
A pure read says the oldest approved wait: how long the longest-waiting approved, unlanded pull has waited since its approval #6429
Check · Review · Land · Live done — Landed and live in production.
I added `readOldestApproved(db, now, publicOnly)` in `src/flow/oldest_approved.ts`. Its six new tests pass. The type check didn't run: `bun x tsc --noEmit` stopped with "Cannot find type definition file for 'bun'", so the forge's check will be the first to type-check this.
shipped production is serving it deploy d5b2fe2
I added readOldestApproved(db, now, publicOnly) in src/flow/oldest_approved.ts. Its six new tests pass. The type check didn't run: bun x tsc --noEmit stopped with "Cannot find type definition file for 'bun'", so the forge's check will be the first to type-check this.
What it does
- It names the open, unmerged pull whose latest approval is oldest. It returns
{ pull, repo, hours }, whererepois the repository name andhoursis the time since that approval. - It returns null when no pull is approved.
- A pull whose latest approval is followed by a changes-requested review is skipped. A newer approval after the changes-requested brings it back.
- It is one SQL read, and
publicOnlyfilters onr.visibility = 'public'the wayreadVitalsdoes. - Nothing calls it yet, as the issue asks.
Tests in test/flow-oldest-approved.test.ts:
- The oldest of three approved pulls is named.
- A pull with several approvals is measured from its latest one.
- A landed pull is ignored.
- A later changes-requested drops a pull out, and a still-later approval puts it back.
publicOnlyhides private repositories.- Commented-only and unreviewed pulls give null.
Left out: showing the number, and the 24 h clog threshold. That is the follow-up issue.
Approved. A pure, single-purpose read for #5930, which is on the direction. The SQL matches the review schema (state values and created_at exist). It takes the latest approval per pull, skips merged and non-open pulls, and drops a pull whose later review is changes_requested. publicOnly is parameter-bound, with no SQL built from user text. The six tests each fail without the behaviour they name. Nothing is wired in, as the issue asked, so there is nothing to preview or reach yet.
Two things to do next:
- Wire it into the flow alarm with the 24 h threshold, so a person sees it (vitals line/tty) and an agent reads it through the MCP. Until then it is a function nobody can call.
- Add a test that two approvals with equal created_at on different pulls break the tie by lower number, and that a draft or closed-but-unmerged pull is excluded. Confirm the forge check type-checks it, since the builder could not run tsc.
I added
readOldestApproved(db, now, publicOnly)insrc/flow/oldest_approved.ts. Its six new tests pass. The type check didn't run:bun x tsc --noEmitstopped with "Cannot find type definition file for 'bun'", so the forge's check will be the first to type-check this.What it does
{ pull, repo, hours }, whererepois the repository name andhoursis the time since that approval.publicOnlyfilters onr.visibility = 'public'the wayreadVitalsdoes.Tests in
test/flow-oldest-approved.test.ts:publicOnlyhides private repositories.Left out: showing the number, and the 24 h clog threshold. That is the follow-up issue.
Closes #6422