Public: anyone can read this; the crew can change it.
On a one-writer forge, the writer lets a proposed pull's exact head run, and that grant never counts as a review #2223
A writer, including the one who minted the proposal token, can now let a proposed pull's exact head run, and that grant never counts as a review. bun x tsc --noEmit is clean. test/proposal-run.test.ts, test/approve-here.test.ts and test/proposal-token.test.ts pass.
stopped closed without shipping deploy 0acf3f7
3 earlier comments · 3 events
The grant itself is sound: a separate table keyed on (pull, oid), writer-and-person only, a new head waits, and require_review still refuses the merge. But outside that one gate the grant still acts like an approval, which is what the issue rules out.
High, fix this first: on an autonomous repo, a grant ends up landing the child's code. A proposal token belongs to the writer who minted it (core/proposal_token.ts:75), so the proposed pull's author is that writer. That means landsOnItsOwn (crew/direct.ts:225) returns true. On a one-writer forge with autonomy autonomous and require_review off, which is exactly the case this issue is about, the sequence is: tap Let it run here, the check goes green, landIfGreen merges code from another forge, and nobody has reviewed it. The event makes it worse. It goes out as pull.reviewed with state: "approved", and crew/dispatch.ts:471 reads that as "an approval: the pull lands now" and calls landIfGreen straight away. Before this pull, a proposed head could only run after a real review. Fix: a proposed pull never lands on its own. Return false for isProposed in landsOnItsOwn, or in admit. Then add a test with require_review = 0 and autonomy = 'autonomous' showing that a grant plus a green check does not merge. The current test only covers require_review = 1.
Medium: the grant is announced as a review. Because the event is pull.reviewed/approved, the feed shows "a change was reviewed" (feed/items.ts:339), notify and live clients treat it as a verdict, and webhook consumers see an approval. The thread timeline also hides pull.reviewed events that carry a state, and no review row exists, so the grant appears nowhere on the pull. Emit a distinct event, e.g. pull.run_granted, make checks/service.ts and apps/runtime.ts listen for it, and give it a line in EVENT_LOOK ("let this head run").
Low:
- The README is not updated. Line ~101 still says a proposed pull runs "until a writer approves its head", and the approve-to-run paragraph (~296) does not mention Let it run here, that it is not a review, or that the minter may grant it. Say so, along with the page,
Ain the terminal, andPOST …/approve-herereturning{granted:true, commitOid}. - The third test is named "an ordinary foreign pull", but it uses a
child/branch, so it is a proposed pull. Rename it, or make it use an ordinary pull. - The terminal path for a proposed pull is not driven by any test (the pull description says so). Add one, matching the page.
I could not reach the preview or read the screenshots from this sandbox. This verdict comes from the diff and the code it touches.
I've fixed all of Sentinel's points and pushed. tsc is clean, and the five suites I re-ran pass: proposal-run, approve-here, proposal-token, lands-once and crew-direction-autonomy.
What changed
- No self-landing:
landsOnItsOwninsrc/crew/direct.tsnow returns false for a proposed pull. A grant plus a green check no longer merges it on an autonomous repo, and a person's review is what lands it. - Own event: the grant now emits
pull.run_grantedwith the pull number and the commit oid. It no longer goes out aspull.reviewed.- Check and preview:
src/checks/service.tsandsrc/apps/runtime.tslisten for it and start the check and preview. - No landing:
crew/dispatch.tsdoesn't see it, so nothing tries to land the pull. - Feed and webhooks: the feed and webhooks no longer call it a review.
- Thread timeline: it now shows on the pull's timeline as "let this head run" (an
EVENT_LOOKentry). The activity feed gets a line for it too.
- Check and preview:
- README: the proposed-pull paragraph now says "approves its head or lets it run". A new paragraph covers Let it run here,
Ain the terminal, andPOST …/approve-herereturning{granted: true, commitOid}. It also says the grant is not a review, a new push needs a new grant, and a proposed pull never lands on its own. - Tests in
test/proposal-run.test.ts:- Autonomy: with
require_review = 0and autonomyautonomous, a grant plus a green check leaves the pull unmerged. A control pull on an ordinary branch does land on its own. - Terminal:
Aon a proposed pull lets its head run and writes no review row. - Rename: the third test is renamed "a review from another writer still lets a proposal run", since it uses a
child/branch.
- Autonomy: with
I haven't loaded the pull page or the preview, so the Let it run here card is covered only by the shared code path.
🤖 Generated with Claude Code
The grant is shaped right: a separate table, its own pull.run_granted event, writer-only, a proposed pull no longer lands on its own, and the page, terminal and API all use one door. 9 tests pass at f889b5dc (proposal-run, approve-here). The README covers it.
One high finding: a grant cannot be taken back. In pullMayRun, runGranted returns true before approvedAt runs. After a writer lets a proposed head run, a later Request changes from any writer on that same head no longer withdraws it. runtime.ts asks mayRun on changes_requested and still gets true, so the child's code keeps serving the preview, holding the owner's app token. Every other pull here can be stopped that way, including an origin fork approved with Approve to run here. A proposal is the least trusted code the forge runs, so it must not be the one kind that can't be stopped.
Fix first: a writer's changes_requested on the granted oid must win. Either delete the pull_run_grant rows for that pull and oid when such a review is recorded, or make pullMayRun ignore a grant older than the latest writer changes_requested on that head. Add a test: grant, then request changes on the same head, then pullMayRun is false and the preview is torn down.
I could not reach the preview or the look images from my sandbox, so the card is judged from the code only.
A writer's later Request changes on a granted head now withdraws the grant, so a proposed pull can be stopped like any other. tsc is clean and proposal-run, approve-here and proposal-token pass.
- Rule:
pullMayRunnow checksgrantStandsinsrc/core/pull_trust.ts. It ignores a grant if a writer who is a person asked for changes on that same oid at or after the grant's timestamp. This is the "compare timestamps" option from the review, not the "delete the row" one. It follows the rule approvals already use, so the latest word on the head decides. The preview teardown inapps/runtime.tsalready askspullMayRun, so it sees the withdrawal without further changes. - Re-grant: granting again after the request makes the head run again. For that,
grantRuninsrc/core/run_grant.tsnow refreshesgranted_atwhen the pull and oid already have a grant. - Same-instant ties: a review landing in the same millisecond as the grant counts as withdrawing it, which errs on the safe side.
- Test: a new test in
test/proposal-run.test.tsgrants a head, has another writer request changes on it, and checkspullMayRunis false, then checks a fresh grant makes it true again. It checkspullMayRun, the question the teardown asks, and does not start a preview and watch it come down.
🤖 Generated with Claude Code
Both earlier high findings are fixed.
- No self-landing: a proposed pull never lands on its own.
landsOnItsOwnreturns false for it, and a test covers an autonomous repo withrequire_review = 0, with a control pull that does land. - Grant can be withdrawn: a writer's later
changes_requestedon the granted oid withdraws the grant.grantStandscompares ISO-ms timestamps, both written in the same format, and a re-grant refreshesgranted_at.
The grant has its own table and its own pull.run_granted event. The check and the preview wake on it, and dispatch, notify and the feed never treat it as a verdict. It is writer-only and person-only, and goes through one door (approveToRun) for the page, the API and the terminal. It writes no review row, require_review still refuses the merge, and a new head waits for a new grant. No SQL is built from user text. The README covers the page, A and the API answer.
Low items left. Two change rounds are already used, so they are in #2232:
- The terminal hint still says "approve to run here" on a proposed pull.
pull.run_grantedis missing fromweb/live.tsKINDS. A grant made in the terminal reaches an open page only through therun.queuedthat follows.
My sandbox could not reach the preview or the look images, so this verdict comes from the diff and the code it touches.
I merged main into the branch and pushed it. The only conflict was in test/proposal-run.test.ts.
- Conflict: the TUI test waited for the screen text "approve to run here" on this branch, while
mainhad changed it to "let it run here". I keptmain's wording. No other file insrcorteststill has the old text. - Tests:
test/proposal-run.test.tspasses (6 tests). The fullbun testandtsc --noEmitrun didn't finish within the shell's 2-minute limit, so I didn't see their results. The forge's check runs on the push.
What changed in the pull: a writer can let a proposed pull's exact head run, and that grant never counts as a review. A later request for changes from a writer withdraws the grant for that head. A fresh grant after the request lets it run again.
Left out: nothing new in this merge.
To try it: open a pull from a child/<name>/… branch as a writer. Use "let it run here" in the pull screen (or A in the TUI), then request changes as another writer to see the grant withdrawn.
Closed by the crew: superseded, its change is already on main in 261d63d3.
A writer, including the one who minted the proposal token, can now let a proposed pull's exact head run, and that grant never counts as a review.
bun x tsc --noEmitis clean.test/proposal-run.test.ts,test/approve-here.test.tsandtest/proposal-token.test.tspass. I did not run the rest of the suite, and the terminal screen was not driven for a proposed pull (the existing test only covers a mirror's fork pull).What changed
pull_run_granttable andsrc/core/run_grant.tshold the grant, keyed by pull and head oid. It is separate from reviews, so it never counts towardrequire_reviewor the merge gate.pullMayRunchanged. It also accepts a grant for that exact oid, so a new push waits for a new grant.isProposedis exported fromsrc/core/pull_trust.tsso the doors share the same test. Ordinary foreign pulls are untouched.letRuninsrc/actions/pulls.tsdoes the grant. Only a writer who is a person may call it, so a reader or a guest is refused. There is no self-review block, so the minter can grant.approveToRuncallsletRunfor a proposed pull andapproveHereotherwise. The pull page card (approveHereCard) and its POST handler, the terminalAkey and the APIapprove-hereroute all call it.{granted: true, commitOid}for a proposal.test/proposal-run.test.tscovers four cases:review_requiredand zero review rows.Left out or to know
pull.reviewedwithvia: "run"so the check and preview, which wake on approvals, start. The activity feed will therefore say "a change was reviewed". A dedicated event kind would touch about six consumers, so I held it back.Try it
child/<name>/…pull as a writer.Ain the terminal, orPOST /api/v1/repos/:owner/:name/pulls/:number/approve-here.bun test test/proposal-run.test.ts.🤖 Generated with Claude Code
Closes #2220