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

A review's approval is recorded against its head and base; when either moves it reads 'moved since approval' #12548

Merged opened this

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

Merged

Most of #12524 was already on main in fb6f20cea (#12164). That commit added the review.baseoid migration and its pin (20261114070000-review-base), and gave GET …/pulls/:number its approvedAt: { at, head, base, current }. The MCP pulls list also got movedSinceApproval then.

Notes

shipped production is serving it deploy 7612a18

opened this

Most of #12524 was already on main in fb6f20cea (#12164). That commit added the review.base_oid migration and its pin (20261114070000-review-base), and gave GET …/pulls/:number its approvedAt: { at, head, base, current }. The MCP pulls list also got movedSinceApproval then. So this pull adds no migration. What was still missing was the inbox: an approved pull's row never said its approval had gone stale. This pull adds that.

What changed

  • src/core/approval_at.ts (new): movedSinceApproval(reviews, head, base), the one rule for whether a pull moved since its approval. It is true when the latest approval was given on another head or against another base. If the base hasn't been read yet, only the head is compared. Both the inbox and the MCP pull list (src/http/mcp/tools/pulls.ts) now use it; the MCP list's private copy is gone.
  • src/crew/stale_asks.ts: knownBase returns the base tip the stale-asks sweep last read, so the inbox runs no git while answering a request.
  • src/web/studio/asks.ts, decisions.ts: the "look" and "waiting" asks set movedSinceApproval. When it holds, the row line ends ", moved since approval", the card's short line ends " · moved since approval", and the card's longer text says so in one sentence.
  • One review read per request: askCandidatesFor now reads the pulls' reviews once and passes them through reviewWaitsFor to reviewSummariesFor, which gained an optional argument for reviews already read. test/asks-counts.test.ts requires exactly one such read per request, and failed while the new code made a second.
  • docs/features/approval-base.md: a new Inbox line.

What I chose not to do: I didn't change approvedAt to a "head against base" string. Its object already carries both oids, and changing its shape would break existing readers.

Tests: test/approval-moved-inbox.test.ts has unit cases for the rule. It also runs the full path: approve, move main, re-check green on the new main, sweep. The row then goes from "Feat" is green, waiting for your look to …, moved since approval, and /asks shows it. The gate, tsc, design-lint and the covering asks/approval/stale-check/MCP files pass, run one file at a time; run together in one process, several asks files failed and then passed alone. test/ask-to-live-batched.test.ts fails here with or without this change (a 5 s setup timeout in this sandbox). Commit lines say No look: (no app.looks page has an approved pull whose base moved) and give a Try:.

To try it on the preview: approve a pull, land another pull on main, re-run the first pull's check, then open /asks. The row ends "moved since approval", and the MCP pulls tool with repo reports movedSinceApproval: true.

🤖 Generated with Claude Code

Closes #12524

3 earlier comments · 1 event
commented

Most of #12524 was already on main in fb6f20cea (#12164). That commit added the review.base_oid migration and its pin (20261114070000-review-base), and gave GET …/pulls/:number its approvedAt: { at, head, base, current }. The MCP pulls list also got movedSinceApproval then. So this pull adds no migration. What was still missing was the inbox: an approved pull's row never said its approval had gone stale. This pull adds that.

What changed

  • src/core/approval_at.ts (new): movedSinceApproval(reviews, head, base), the one rule for whether a pull moved since its approval. It is true when the latest approval was given on another head or against another base. If the base hasn't been read yet, only the head is compared. Both the inbox and the MCP pull list (src/http/mcp/tools/pulls.ts) now use it; the MCP list's private copy is gone.
  • src/crew/stale_asks.ts: knownBase returns the base tip the stale-asks sweep last read, so the inbox runs no git while answering a request.
  • src/web/studio/asks.ts, decisions.ts: the "look" and "waiting" asks set movedSinceApproval. When it holds, the row line ends ", moved since approval", the card's short line ends " · moved since approval", and the card's longer text says so in one sentence.
  • One review read per request: askCandidatesFor now reads the pulls' reviews once and passes them through reviewWaitsFor to reviewSummariesFor, which gained an optional argument for reviews already read. test/asks-counts.test.ts requires exactly one such read per request, and failed while the new code made a second.
  • docs/features/approval-base.md: a new Inbox line.

What I chose not to do: I didn't change approvedAt to a "head against base" string. Its object already carries both oids, and changing its shape would break existing readers.

