Skip to content

[Feature] opencode adapter: enforce the gates under OpenCode V2 #1956

Closed

Description

@zeyadsleem

User Story

As an apexyard adopter running OpenCode V2, I want the shipped opencode adapter to load and enforce the gates so that I get the same mechanical enforcement as on V1, instead of a silent no-op.

Acceptance Criteria

  • harness-adapters/opencode depends on the V2 plugin package and its default export is a single object that satisfies both plugin APIs: the V1 factory under server(), and the V2 entrypoint from Plugin.define({ id, setup }) spread into the same object.
  • Under V2, the adapter registers through ctx.tool.hook("execute.before", ...) and throws when a gate exits 2, so the tool call is denied.
  • Tool-id mapping covers V2: shell maps to the bash gate set, and bash keeps working for V1. edit and write keep their current mapping.
  • The patch tool has a decided, tested behaviour: either run the Edit-wired gates with a reconstructed file_path set, or be documented as unrouted with a log line. No undocumented silent skip.
  • The gate logic stays in gate-dispatcher.ts and derive-gates.ts. This change adds a transport only.
  • V1 does not regress: the existing test suite passes and a V1-shaped plugin still loads.
  • New tests cover the V2 path: allow, deny (exit 2 throws), ops-root resolution, session-id handling, and tool-id mapping.
  • harness-adapters/opencode/README.md, docs/harnesses/opencode.md, and docs/opencode-adapter.md state that V1 and V2 are both supported, and that V2 requires directory paths for configured local plugins.
  • The batch bypass note is removed. anomalyco/opencode#5894 closed as stale, the maintainer could not reproduce it, and V2 has no batch tool.

Design Notes

  • V2 does not run V1 plugins. The current adapter therefore loads as a no-op: no error, no gate.
  • The dual-export shape is the one the vendor documents in its own migration guide, so one package serves both versions.
  • Error behaviour stays as it is today: a gate that cannot produce an exit status fails closed, and an unresolved ops root runs with no gates.
  • Open question for the build: a subagent runs in a different session id. The ticket marker is tree-based, so it should still resolve. Add a test with a subagent-shaped event.
  • Related: [CI] Conformance CI: zero-cost hybrid (opencode daily on the free model, pi and codex manual and release evidence) #1916 pins [email protected] in the conformance job. When that pin moves past the V2 plugin API, this adapter must not silently stop enforcing.

Out of Scope

Effort Estimate

TBD

Glossary

Term Definition
Gate A mechanical check that denies a tool call when a governance rule is not met.
Plugin transport The harness-specific code that connects the shared gate logic to a harness plugin API.
OpenCode V2 plugin API The Plugin.define({ id, setup }) API that replaces the V1 plugin factory.
Code Mode V2's execute tool that runs scripted tool calls. Nested calls still pass through execute.before.
Fail closed A gate error denies the tool call.

Activity

  1. added 10 commits that reference this issue on Nov 4, 2026
  2. added a commit that references this issue on Nov 5, 2026
  3. atlas-apex commented on Nov 6, 2026

    @atlas-apex
    Collaborator

    Delivered in #1959 (90c5e06). Thank you @zeyadsleem for the report and @ahmed-bermawy for the port. The change is on dev now and ships in the next release. Until then, an ops fork can pick it up with /update --from-dev, which pulls pre-release work.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions