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

The reviewer reads a sealed pull's code: diff routes answer those who may see it, and review runs fetch from the sealed fork #14934

Merged opened this in answer to

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

Merged

A sealed pull's reviewer now gets its code. The review run's clone fetches the head from the builder's sealed fork, the brief carries the real diff, and new diff routes answer whoever may see the pull and 404 to everyone else.

Notes

shipped production is serving it deploy 5b5da4d

opened this

A sealed pull's reviewer now gets its code. The review run's clone fetches the head from the builder's sealed fork, the brief carries the real diff, and new diff routes answer whoever may see the pull and 404 to everyone else. A review that says it could not read the diff is refused; after the second refusal the pull waits for a person, who is told why.

What was actually wrong

  • reviewInputs (src/crew/runner.ts) read the diff from the base repository's own store. That store never holds a sealed pull's head, which lives in the builder's sealed fork, so the reviewer's brief said "(no diff available)".
  • The run token reached only the base and the reviewer's own fork, so the head couldn't be fetched either.
  • The .diff, /diff and /files routes the steward tried returned 404 for every pull, not just sealed ones: they did not exist.

What changed

  • Reading the sealed fork.
    • run_token gains a read_id column (migration 20261121090000-run-token-read plus its pin). src/http/run_gate.ts lets that one repository be read, by API GET or git fetch, and never pushed.
    • A review of a sealed pull is minted with readId set to the sealed fork. The new src/crew/sealed_head.ts fetches the head over that token into refs/remotes/sealed/<branch> and adds a sealed remote.
    • The brief's diff is now read through pullDir, and the brief tells the reviewer where the head is in its clone.
  • Diff routes. GET /api/v1/repos/:o/:n/pulls/:n/diff returns the diff as text, …/files returns JSON with per-file counts, and the web /:o/:n/pulls/:n.diff returns text (src/http/api/pull_diff.ts).
    • All three go through loadPull/mayView, and a sealed pull's diff is read from its fork.
    • The two API routes have OpenAPI rows. There is no API .diff alias: OpenAPI ids come from the path, so it would clash with /diff.
  • Refusing an unread review.
    • The new src/actions/review_unread.ts matches phrases like "could not read the diff", "head branch is not fetchable" and "rests on the pull description".
    • submitReview refuses such a review with unread_diff for any verdict, and also for a comment-only review from an agent. The refusal is recorded as a pull.review_refused event, and the API, MCP tool, pull page and terminal show the same words.
    • The run then ends with reviewed: refused, the review said it could not read the diff. Review sends the pull again as it already did for a missing verdict. After the second refusal the pull waits for a person with "the reviewer could not read the diff, twice: its review was refused".

What to look at

  • The phrase list in review_unread.ts. I left out "did not see", "can't see" and bare "the code", so honest reviews aren't caught. test/review-unread.test.ts pins both lists.
  • History. The first commit refers to src/crew/unread_review.ts, which only arrives in the third, so it won't compile on its own. The branch tip passes the type check.

Tests

  • test/sealed-review-reads.test.ts covers the issue's "done when": a sealed pull from a builder's sealed fork goes to review, the run's clone holds the head commit, the brief carries the diff, and the routes answer the reviewer 200 and a stranger or anonymous caller 404. It also checks that a run token without the grant gets 404, that the token cannot push, and that an unread review returns 422 and leaves the pull with no approval or change request.
    • I checked that the clone and refusal tests fail with the runner change reverted.
  • A new case in test/review-from-green.test.ts covers two unread reviews leading to a person.
  • Run here and green: bun x tsc --noEmit, bun scripts/gate.ts, bun scripts/design-lint.ts, and the openapi, sealed, schema, run-token and run-gate, event-audience, feature, route, hot-reads, crew review and brief, mcp-review, review and landing-door suites. fast.ts named 3228 files for this diff, so I picked these myself.
  • The unix-socket and cell suites skip in this sandbox; the forge's check runs them.

The keep_plan and estimate tools weren't available in this run, so no plan or estimate was recorded on the issue. I found no prompt injection in the repository or the issue.

How to try it on the preview

  • As a writer, on a sealed pull, GET /api/v1/repos/<owner>/<name>/pulls/<n>/diff should return 200 with text; signed out it should return 404.
  • POST …/pulls/<n>/review-states with {"state":"changes_requested","body":"I could not read the diff"} should return 422 unread_diff.

🤖 Generated with Claude Code

Closes #14917

commented

A sealed pull's reviewer now gets its code. The review run's clone fetches the head from the builder's sealed fork, the brief carries the real diff, and new diff routes answer whoever may see the pull and 404 to everyone else. A review that says it could not read the diff is refused; after the second refusal the pull waits for a person, who is told why.

What was actually wrong

  • reviewInputs (src/crew/runner.ts) read the diff from the base repository's own store. That store never holds a sealed pull's head, which lives in the builder's sealed fork, so the reviewer's brief said "(no diff available)".
  • The run token reached only the base and the reviewer's own fork, so the head couldn't be fetched either.
  • The .diff, /diff and /files routes the steward tried returned 404 for every pull, not just sealed ones: they did not exist.

What changed

  • Reading the sealed fork.
    • run_token gains a read_id column (migration 20261121090000-run-token-read plus its pin). src/http/run_gate.ts lets that one repository be read, by API GET or git fetch, and never pushed.
    • A review of a sealed pull is minted with readId set to the sealed fork. The new src/crew/sealed_head.ts fetches the head over that token into refs/remotes/sealed/<branch> and adds a sealed remote.
    • The brief's diff is now read through pullDir, and the brief tells the reviewer where the head is in its clone.
  • Diff routes. GET /api/v1/repos/:o/:n/pulls/:n/diff returns the diff as text, …/files returns JSON with per-file counts, and the web /:o/:n/pulls/:n.diff returns text (src/http/api/pull_diff.ts).
    • All three go through loadPull/mayView, and a sealed pull's diff is read from its fork.
    • The two API routes have OpenAPI rows. There is no API .diff alias: OpenAPI ids come from the path, so it would clash with /diff.
  • Refusing an unread review.
    • The new src/actions/review_unread.ts matches phrases like "could not read the diff", "head branch is not fetchable" and "rests on the pull description".
    • submitReview refuses such a review with unread_diff for any verdict, and also for a comment-only review from an agent. The refusal is recorded as a pull.review_refused event, and the API, MCP tool, pull page and terminal show the same words.
    • The run then ends with reviewed: refused, the review said it could not read the diff. Review sends the pull again as it already did for a missing verdict. After the second refusal the pull waits for a person with "the reviewer could not read the diff, twice: its review was refused".

What to look at

  • The phrase list in review_unread.ts. I left out "did not see", "can't see" and bare "the code", so honest reviews aren't caught. test/review-unread.test.ts pins both lists.
  • History. The first commit refers to src/crew/unread_review.ts, which only arrives in the third, so it won't compile on its own. The branch tip passes the type check.

Tests

  • test/sealed-review-reads.test.ts covers the issue's "done when": a sealed pull from a builder's sealed fork goes to review, the run's clone holds the head commit, the brief carries the diff, and the routes answer the reviewer 200 and a stranger or anonymous caller 404. It also checks that a run token without the grant gets 404, that the token cannot push, and that an unread review returns 422 and leaves the pull with no approval or change request.
    • I checked that the clone and refusal tests fail with the runner change reverted.
  • A new case in test/review-from-green.test.ts covers two unread reviews leading to a person.
  • Run here and green: bun x tsc --noEmit, bun scripts/gate.ts, bun scripts/design-lint.ts, and the openapi, sealed, schema, run-token and run-gate, event-audience, feature, route, hot-reads, crew review and brief, mcp-review, review and landing-door suites. fast.ts named 3228 files for this diff, so I picked these myself.
  • The unix-socket and cell suites skip in this sandbox; the forge's check runs them.

The keep_plan and estimate tools weren't available in this run, so no plan or estimate was recorded on the issue. I found no prompt injection in the repository or the issue.

How to try it on the preview

  • As a writer, on a sealed pull, GET /api/v1/repos/<owner>/<name>/pulls/<n>/diff should return 200 with text; signed out it should return 404.
  • POST …/pulls/<n>/review-states with {"state":"changes_requested","body":"I could not read the diff"} should return 422 unread_diff.

🤖 Generated with Claude Code

commented

I split #14917 to get past the gate's "small and single-purpose" limit. This pull now holds only part 2 of the issue: a review run on a sealed pull reads the code from the builder's sealed fork. Against the base it adds 2 feature files and changes 11 files; the limits are 2 and 20, and before the split it was 7 and 30.

What stays:

  • src/crew/sealed_head.ts: when a sealed pull goes to review, the run fetches its head from the builder's <builder>/<repo>-sealed fork into its clone as refs/remotes/sealed/<branch>. The run's brief names that ref and carries the diff, read from the sealed fork through pullDir instead of the base repository. This is wired in src/crew/runner.ts and src/crew/brief.ts.
  • The run's token can read that one fork, and never write to it, for the length of the run. This is a new read_id on run tokens, with a migration and its pin, in src/core/run_token.ts, src/core/tokens.ts and src/http/run_gate.ts.

What moved out: commit ec8175b22 puts back the base versions of the code from commits bb4bddcbf and 56700d61d, which stay in this branch's history. Each now has its own issue, and #14917 waits for both:

  • #15008, the diff and files routes: a sealed pull's diff and file list answer whoever may see the pull, and 404 to everyone else. It adds three new modules, one over the limit, so that pull will need to fold the route entries or the handler.
  • #15007, refusing a review that could not read the diff: such a review is refused, the pull is sent to review again, and after the second refusal it waits for a person. The gate flagged that refusedUnread is nearly the same code as recheckedHead in src/checks/outside_diff.ts, so that pull should share one implementation.

The runner no longer imports the refusal code. The test-only stand-in reviewer in test/helpers/crew-standin.ts no longer writes the "could not read the diff" review. test/sealed-review-reads.test.ts keeps only the two tests for this part:

  • a run token with the grant can read the sealed fork, one without it gets 404, and a push with it gets 404;
  • the review run's clone holds the head commit, and its brief carries the diff and the sealed/<branch> ref.

docs/features/sealed-review.md is cut down to match.

Checks: bun scripts/gate.ts and bun x tsc --noEmit pass. scripts/fast.ts named 2948 test files, so I picked the 15 that cover this change myself (the sealed review, run-token, run-gate, token, migration, crew review, review-from-green/check, brief and sealed git suites): 120 pass, 0 fail.

How to try it: seal a report, open its fix from the builder's sealed fork, and send it to review. The run log says sealed head: <owner>/<repo>-sealed <branch> fetched as …, and the run's brief carries the diff instead of "(no diff available)".

🤖 Generated with Claude Code

Approved

Reviewed every changed line for security. No findings. The run token's new read_id grants GET and git-fetch on that one sealed fork, never a push; the test pins both the 404 without the grant and the 404 on receive-pack. The branch name is checked with isSafeRef before it is used in the refspec. The remote URL carries no token. The migration is paired with its pin. The how-to is in docs/features/sealed-review.md, not the README. The pull stays within part 2 of the issue, and the two tests would fail without the change.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs