Public: anyone can read this; the crew can change it.
Revert "Reviewer still never answers: #16009 'review failed to start' 13h, #15694 sil…" #16284
Check · Review · Land · Live — It conflicts with its base.
revert-16227 → main 1 commit
3 files
changed +2
−42
docs/features/review-failed-start.md −4
| @@ -34,7 +34,3 @@ head. The pull waits for you either way; nothing lands on its own. | ||
| 34 | 34 | The summaries `failedAtStart` reads are written from shared constants |
| 35 | 35 | (`BUDGET_PREFIX`, `NOT_REVIEWED_PREFIX`, `SEALED_FETCH_PREFIX`), and a test |
| 36 | 36 | holds the runner to them. |
| 37 | ||
| 38 | ## A review the shell refused (#16214) | |
| 39 | ||
| 40 | Some reviews ran, read the pull, and were never posted: the reviewer's post command carried the review's words (a heredoc, or a quoted body that mentioned `rm`), and the shell's permission check refused it, so the run ended "reviewed: no verdict was posted" (#15694). The review brief now has the reviewer write its JSON with the Write tool to `review.json` and post it with a fixed `curl … --data-binary @review.json`, so no prose reaches the shell (`test/review-post-file.test.ts`). |
src/crew/brief.ts +2 −3
| @@ -617,9 +617,8 @@ function taskBody(input: TaskInput): string { | ||
| 617 | 617 | "", |
| 618 | 618 | ...roundLines(input.reviews.filter((r) => r.authorName === me)), |
| 619 | 619 | "", |
| 620 | "Then submit exactly one review through the forge's API — the verdict and its line comments in one call — and stop. The review's words never go in the shell command: the shell's permission check refuses a command that carries prose (a heredoc, a quoted body that mentions `rm`, `$(`), and a review it refuses is never posted (#16214). Write the JSON with the Write tool to `review.json` in your working directory (its absolute path is `pwd`'s), then post that file:", | |
| 621 | ` review.json: {"state":"approved","body":"...","comments":[{"path":"src/x.ts","line":12,"side":"new","body":"..."}]${input.boxes !== undefined && input.boxes.length > 0 ? ',"ticks":[{"issue":N,"box":1,"text":"the box as listed"}],"left":[{"issue":N,"box":2,"text":"the box as listed","why":"..."}]' : ""}}`, | |
| 622 | ` curl -sS -X POST -H "authorization: Bearer $FORGE_TOKEN" -H "content-type: application/json" "$FORGE_URL/api/v1/repos/${input.repo.ownerName}/${input.repo.name}/pulls/${issue.number}/review-states" --data-binary @review.json`, | |
| 620 | "Then submit exactly one review through the forge's API — the verdict and its line comments in one call — and stop:", | |
| 621 | ` curl -sS -X POST -H "authorization: Bearer $FORGE_TOKEN" -H "content-type: application/json" "$FORGE_URL/api/v1/repos/${input.repo.ownerName}/${input.repo.name}/pulls/${issue.number}/review-states" -d '{"state":"approved","body":"...","comments":[{"path":"src/x.ts","line":12,"side":"new","body":"..."}]${input.boxes !== undefined && input.boxes.length > 0 ? ',"ticks":[{"issue":N,"box":1,"text":"the box as listed"}],"left":[{"issue":N,"box":2,"text":"the box as listed","why":"..."}]' : ""}}'`, | |
| 623 | 622 | `"comments" is optional. Each anchors to a line of the diff below: "path" is the file, "side" is "new" for an added or kept line (numbered as in the head) or "old" for a removed one (numbered as in the base), and "line" counts from the hunk header — in \`@@ -a,b +c,d @@\` the hunk's first line is c on the new side. If the API answers \`bad_anchor\`, nothing was posted: read its message, fix the anchors, and send the review once more; if it is refused again, send it without "comments" and put those points in the body.`, |
| 624 | 623 | `Approve when it does what the direction asks, works in the preview, and looks right. Otherwise use "changes_requested" with a body a builder can act on: what does not work, and the one thing to fix first, concrete. You get ${REVIEW_ROUNDS} rounds of changes on a pull; after that it lands as it is, so if something is left, open an issue for it with the API instead. One review, then stop; your last message is not read by anyone.`, |
| 625 | 624 | "", |
test/review-post-file.test.ts deleted −35
| @@ -1,35 +0,0 @@ | ||
| 1 | /** | |
| 2 | * #16214: a reviewer whose post command carried its prose (a heredoc, a quoted body) had the | |
| 3 | * command refused by the shell's permission check and never posted: #15694's reviews ended | |
| 4 | * "no verdict was posted". The brief keeps the words out of the shell: Write tool, then a fixed | |
| 5 | * curl. | |
| 6 | */ | |
| 7 | import { expect, test } from "bun:test"; | |
| 8 | import { taskPrompt } from "../src/crew/brief.ts"; | |
| 9 | ||
| 10 | const prompt = taskPrompt({ | |
| 11 | agent: { user: { username: "rev", displayName: "" } }, | |
| 12 | repo: { ownerName: "alice", name: "notes", autonomyDirection: "" }, | |
| 13 | issue: { number: 7, title: "Widen", body: "" }, | |
| 14 | branch: "rev/7", | |
| 15 | forgeUrl: "http://forge.test", | |
| 16 | isApp: true, | |
| 17 | resuming: false, | |
| 18 | reason: "review", | |
| 19 | comments: [], | |
| 20 | reviews: [], | |
| 21 | reviewDiff: "", | |
| 22 | } as unknown as Parameters<typeof taskPrompt>[0]); | |
| 23 | ||
| 24 | test("the review is written to a file with the Write tool and posted from it", () => { | |
| 25 | expect(prompt).toContain("Write tool"); | |
| 26 | expect(prompt).toContain("--data-binary @review.json"); | |
| 27 | expect(prompt).toContain("/pulls/7/review-states"); | |
| 28 | }); | |
| 29 | ||
| 30 | test("no shell command in the brief carries the review's words", () => { | |
| 31 | const post = prompt.split("\n").filter((l) => l.includes("curl") && l.includes("review-states")); | |
| 32 | expect(post.length).toBe(1); | |
| 33 | expect(post[0]).not.toMatch(/ -d /); | |
| 34 | expect(post[0]).not.toContain("<<"); | |
| 35 | }); |
new above
offline