Tests: test/approval-moved-inbox.test.ts has unit cases for the rule. It also runs the full path: approve, move main, re-check green on the new main, sweep. The row then goes from "Feat" is green, waiting for your look to …, moved since approval, and /asks shows it. The gate, tsc, design-lint and the covering asks/approval/stale-check/MCP files pass, run one file at a time; run together in one process, several asks files failed and then passed alone. test/ask-to-live-batched.test.ts fails here with or without this change (a 5 s setup timeout in this sandbox). Commit lines say No look: (no app.looks page has an approved pull whose base moved) and give a Try:.

To try it on the preview: approve a pull, land another pull on main, re-run the first pull's check, then open /asks. The row ends "moved since approval", and the MCP pulls tool with repo reports movedSinceApproval: true.

🤖 Generated with Claude Code

commented

When a pull has been approved and its head or base moves afterwards, its inbox row now says "moved since approval" (#12524). Before, the row looked the same as one whose approval still matched the code. It decides by comparing where the head and base are now with where they were when the approval was given.

The logic is in a new module, src/core/approval_at.ts. src/core/reviews.ts, src/crew/review.ts, src/crew/stale_asks.ts and src/http/mcp/tools/pulls.ts now use that shared module where each worked this out on its own before. The label itself appears in src/web/studio/asks.ts and src/web/studio/decisions.ts. test/approval-moved-inbox.test.ts covers rows whose head moved, rows whose base moved, and rows that didn't move.

This push merges current main in. Git merged it without conflicts: the conflicting file, test/deadends.test.ts, came from #12490, and this branch doesn't change it.

The gate and bun x tsc --noEmit pass. scripts/fast.ts found the merge too broad to name tests for, so I picked the ones that cover the change. Across 11 files (dead-end crawl, approvals, review, decisions): 58 pass, 2 skipped, 0 fail.

To try it: approve a pull, push to its head or to main, then open the inbox. The row reads "moved since approval".

🤖 Generated with Claude Code

commented

When a pull has been approved and its head or base moves afterwards, its inbox row now says "moved since approval" (#12524). Before, the row looked the same as one whose approval still matched the code. It decides by comparing where the head and base are now with where they were when the approval was given.

The logic is in a new module, src/core/approval_at.ts. src/core/reviews.ts, src/crew/review.ts, src/crew/stale_asks.ts and src/http/mcp/tools/pulls.ts now use that shared module where each worked this out on its own before. The label itself appears in src/web/studio/asks.ts and src/web/studio/decisions.ts. test/approval-moved-inbox.test.ts covers rows whose head moved, rows whose base moved, and rows that didn't move.

The last check failed in test/pages-budget.test.ts. src/web/studio/asks.ts read the reviews of every pull the inbox looked at on every request, which put /:owner/:name/pulls/:number at 114 SQL statements against a budget of 113 and /api/v1/asks at 63 against 61. Now it reads them once, only for green pulls, and that one read also serves the review-wait check, which used to read them on its own. Idle pulls that were never green get a separate read, only when there are any. Both pages are back within budget, and no budget was raised.

The other failures in that log were:

  • Passing here: test/mcp-parent-unreachable.test.ts, test/tui-screens.test.ts and test/render-subtitles-shift.test.ts pass in this sandbox, so I left them alone.
  • Red on main as well: test/boundary-tenancy-cell.test.ts and test/studio-app-timing.test.ts; the check didn't count them against this pull.

This push also merges the latest main; it merged without conflicts. The gate, bun x tsc --noEmit and bun scripts/design-lint.ts pass. scripts/fast.ts found the merge too broad to name tests for, so I picked the ones that cover the change: the page budget, the review, approval and inbox tests, and the dead-end crawl. All of them pass.

To try it: approve a pull, push to its head or to main, then open the inbox. The row reads "moved since approval".

🤖 Generated with Claude Code

Approved

Clean. One shared rule in src/core/approval_at.ts (MCP list now uses it, private copy removed), no git on the request path (knownBase from the sweep), one review read per request so the page budgets hold, an Inbox line in docs/features/approval-base.md, and an end-to-end test (approve, move main, re-check, sweep, row changes) that fails without the change. The terminal reads the same ask lines, so it gets the wording too. Nits, not blocking: src/http/mcp/tools/pulls.ts now ends with a stray blank line after pile(). Box 2 is only half met: the inbox says moved since approval, but approvedAt stays an object rather than a head-against-base string; keeping it avoids breaking readers, which is a fair call.

commented

Left #12524 open: 1 unticked item remain (Pull JSON carries approvedAt as 'head against base'; the inbox row says 'moved since approval' when either differs.).

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs