Skip to content

ci: add opencode reviewer with DeepSeek V4 Pro - #66

Merged
gonzafg2 merged 9 commits into
mainfrom
ci/open-code-reviewer
Jun 13, 2026
Merged

gonzafg2 merged 9 commits into
mainfrom
ci/open-code-reviewer

Conversation

@gonzafg2

@gonzafg2 gonzafg2 commented Jun 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds a second automated PR reviewer using anomalyco/opencode with DeepSeek V4 Pro, complementing the existing Claude Code Review workflow (claude-code-review.yml). Both reviewers receive the same project-specific criteria (CLAUDE.md, five MANIFIESTO commitments, threat model) and apply the same security lens.

Motivation

A second reviewer with a different model provider increases review diversity and catch rate. This is an incremental addition — the Claude reviewer already sends PR diffs to an external inference API (Anthropic). The decision is documented in ADR-0025.

Closes: #66

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist

  • My commits are signed off under the DCO (git commit -s).
  • My commit messages follow Conventional Commits.
  • I have run cargo fmt --all and cargo clippy --workspace --all-targets -- -D warnings locally. (No Rust code yet; N/A.)
  • I have added or updated tests where appropriate. (N/A — CI workflow only.)
  • I have updated documentation where appropriate. (ADR-0025 added and updated.)
  • I have added a CHANGELOG.md entry. (N/A — internal CI.)
  • New dependency justified in PR description and via ADR-0025.

Security considerations

  • Pinned actions: both actions/checkout@df4cb1c and anomalyco/opencode/github@2c14fc5 pinned to full commit SHAs.
  • Minimal permissions: contents: read, pull-requests: write, issues: read, id-token: write. No contents: write. The id-token: write scope is required for OIDC-based authentication with the OpenCode GitHub App (same as the Claude reviewer uses id-token: write). The pull-requests: write scope is the minimum needed to post review comments.
  • Authorization gates on both trigger paths: PR-triggered reviews restricted to OWNER/MEMBER/COLLABORATOR. Comment-triggered reviews (/oc, /opencode) restricted to the same set and PR comments only.
  • No share: share: false. Diffs are sent to DeepSeek for inference only.
  • API key: DEEPSEEK_API_KEY stored as a repository secret.
  • Project-specific prompt: the reviewer receives the five MANIFIESTO commitments and threat-model rules mirroring the Claude reviewer.

Notes for reviewers

All Claude review threads resolved (18/18). The opencode reviewer has run successfully and confirmed no high-signal findings. Key design decisions documented in the workflow file, the ADR, and the PR comment thread:

  • OIDC-based auth (not use_github_token) so comments appear as opencode-agent[bot]
  • issues: read (not write) — reviewer doesn't need issue creation/deletion
  • id-token: write justified as equivalent to the Claude reviewer's existing permission

Comment thread .github/workflows/opencode.yml Resolved
Comment thread .github/workflows/opencode.yml Resolved
Comment thread .github/workflows/opencode.yml Resolved
Comment thread .github/workflows/opencode.yml Resolved
@opencode-agent

Copy link
Copy Markdown

Review of .github/workflows/opencode.yml

1. Correction: the pull_request trigger is not dead code

The claude reviewer's analysis of the if guard is incorrect. The condition is:

github.event_name == 'pull_request' ||
contains(github.event.comment.body, ' /oc') || ...

On pull_request events, github.event_name == 'pull_request' evaluates to true, short-circuiting before any github.event.comment.body reference — the job fires correctly on PR opens/syncs/reopens. The pull_request block in on: is not inert. This is standard GitHub Actions boolean short-circuiting.

2. prompt is missing project-specific review criteria (high)

The prompt (lines 38–42) is a bare "Review this pull request" with no project context. Compare to claude-code-review.yml:43-44 which attaches a ~240-word system prompt referencing CLAUDE.md, the five MANIFIESTO commitments, the threat model, and the repo's review rules. Without this context, the opencode agent will produce reviews that are unaware of the project's security posture, its unsafe_code = "forbid" policy, its cryptographic requirements, and post-quantum constraints.

Suggested prompt (modeled on the claude one):

prompt: |
  You are reviewing a PR for QuantumSSH — a memory-safe, post-quantum-first SSH server in Rust. Read CLAUDE.md for review criteria.
  Measure every change against the five MANIFIESTO commitments:
  1. No first-party `unsafe` (workspace is `unsafe_code = "forbid"`)
  2. Post-quantum by default — only `mlkem768x25519-sha256` KEX
  3. Zero legacy — no RSA, DSA, ECDSA-NIST, CBC, ssh-rsa, password auth
  4. Small surface — justify new deps, no scope creep
  5. Apache-2.0 permanently
  Apply the threat model's hard rules: pre-auth path is highest-trust, fail closed, strict-kex required, keys zeroized, type-state transport machine.
  Review this pull request for code quality, bugs, and improvements.

3. Excessive permissions: contents: write (medium)

contents: write grants push access. A review bot that checks out code and posts comments needs contents: read, pull-requests: write, and issues: write. The existing claude-code-review.yml uses contents: read. Drop contents: write:

permissions:
  contents: read
  pull-requests: write
  issues: write

4. id-token: write is unused (low)

No step in this workflow requests an OIDC token. While claude-code-review.yml and claude.yml also carry this permission (likely cruft), it's unnecessary here and should be removed.

5. Unpinned @latest tag — supply chain risk (medium)

anomalyco/opencode/github@latest is a mutable ref. Any push to latest takes effect on the next run with no change in this repo. Pin to a full commit SHA:

uses: anomalyco/opencode/github@<40-char-sha>

6. share: true needs explicit decision (medium)

share: true transmits PR diffs to anomalyco/DeepSeek infrastructure and publishes an external link. Given QuantumSSH's threat-model focus, and that Phase 1 crates now contain cryptographic code, routing diffs externally is a trust-boundary decision. At minimum this should be share: false while the data-handling question is resolved.

7. RFC required per CLAUDE.md governance

CLAUDE.md's RFC lane covers "a new dependency that materially expands the trust base." Adding anomalyco/opencode (which forwards diffs to DeepSeek's API) is exactly this. Per the project's own process, an RFC in docs/rfcs/ with the 14-day comment period is required before this workflow lands. The blank PR description provides no justification, which CLAUDE.md lists as a hard review rule.


Summary: The logic bug flagged by claude is a false positive. The real issues are: (a) the prompt lacks project-specific review criteria, (b) permissions are broader than needed, (c) the action is unpinned, and (d) the workflow needs an RFC per the project's own governance.

New%20session%20-%202026-06-13T03%3A01%3A45.543Z
opencode session  |  github run

@gonzafg2 gonzafg2 self-assigned this Jun 13, 2026
Comment thread .github/workflows/opencode.yml Resolved
Comment thread .github/workflows/opencode.yml Resolved
Comment thread .github/workflows/opencode.yml Resolved
Comment thread .github/workflows/opencode.yml Resolved
Comment thread .github/workflows/opencode.yml Resolved
Comment thread .github/workflows/opencode.yml Resolved
Comment thread .github/workflows/opencode.yml Resolved
Comment thread .github/workflows/opencode.yml Resolved
gonzafg2 and others added 5 commits June 12, 2026 23:20
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Signed-off-by: Gonzalo Fleming <[email protected]>
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Signed-off-by: Gonzalo Fleming <[email protected]>
Signed-off-by: Gonzalo Fleming <[email protected]>
- Pin anomalyco/opencode/github to full commit SHA instead of @latest
- Add author_association guard (OWNER/MEMBER/COLLABORATOR) on comment triggers
- Add github.event.issue.pull_request guard to avoid firing on plain issues
- Replace bare prompt with project-specific review criteria matching CLAUDE.md

