Skip to content

fix(pr-review): a pull request session reads its own repository - #2478

Merged
Makisuo merged 2 commits into
mainfrom
sec/pr-session-repository-scope
Nov 10, 2026
Merged

Makisuo merged 2 commits into
mainfrom
sec/pr-session-repository-scope

fix(pr-review): fail a pass whose pull request cannot be read, refuse…

8896f53
Select commit
Loading
Failed to load commit list.
Maple Review Bot / Maple / review succeeded Nov 10, 2026 in 1m 26s

Confidence 8/10 · No issues found

🟢 Confidence 8/10 · likely safe to merge. Pinning and withholding are pinned by tests; the untested piece is the new unreadable fail-fast in turn-runner, whose reply-row write drops the reason.
1 note · tests partial −1 · risk high −1 · 1/1 new units observable

A review or reply session now pins every repository-naming tool to its own pull request's repository, withholds those tools when it cannot be read, and fails an unattended pass instead of running unpinned. The scope change holds; one copy defect on the reply path.

  • buildChatToolkit overwrites repository for the six repository tools and withholds them when the scope is unreadable
  • turn-runner resolves replyTarget and fails an unattended pass whose pull request cannot be read
  • list_source_repositories leaves the reviewer's ruleset and joins the code-mode tool set
  • search_source_code rejects a path containing whitespace, closing the qualifier-injection vector

Findings

🔵 Note · F1 · Reply row loses the unreadable-pull-request reason in failUnfinished

correctness · apps/ai/src/chat/turn-runner.ts:409

failUnfinished's second argument is read only for an investigation: a reply row is settled with NO_REPLY_ERROR and its comment falls back to "Mention me again to retry" (autonomous-settle.ts:86, PrReviewConversationService.ts:859). An autonomous reply whose pull request cannot be read therefore records and posts the wrong cause, and asks for a retry that fails the same way.

Give `UnfinishedRows.failReply` the message argument that `failInvestigation` has, and pass `PULL_REQUEST_UNREADABLE` as the reply row's `error` and as its posted notice.

Production impact

Production traffic of the changed files (last 7 days)
File Calls/day Busiest operations
packages/backend/src/services/pr-review/PrReviewConversationService.ts 28 PrReviewConversationService.post 28/day, 0.0% err
What was checked
  • A run_code program cannot reach a withheld tool: codeTools is filtered from maple.toolkit.tools (run.ts:198)
  • All four sandbox_* tools and both source tools take a repository parameter, so REPOSITORY_TOOLS covers every reviewer tool that names one
  • path reaches GitHub as a path: and filename: qualifier (GithubAppClient.ts:2138), so the whitespace refusal is the right guard; splitSearchPath derives both from the checked string
Observability coverage: 1 of 1 changes observable
Change Kind Observable Evidence
PrReviewConversationService.replyTarget (reply row + repository read per reply turn) database read yes Effect.fn("PrReviewConversationService.replyTarget") span, PrReviewConversationService.ts:314

8896f53 · Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.

Annotations

Check notice on line 409 in apps/ai/src/chat/turn-runner.ts

See this annotation in the file changed.

@maple-review-bot maple-review-bot / Maple / review

correctness: Reply row loses the unreadable-pull-request reason in `failUnfinished`

`failUnfinished`'s second argument is read only for an investigation: a reply row is settled with `NO_REPLY_ERROR` and its comment falls back to "Mention me again to retry" (`autonomous-settle.ts:86`, `PrReviewConversationService.ts:859`). An autonomous reply whose pull request cannot be read therefore records and posts the wrong cause, and asks for a retry that fails the same way.