Skip to content

Follow-ups from PR #53: native ask bridging hardening, config checks and docs #68

Closed

Description

@dyoshikawa

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.ts compares an input digest in execute.after. A later execute.before hook (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 in execute.after comes too late. Keeping a reference to the execute.before event in the grant and re-checking tool + input digest inside the permission.evaluate hook would stop it at ask time.
  • Same-action asks skip resources (mid). When event.action === grant.tool, the ask is allowed without looking at event.resources, and the grant is not consumed. A custom or MCP tool that calls ctx.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.after does is undefined (low-mid). The Effect types declare execute.after failures as never; the promise adapter wraps the callback in Effect.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), and execute.after does not compare grant.tool with event.tool even though tool is mutable.
  • Silently ignored combinations (low). allToolsNativeAsks: "review" with mode: "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 ask would 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-ask runs inside permission.evaluate are not updated; the new section should state that explicit user ask rules (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 (one execute.after must not drop the other grant), and the isReviewer branch in the evaluate hook.
  • Host ordering (info). The feature assumes OpenCode calls execute.before before 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

  1. 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.
  2. Decide on resources matching for same-action asks, or document the gap.
  3. Reject or warn on allToolsNativeAsks: "review" outside all-tools / on V1.
  4. Update the README modes table, the permission.evaluate paragraph and the residual-risk notes; record the flipped asks in the audit log.
  5. Add the missing tests and run one live check of the hook order.

Activity

  1. added
    documentation
    enhancement
    maintainer-scrap
    on Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationenhancementmaintainer-scrap

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions