Repository navigation
Closed
Labels
documentationImprovements or additions to documentationenhancementNew feature or requestmaintainer-scrapMaintainer notes and follow-ups to revisit later
Description
Background
PR #53 (by @thisfilipe) adds the opt-in allToolsNativeAsks: "review" for all-tools mode on OpenCode 2.x: an AI allow from tool.execute.before satisfies the native permission ask of that exact tool call (keyed on session, message and call id plus agent, 45 s lifetime, revoked through the root-session intent tracker), and any other native action raised by the call is reviewed separately with its resources. The default stays "preserve". The re-review on 2026-10-23 found no high or critical issues; the follow-ups below were left out so the PR could merge.
Details
- Input mutation is only detected after execution (mid).
src/v2.tscompares an input digest inexecute.after. A laterexecute.beforehook (another plugin, or core's input repair) that rewrites{command: "ls"}into something else still gets its same-action native ask auto-allowed, and the throw inexecute.aftercomes too late. Keeping a reference to theexecute.beforeevent in the grant and re-checkingtool+ input digest inside thepermission.evaluatehook would stop it at ask time. - Same-action asks skip resources (mid). When
event.action === grant.tool, the ask is allowed without looking atevent.resources, and the grant is not consumed. A custom or MCP tool that callsctx.ask({action: <its own name>, resources: [resolved at run time]})gets resources the reviewer never saw auto-allowed. Either match resources against the reviewed input or document this. - What a throw in
execute.afterdoes is undefined (low-mid). The Effect types declareexecute.afterfailures asnever; the promise adapter wraps the callback inEffect.promise, so a rejection becomes a defect. README says the mutation is "detected" but not what happens next. - Digest timing and tool name (low). The input digest is computed after the review finishes (compute it before
tracker.begin), andexecute.afterdoes not comparegrant.toolwithevent.tooleven thoughtoolis mutable. - Silently ignored combinations (low).
allToolsNativeAsks: "review"withmode: "on-ask"or on V1 is accepted and ignored, unlike the rest of the config, which rejects ignored options. - Escalate becomes deny (low, design). An escalate or reviewer failure on an extra action denies instead of leaving the human prompt; leaving
askwould match "escalate = human". - Audit log (low). Flipping a same-action native ask to allow is not recorded.
- README gaps (low). The Review modes table and the paragraph saying only
on-askruns insidepermission.evaluateare not updated; the new section should state that explicit useraskrules (e.g."git push *": "ask") are answered by the AI when the option is on, and that same-action asks do not re-check resources. - Tests (low). Missing: an evaluate event without
agent, two parallel calls in one message (oneexecute.aftermust not drop the other grant), and theisReviewerbranch in the evaluate hook. - Host ordering (info). The feature assumes OpenCode calls
execute.beforebefore the tool's native permission assert. Upstream core does today; if a host version asserts first the option silently does nothing (fail-closed). Worth one live check on the supported 2.x range.
Solution / Next Steps
- Move the mutation check into the evaluate hook (stored event reference, tool + digest computed before review) so a mutated call falls back to a human or deny before it runs.
- Decide on resources matching for same-action asks, or document the gap.
- Reject or warn on
allToolsNativeAsks: "review"outside all-tools / on V1. - Update the README modes table, the
permission.evaluateparagraph and the residual-risk notes; record the flipped asks in the audit log. - Add the missing tests and run one live check of the hook order.
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationenhancementNew feature or requestmaintainer-scrapMaintainer notes and follow-ups to revisit later
Activity