Repository navigation
feat(agent): share plan permission set with review subagent - #165
Conversation
|
Automation re-review found one concrete defect before merge:
Required follow-up: keep Plan's exceptions unchanged, make Review's edit rule deny all paths, and add a regression assertion for a plan path plus a normal path. Current CI for |
mdev34-lab
left a comment
There was a problem hiding this comment.
Re-review of head b7ba77857ca78597d40a9ed2d0138bab30939fb7.
Finding: packages/opencode/src/agent/agent.ts:237-248 gives Review the same path-specific edit exceptions as Plan (.opencode/plans/*.md and the global plans path), while packages/opencode/src/agent/prompt/review.txt says Review must not edit, write, create, or delete any files. The generic test evalPerm(review, "edit") === "deny" does not catch those path-sensitive allows.
Required fix: Keep Review's permission block independent, but remove the Plan-only edit exceptions from Review so every edit path remains denied. Add a regression assertion for a path such as .opencode/plans/review.md.
Other reviewed areas looked consistent. CI/status for the current head is still pending with no reported checks yet.
|
@kilocode-bot Get this PR looking good (perform the fixes). Then I'll merge manually. |
Review inherited Plan's plan-path edit exceptions (.opencode/plans/*.md and the global plans path), which contradicts review.txt's directive that Review must not edit, write, create, or delete files. Plan's edit exceptions are unchanged; Review now denies edits on every path. Tests pin a plan path and a normal path as denied for Review while Plan still allows its plan-path edits.
|
Cloud Agent result for mdev34-lab/alphacode (code, agent_cf07ded0-f727-4897-8f1e-c02976ab1e95, completed): Done. Pushed to the existing PR branch Changes (
Verification: Note: this sandbox is missing the optional |
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (6 files)
Reviewed by free · Input: 0 · Output: 0 · Cached: 0 |
|
LGTM. Merging |
Issue #113. The generic `review` subagent is now a request rather than an identity: the task tool resolves which reviewer actually runs from the parent agent, so Work dispatches work-review, Code dispatches code-review, and every other parent keeps the generic reviewer. All three reviewers share one `reviewPermissions` block, extracted from the existing `review` definition, so they keep the plan-equivalent inspection permissions including bash for reproducing and verifying runtime behaviour, with edit denial enforced at the permission seam. The split is domain focus only: the reviewers are identical in capability and in the standard they apply. The report gate requiring every reviewer to deliver a parseable <alphacode-review> envelope is name-based, so reviewer names live in one module (REVIEW_AGENTS for the gate, REVIEW_ROUTING for dispatch) rather than being compared inline at each of the four call sites. A reviewer outside REVIEW_AGENTS still completes without a verdict, which centralising reduces but does not remove. Parent-agent resolution reads the newest user message. MessageV2.page returns oldest-first, so a session whose agent changed mid-session would otherwise be routed by its first agent; the resolution is shared with the background notification path, which has the same requirement. The task permission prompt stays keyed on the requested subagent_type so existing grants and deny rules keep matching, since dispatching a different reviewer is a runtime detail. Stale read-only wording that #165 made false is corrected, and the two new reviewer prompts no longer claim they cannot run commands.
Issue #113. The generic `review` subagent becomes a request rather than an identity: the task tool resolves which reviewer runs from the parent agent, so `work` dispatches work-review, `code` dispatches code-review, and any other parent keeps the existing generic `review`. Every routing target is itself a member of the reviewer set, so a routed request still passes the report gate. All three reviewers share one `reviewPermissions` block, extracted from the existing `review` definition, so they keep the plan-equivalent inspection permissions including `bash` for reproducing and verifying runtime behaviour, with edit denial enforced at the permission seam. The split is domain focus only: identical capability, identical standard, no description implying a weaker bar. The report gate is keyed on agent name, and a name missing from the set completes a review without a verdict rather than failing loudly. The names therefore live in one module, `REVIEW_AGENTS` for the gate and `REVIEW_ROUTING` for dispatch, with a `ReviewAgent` union making "a routed target is itself a reviewer" a compile error. Centralising reduces the failure mode; it does not remove it, and the module says so. Parent-agent resolution reads the session row, then the newest user message naming an agent, because a session row's `agent` is null for the default session. `MessageV2.page` returns messages oldest-first, so this uses `findLast`; reading the oldest message would invert the routing in exactly the mid-session agent switch it exists to handle. `ctx.agent` is deliberately not consulted, because on the subtask path it is the child's agent. The read is memoized and yielded only when a review routes or a background result is delivered, so other delegations never pay for it. An unreadable parent fails the dispatch explicitly instead of resolving to no agent and silently falling back to the generic reviewer with the wrong prompt and permissions. The catch is narrowed to `NotFound` so any other cause stays a defect rather than being reinterpreted. The task permission prompt is keyed on the requested `subagent_type` together with the resolved name, because stored always-allow grants and user config rules are written against either, and a deny on one name must not be bypassed by an allow on the other. Stale read-only wording that #165 made false is corrected, and the two new reviewer prompts no longer claim they cannot run commands.
Issue for this PR
Closes #164
Type of change
What does this PR do?
The Review subagent was deny-by-default with a bespoke readonly overlay, so it could not run commands to reproduce or verify runtime behavior. Plan already has the intended boundary (inspection plus non-destructive execution including bash), so per #164 the plan set is now the single source of truth:
Why this shape: bash allow flows from the shared defaults allow-all exactly as it does for plan today, and edit/write/apply_patch stay gated through the edit permission at the runtime layer (Permission.disabled maps them onto edit), identically for both agents. Session-level child denies (todowrite) and the review finish envelope gate are unaffected.
How did you verify your code works?
Screenshots / recordings
Not a UI change.
Checklist