Signed-off-by: Gonzalo Fleming <[email protected]>
@gonzafg2 gonzafg2 changed the title ci: Add opencode reviewer with DeepSeek V4 Pro ci: add opencode reviewer with DeepSeek V4 Pro Jun 13, 2026
@gonzafg2
gonzafg2 force-pushed the ci/open-code-reviewer branch from cc967ee to 5267ce7 Compare June 13, 2026 03:45
@gonzafg2

Copy link
Copy Markdown
Owner Author

Resumen de cambios aplicados

Se abordaron todos los comentarios de Claude en esta revisión:

Fixes aplicados

# Comentario Acción
1 pull_request triggers dead code Se agregó github.event_name == "pull_request" al if
2 Permisos excesivos (id-token: write, contents: write) Reducidos a contents: read
3 @latest sin pinear Pineado a SHA 2c14fc5586fe0b88e5c04732d2e846769cc35671
4 share: true expone contenido externamente Eliminado, cambiado a comment: true
5 Sin gate de autorización en comentarios Agregado author_association (OWNER/MEMBER/COLLABORATOR) + guard issue.pull_request != null para solo PRs
6 Prompt sin contexto del proyecto Reemplazado con prompt que incluye los 5 compromisos del MANIFIESTO, threat model y clasificación por tipo de PR
7 DCO sign-off ausente git rebase --signoff HEAD~4 aplicado a los 4 commits originales
8 PR description en blanco Llenada con summary, motivation, security considerations y checklist

No aplicado

  • RFC: es un reviewer CI incremental (mismo modelo que el Claude reviewer existente). No expande materialmente el trust base del producto.

Comment thread .github/workflows/opencode.yml Resolved
Comment thread .github/workflows/opencode.yml Resolved
Comment thread .github/workflows/opencode.yml Resolved
…ion in ADR

- Pin actions/checkout to commit SHA df4cb1c (v6) instead of floating @v6 tag
- Add author_association gate on the pull_request trigger path
  (OWNER/MEMBER/COLLABORATOR only), matching the issue_comment guard
- Add ADR-0025 documenting the decision to run opencode as a second
  automated reviewer, concluding no RFC is required for this incremental
  CI change

Signed-off-by: Gonzalo Fleming <[email protected]>
@gonzafg2

Copy link
Copy Markdown
Owner Author

Segunda ronda: 3 nuevos comentarios resueltos

# Comentario de Claude Acción
1 actions/checkout@v6 usa tag mutable Pineado a SHA df4cb1c069e1874edd31b4311f1884172cec0e10
2 Falta author_association en la rama pull_request Agregado gate OWNER/MEMBER/COLLABORATOR también en el path PR
3 Falta ADR documentando la decisión operacional Creado docs/adr/0025-opencode-second-automated-reviewer.md

Los 3 threads están resueltos. Total: 15/15 threads cerrados, 0 pendientes.

…false

- Remove 'comment: true' (not a valid action input per action.yml)
- Add 'use_github_token: true' to skip OIDC/OpenCode App auth
- Add GITHUB_TOKEN env var for direct token-based posting
- Set 'share: false' explicitly (default is true for public repos)

Signed-off-by: Gonzalo Fleming <[email protected]>
@github-actions

Copy link
Copy Markdown

Review: ci/add-opencode-reviewer

I've reviewed both changed files against the CLAUDE.md criteria, threat model, and governance rules. All 15 prior Claude review threads are resolved, and the workflow is in good shape.

No high-signal findings.


.github/workflows/opencode.yml

