Skip to content

fix(opencode): enrich reviewer output with provider-owned capture subject #1689

Description

@dnlrsls

Pre-flight Checklist

  • I have searched existing issues and this is not a duplicate.
  • I understand PRs require status:approved.

Bug Description

A negotiated bounded review exposes provider-owned artifact_subject, exact candidate diff, and changed-path manifest through START/status. The selected OpenCode reviewer correctly returns the strict native model-owned shape {findings,evidence}. The managed review-result-artifacts.ts hook forwards that JSON unchanged to review capture-result, but native admission requires the capture-only envelope to also contain provider-derived top-level subject_hash and inspection. Capture therefore fails with reviewer artifact admission incomplete: reviewer result omitted the provider-owned artifact subject, preserves the raw result, and leaves authority in reviewing with no admitted lens result.

This is a product/integration regression or incomplete acceptance from merged PR #1550, which introduced provider-owned artifact admission and claimed managed OpenCode support. It is distinct from #1610 (authority revision propagation), #1411 (capture incident preservation/recovery), and #1454 (immutable diff/manifest delivery). The reviewer must not emit or construct provider-owned metadata; the adapter owns enrichment.

Steps to Reproduce

  1. Install/sync a Gentle AI beta containing provider-owned reviewer artifact admission and use OpenCode.
  2. Start or resume a negotiated review whose native next transition is collect/reviewer_results_required; verify it provides artifact_subject, candidate_diff, and changed_path_manifest.
  3. Launch the selected bound reviewer through the managed hook.
  4. Let the reviewer return valid strict JSON with only findings and evidence, as required by its agent contract.
  5. Observe the after-hook extract that JSON and forward it unchanged to review capture-result.
  6. Observe capture fail with the admission-incomplete error and preserve the raw reviewer result while authority remains unchanged.

Expected Behavior

The managed adapter should build a capture-only envelope by combining reviewer-owned findings/evidence with provider-owned subject_hash from artifact_subject.subject_hash and inspection: {status: "completed", paths: [...]} derived from the exact ordered changed-path manifest. Models must continue returning only findings/evidence. The same deterministic enrichment path should support replaying a preserved raw result through full native verification without rerunning the lens or opening another review budget.

Actual Behavior

The installed plugin and the current beta managed asset both forward reviewer output unchanged. Preflight/transition context contains the provider-owned subject and manifest, but the after-hook does not retain or merge them into capture stdin. Native capture sees an empty subject hash and rejects admission.

Environment

  • Gentle AI Version: beta module v1.49.1-0.20260722122850-8881b60b01c7, revision 8881b60b01c7 (post-v2.1.11 development build)
  • Operating System: Windows
  • AI Agent / Client: OpenCode
  • Affected Area: Installation Pipeline (managed OpenCode plugin)

Logs / Error Output

gentle-ai review capture-result failed (1): Error: reviewer artifact admission incomplete: reviewer result omitted the provider-owned artifact subject

Additional Context

Verified source-backed causal chain:

  • internal/cli/review_start_contract.go and internal/cli/review_next_transition.go expose the provider-owned subject/diff/manifest.
  • internal/cli/review_facade.go decodes capture input with top-level subject_hash, inspection, findings, and evidence.
  • internal/reviewtransaction/artifact_admission.go rejects a missing subject hash.
  • internal/assets/opencode/plugins/review-result-artifacts.ts extracts reviewer JSON and forwards it unchanged; the installed managed plugin has the same ownership gap.

Acceptance criteria:

  • Reviewer output contract remains strict {findings,evidence} only.
  • Adapter retains provider preflight/transition context for the exact bound slot.
  • Adapter constructs capture stdin with provider-derived subject_hash and ordered completed inspection.paths.
  • Models never construct hashes, manifests, inspection metadata, or canonical artifacts.
  • Preserved raw results can pass through the same enrichment and native verification path without another reviewer invocation.
  • A behavioral managed-hook test mocks preflight/transition context, supplies findings/evidence-only output, asserts exact capture stdin, and covers preserved-result recovery and idempotent replay.

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:highHigh prioritystatus:approvedApproved for implementation — PRs can now be openedtype:bugBug fix

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions