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

A test pins leave-to-run: a grant names one head, a new push waits for a new grant, and a grant is never a review #6724

Merged opened this

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

Merged

I added `test/run-grant.test.ts`, which pins leave-to-run on a real proposed pull (`child/kid/one`, with `require_review` on). It and `test/proposal-run.test.ts` pass, and `tsc --noEmit` is clean. The forge's full check has not run yet.

shipped production is serving it deploy e8d1618

opened this

I added test/run-grant.test.ts, which pins leave-to-run on a real proposed pull (child/kid/one, with require_review on). It and test/proposal-run.test.ts pass, and tsc --noEmit is clean. The forge's full check has not run yet.

The tests show:

  • One head per grant: after grantRun on head A, runGrantedAt answers for A and pullMayRun is true for A. After a push to B, pullMayRun is false until B is granted.
  • Granting twice: the second grant keeps one row, moves granted_at and records the second granter. To make the move visible, the test first sets the row's granted_at back to year 2000 and its user_id to a placeholder.
  • Empty oid: grantRun with "" writes nothing, runGrantedAt returns undefined, and the pull may not run.
  • Not a review: a granted head with no review still gets review_required from mergePull, and the review table stays empty.

I also changed src/core/run_grant.ts. grantRun used to insert a row for an empty oid, and only the reader hid it. It now returns early on an empty oid, so no row is written.

I didn't touch src/core/pull_trust.ts. It already behaved as the issue describes, and test/proposal-run.test.ts already covered the grant through the approveToRun action. The new file covers grantRun and runGrantedAt directly.

Closes #6718

commented

I added test/run-grant.test.ts, which pins leave-to-run on a real proposed pull (child/kid/one, with require_review on). It and test/proposal-run.test.ts pass, and tsc --noEmit is clean. The forge's full check has not run yet.

The tests show:

  • One head per grant: after grantRun on head A, runGrantedAt answers for A and pullMayRun is true for A. After a push to B, pullMayRun is false until B is granted.
  • Granting twice: the second grant keeps one row, moves granted_at and records the second granter. To make the move visible, the test first sets the row's granted_at back to year 2000 and its user_id to a placeholder.
  • Empty oid: grantRun with "" writes nothing, runGrantedAt returns undefined, and the pull may not run.
  • Not a review: a granted head with no review still gets review_required from mergePull, and the review table stays empty.

I also changed src/core/run_grant.ts. grantRun used to insert a row for an empty oid, and only the reader hid it. It now returns early on an empty oid, so no row is written.

I didn't touch src/core/pull_trust.ts. It already behaved as the issue describes, and test/proposal-run.test.ts already covered the grant through the approveToRun action. The new file covers grantRun and runGrantedAt directly.

Approved

Clean. I read every changed line. The only source change is an early return for an empty oid in grantRun. It is defence in depth: approveToRun already refuses an empty head, and the guard now keeps a stray row from being written rather than relying on the reader to hide it. There is no new input surface, the SQL is parameterised, and no door changes, so the terminal and README parity points do not apply.

The new test/run-grant.test.ts covers every point in #6718 on a real proposed pull with require_review on:

  • a grant names one head, and a push waits for a new grant
  • granting twice keeps one row and moves granted_at and the granter
  • an empty oid is never granted (this test fails without the guard)
  • a grant is not a review: mergePull still answers review_required and the review table stays empty

At c1f31e8 I ran it with test/proposal-run.test.ts: 11 pass, 0 fail. The preview answers / with 200. The pull is small and single-purpose and adds no dependency.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs