Repository navigation
feat: add fetch_pr_review_context tool to review-dispatch plugin - #697
Conversation
Proposal, design, specs, and tasks for a new fetch_pr_review_context tool in the review-dispatch plugin that combines Steps 0-3.5 of review commands into one deterministic tool call, eliminating ~15-20s of LLM think time per review session.
- Implement deterministic PR context fetch: metadata, CI checks, diff (0o600 temp file), reviews, inline comments, derived fields - Use Bun.spawn with argument arrays for shell injection resistance - Add comprehensive test suite (fetch-pr-review-context.test.ts) - Update OpenSpec design to document Bun.spawn decision - Sync scaffold asset copy and register tool in plugin - Add CHANGELOG entry and Dewey learnings Assisted-by: mimo-v2.6-pro Generated with AI assistance (mimo-v2.6-pro)
jflowers
left a comment
There was a problem hiding this comment.
PR Review: #697 — feat: add fetch_pr_review_context tool to review-dispatch plugin
Summary
This PR adds a fetch_pr_review_context tool that consolidates 5+ sequential gh CLI calls into one deterministic fetch. The implementation uses Bun.spawn with argument arrays for shell injection resistance, persists diffs to $TMPDIR/opencode/pr-<number>-diff.patch with O_EXCL + 0o600, and includes comprehensive error handling with structured warnings. The test suite (1053 lines) covers happy paths, error modes, and concurrency.
Verdict: APPROVE WITH ADVISORIES — Two medium-severity advisories and five low-severity observations. None block merge.
Dispatch Provenance
| Agent | Verdict |
|---|---|
| divisor-adversary | APPROVE WITH ADVISORIES |
| divisor-architect | APPROVE WITH ADVISORIES |
| divisor-curator | APPROVE |
| divisor-guard | APPROVE WITH ADVISORIES |
Findings
Security
- MEDIUM —
$TMPDIR/opencode/parent dir created withmkdir({recursive:true, mode:0o700})does not enforce 0o700 on an already-existing directory. On macOS,open('wx')does not implyO_NOFOLLOW, so a symlink race is theoretically possible betweenunlink()andopen('wx'). Blast radius limited since diff content is non-secret PR data. (.opencode/plugins/review-dispatch/index.ts) - LOW —
runGhCommandreads stdout/stderr without size limits. Time-bounded by 30sAbortSignal.timeoutbut not size-bounded. Practical risk negligible. (.opencode/plugins/review-dispatch/index.ts) - LOW —
JSON.parse(raw)calls lack runtime schema validation. Low risk sinceghCLI has stable JSON output. (.opencode/plugins/review-dispatch/index.ts)
Architecture
- LOW —
warningstyped asstring[]while other arrays useReadonlyArray<T>. (.opencode/plugins/review-dispatch/index.ts)
Alignment — see inline comments
Artifact: e8fb723e-c3f0-4c11-8aa7-b819d3814c71
This review was generated by /uf.review-pr (AI-assisted).
| - [x] 1.2 Implement `fetchPrReviewContext()` function. | ||
| Files: `.opencode/plugins/review-dispatch/index.ts` | ||
| Sub-tasks: | ||
| - [x] 1.2a Validate `gh` CLI availability and auth |
There was a problem hiding this comment.
MEDIUM — intent-drift (divisor-guard)
Sub-task 1.2a references "via BunShell (FR-004)" but the implementation uses Bun.spawn with argument arrays. Sub-task 1.2h references partial_failure error code which was replaced by graceful degradation with warnings. design.md was correctly updated with a "Design evolution note" but tasks.md was not updated to match.
This is a spec artifact drift — when design decision D2 evolved during implementation, the update propagated to design.md and the spec but not to tasks.md.
|
|
||
| ### III. Observable Quality | ||
| **Assessment**: PASS — Returns machine-parseable JSON with | ||
| all fields typed. Diff saved to inspectable file on disk. |
There was a problem hiding this comment.
LOW — intent-drift (divisor-guard)
The "Testability" section states "BunShell calls are injectable" but the implementation uses Bun.spawn, not BunShell. Minor documentation inconsistency — the proposal was written before design decision D2 evolved.
|
|
||
| // ── Test infrastructure ────────────────────────────────────── | ||
|
|
||
| type BunRuntime = { |
There was a problem hiding this comment.
LOW — convention-consistency (divisor-architect)
originalBunSpawn is declared at module scope but never used — appears to be a leftover from an earlier test approach where Bun.spawn was saved/restored globally. The current pattern uses per-test restore() closures instead. Consider removing this unused declaration.
Summary
Add a new
fetch_pr_review_contexttool to the review-dispatchplugin that consolidates 5+ sequential
ghCLI calls into onedeterministic fetch. The tool retrieves PR metadata, CI checks,
the full diff (persisted to disk with 0o600 permissions),
existing reviews, inline comments, and pre-computed derived
fields — reducing review dispatch latency and eliminating shell
injection risk via Bun.spawn argument arrays.
How to Test
readable file
ghCLI returnsgh_not_founderror$TMPDIR/opencode/pr-<number>-diff.patchwith
0o600pr_not_founderrorHow to Demo
fetch_pr_review_contextwith the PRnumber
and SHAs, files list, diff path, CI checks, existing reviews,
and inline comments
diff_pathwith0o600permissionsKey Files Changed
.opencode/plugins/review-dispatch/index.tsfetch_pr_review_contexttool implementation (Bun.spawn, structured errors, threshold detection).opencode/test/fetch-pr-review-context.test.tsinternal/scaffold/assets/opencode/plugins/review-dispatch/index.tsopenspec/changes/fetch-pr-review-context/CHANGELOG.md.opencode/test/plugin-integration.test.ts.opencode/test/scratch-smoke.test.ts.gitignore.uf/dewey/learnings/*.mdThis PR was generated by /uf.finale (AI-assisted).