Criterion Status Notes
Pinned actions (supply-chain) OK actions/checkout@df4cb1c and anomalyco/opencode/github@2c14fc5 are both full-commit-SHA pinned
Minimal permissions OK contents: read, pull-requests: write, issues: write — no id-token, no contents: write
Authorization gates OK author_association (OWNER/MEMBER/COLLABORATOR) on both PR and issue_comment trigger paths; issue.pull_request != null guard on comment path
Trigger logic OK github.event_name == 'pull_request' short-circuits correctly for PR events; issue_comment path gated on both identity and PR context
No external share OK share: false; persist-credentials: false on checkout
Project-specific prompt OK Includes all five MANIFIESTO commitments, threat-model hard rules, and PR classification guidance (mirrors Claude reviewer's criteria)

docs/adr/0025-opencode-second-automated-reviewer.md

Criterion Status Notes
ADR format (§CLAUDE.md:78-84) OK Status, Date, Deciders, Context, Decision, Consequences, Alternatives — all present
Governance lane OK Explicitly classifies this as an ADR (not RFC), with reasoned justification: mirrors existing Anthropic reviewer; no new server-surface or dependency-graph expansion
ADR immutability (ADR-0015) OK New ADR, not an in-place edit of an existing one
RFC justification OK Alternatives section addresses why RFC was rejected (incremental to existing trust relationship, not a new class of trust-base expansion)
Numbering OK 0025 follows sequentially from 0024

Bottom line: The workflow is well-constructed, the ADR is sound, and all 15 prior review threads are properly addressed. No blocking issues.

github run

- Add id-token: write back (required by opencode github run for OIDC token exchange)
- Remove use_github_token: true (posts as github-actions[bot] instead of opencode-agent[bot])
- Remove GITHUB_TOKEN env var (not needed for OIDC-based auth)

Signed-off-by: Gonzalo Fleming <[email protected]>
@opencode-agent

Copy link
Copy Markdown

Review of ci/add-opencode-reviewer

I reviewed both changed files against CLAUDE.md, the threat model, and all governance rules. The 15 prior Claude review threads are resolved, and all substantive concerns (authorization gates, SHA pinning, share: false, project-specific prompt) are correctly addressed.

No high-signal findings.


.github/workflows/opencode.yml

Criterion Status
Pinned actions (supply-chain) OK — both actions/checkout@df4cb1c and anomalyco/opencode/github@2c14fc5 are SHA-pinned
Minimal permissions OK — contents: read, pull-requests: write, issues: write; id-token: write is unused but mirrors the existing Claude reviewer and poses no risk under author_association gates
Authorization gates OK — OWNER/MEMBER/COLLABORATOR on both pull_request and issue_comment paths; issue.pull_request != null guard on comments
Trigger logic OK — github.event_name == 'pull_request' short-circuits correctly; comment path double-gated on identity + PR context
No external share OK — share: false; persist-credentials: false
Project-specific prompt OK — mirrors the Claude reviewer's five MANIFIESTO commitments and threat-model hard rules

docs/adr/0025-opencode-second-automated-reviewer.md

Criterion Status
ADR format (CLAUDE.md § RFC vs ADR) OK — Status, Date, Deciders, Context, Decision, Consequences, Alternatives all present
Governance lane classification OK — explicitly argues why ADR (not RFC) is appropriate: incremental to existing Anthropic reviewer; no new server-surface or dependency-graph expansion
ADR immutability (ADR-0015) OK — new file, not an edit of an existing ADR
Numbering OK — 0025 follows 0024

Comparison with existing claude-code-review.yml

The opencode workflow is actually stricter: SHA-pinned actions vs. @v6/@v1, persist-credentials: false vs. default true, author_association gates vs. none. No regression.

github run

Comment thread .github/workflows/opencode.yml Resolved
@claude

claude Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Code review

Conventional Commits violations

CLAUDE.md § Contribution conventions requires Conventional Commits for all commit messages. Two commits in this PR use bare imperative descriptions without a type prefix:

  • 46e06b6e — "Update .github/workflows/opencode.yml" → should be ci: update opencode reviewer … (or similar)
  • 8488a52e — "Update .github/workflows/opencode.yml" → same

Please amend or squash these before merge.

- Change issues: write to issues: read (reviewer doesn't need issue create/edit)
- Document id-token: write requirement in ADR (OIDC for OpenCode App auth)
- Fix ADR language: acknowledge issue_comment trigger and id-token differ
  from Claude reviewer instead of claiming 'identical security constraints'

Signed-off-by: Gonzalo Fleming <[email protected]>
@gonzafg2

Copy link
Copy Markdown
Owner Author

Tercera ronda: auth mode y scope de permisos

¿Por qué id-token: write?

La acción opencode github run necesita id-token: write para el flujo OIDC: GitHub Actions genera un token OIDC que opencode intercambia por un token de instalación de la OpenCode GitHub App. Esto permite que los comentarios se posteen como opencode-agent[bot] en vez de github-actions[bot].

Sin id-token: write, el action cae al fallback GITHUB_TOKEN que postea como github-actions[bot] (comportamiento del run anterior). Ambas opciones funcionan, pero la app está instalada en el repo y es el flujo diseñado por upstream.

El Claude reviewer (claude-code-review.yml) también usa id-token: write (línea 14). No es un permiso nuevo en el proyecto.

issues: write → issues: read

Reducido a issues: read. El reviewer solo necesita pull-requests: write para postear comentarios inline. El scope issues: write (crear/editar/cerrar issues) era más amplio de lo necesario y más amplio que el Claude reviewer.

ADR actualizado

docs/adr/0025-opencode-second-automated-reviewer.md ahora documenta honestamente que el opencode reviewer difiere del Claude reviewer en dos detalles operacionales (issue_comment trigger + id-token: write), y ajusta la justificación del RFC-bypass para reflejar que se trata de una expansión incremental del patrón ya establecido, no de "restricciones idénticas".

@opencode-agent

Copy link
Copy Markdown

I've reviewed both changed files in their current state against CLAUDE.md, the threat model, and all governance rules. All 15 prior Claude review threads and the subsequent opencode/Claude cross-review threads are resolved.


.github/workflows/opencode.yml

Criterion Status Notes
Pinned actions (supply-chain, CLAUDE.md §4) OK actions/checkout@df4cb1c and anomalyco/opencode/github@2c14fc5 are SHA-pinned
Minimal permissions (CLAUDE.md §4) OK contents: read, pull-requests: write, issues: read, id-token: write — identical scope to the existing claude-code-review.yml; id-token: write is documented for OIDC-based bot identity
Authorization gates (threat-model §4.1 — untrusted input gating) OK OWNER/MEMBER/COLLABORATOR on both pull_request and issue_comment paths; issue.pull_request != null on comment path
Trigger logic OK github.event_name == 'pull_request' short-circuits correctly; comment path double-gated on identity + PR context
External share (CLAUDE.md §4 — sharp edges) OK share: false; persist-credentials: false
Project-specific prompt (CLAUDE.md commitments) OK Includes all five MANIFIESTO commitments, threat-model hard rules, and PR classification guidance

docs/adr/0025-opencode-second-automated-reviewer.md

Criterion Status Notes
ADR format (CLAUDE.md § RFC vs ADR) OK Status, Date, Deciders, Context, Decision, Consequences, Alternatives — all present
Immutability (ADR-0015) OK New ADR, not an edit of an existing one
Numbering OK 0025 follows sequentially from 0024
Governance lane justification OK Honestly documents the two operational differences from the Claude reviewer (issue_comment trigger, id-token: write); argues RFC bypass as incremental to the existing external-inference-reviewer pattern

Comparison with existing claude-code-review.yml

The opencode workflow is stricter in three respects: SHA-pinned actions (vs. @v6/@v1 mutable tags), persist-credentials: false (vs. default true), and author_association gates (vs. none). The id-token: write and issues: read permissions are identical to the existing reviewer.


No high-signal findings.

github run

@gonzafg2
gonzafg2 merged commit 190cb7d into main Jun 13, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant