# 📋 Code Review Report — OpenCode Adapter Plan Rev.3 (Job 90aa4208)

- **Reviewer**: `reviewer-hermes-01` (role: reviewer) — prior reviewer of Rev.2 (job 9c6b3390, verdict PASS with schema findings + touch-point additions)
- **Reviewed diff**: 2 new untracked files — `.agents/reports/implementation_plan.md` and `.agents/reports/planner-reviewer-claude-01/plan-de667f0f.md` (byte-identical, verified; Rev.3, 249 lines). Root `implementation_plan.md` restored to tracked HEAD content (verified: `git diff` = 0 lines). No code changes.
- **Method**: all five Rev.3 changelog claims (F1–F5) verified against live repo + live OpenCode install; my prior review's findings checked for incorporation; full suite run.

---

## 1. Rev.3 Changelog Claims — Correction Verification

| # | Claim | Verification | Result |
|---|---|---|---|
| F1 | Root `implementation_plan.md` restored; plan namespaced under `.agents/reports/.../plan-de667f0f.md` + mirror | `git diff implementation_plan.md` → 0 lines (NATS roadmap intact); both new files exist, byte-identical (diff RC=0); this also resolves the brief-vs-repo conflict my Rev.2 review noted (brief said "save to implementation_plan.md" but overwriting the tracked NATS roadmap was destructive — Rev.3's namespacing is the correct resolution) | ✅ |
| F2 | Touch-point table extended 22 → 29 (items 23–29) | All 7 new items verified against live code: spawn dispatch case `agy\|hermes\|grok)` at create_session.sh ~L205 ✅; YAML init `elif agent ==` chain (agy/hermes/grok branches, no else) at ~L399-419 ✅; fallback CMD_FULL case ~L181-189 ✅; `send_keys_safe` `_sks_agent` case arms at lib.sh ~2058-2061 ✅; test_tier1_unit usage assertions (969/974) ✅; SKILL.md agent lists ✅; conftest mock_agents fixture ✅. Items 23/26/29 directly incorporate the gaps my Rev.2 review enumerated | ✅ |
| F3 | `opencode db path` prioritized; hardcoded `storage.db` dropped | grep confirms zero `storage.db` references remain (only the changelog note about dropping it); **executed against live install**: `opencode db path` → `/Users/godopu16/.local/share/opencode/opencode.db`, RC=0 — the subcommand is real and works (v1.18.25). This resolves the wrong-path finding from my Rev.2 review | ✅ |
| F4 | `OPENCODE_PERMISSION='{"*":"allow"}'` documented as process-env permission layer | The env var is not listed in `opencode --help` output (help lists only CLI flags) — it comes from the config-docs layer, so I could not verify it from `--help` alone; however the CLI does confirm `--auto` exists ("auto-approve permissions that are not explicitly denied"), and setting the var to a benign value caused no CLI error. Treat as **plausibly correct but unverified by me** — the plan's own DoD item ("Verify headless execution under `--auto` + `OPENCODE_PERMISSION=...`") correctly gates it before trust, which is the right posture | ✅ (correctly gated) |
| F5 | `expanduser('~')` → `ctx.home_dir` in auth_ok/artifact paths | Verified: §1.6, §2 table, and DoD all use `ctx.home_dir`; no `expanduser` remains in the plan | ✅ |

## 2. My Prior Review's Findings — Incorporation Status

| My Rev.2 finding | Rev.3 status |
|---|---|
| Wrong DB path (`storage.db`) | ✅ Fixed via F3 (`opencode db path`, verified live) |
| `run_loop.sh::resolve_agent_type` claude-default trap | ❌ **Still missing** — `run_loop` appears 0 times in the plan; the `else: agent = 'claude'` fallback misroutes opencode sessions in loop mode |
| `status.sh::resume_on_disk` per-agent branch | ❌ **Still missing** — `status.sh` appears 0 times in items 1–29 |
| conftest mock opencode binary | ✅ Added (item 29) |
| `send_keys_safe` `_sks_agent` case arm | ✅ Added (item 26) |
| ms-scale `time_created` unit mismatch | ⚠️ **Partially addressed** — Rev.3 keeps `created_at >= ?` in the drift-C sketch (L199) and the DoD spike item still says "verify (`cwd`, `created_at` timestamps)". My live `.schema` dump (job 9c6b3390) showed the real columns are `directory` (not `cwd`) and `time_created` in **milliseconds** (not `created_at` in seconds). The plan's spike-gated phrasing technically covers this ("verify ... column definitions before writing SQL"), so it is not a factual error — the spike remains the gate — but the sketch retains column names my own verified schema dump already disproves. The evidence exists in this workspace (my prior report) and was not folded in. |
| paste-skip membership (empirical) | ✅ Correctly left as smoke-test decision |

## 3. New Findings (non-blocking)

1. **[Medium — carry-in]** The drift-C sketch (§5) and §1.5 spike text still use `cwd`/`created_at` as if they were the expected column names. Live reality (verified twice now): `session.directory text NOT NULL`, `time_created integer NOT NULL` (ms). The DoD spike item would catch this at implementation time, so this is a quality gap, not a correctness trap — but the plan cites jobs `1d63595f`/`56120ad3` as its review inputs while my schema findings from job `9c6b3390` (which the loop had available) were not incorporated. Recommend folding them in: one-line change to the sketch's SELECT and a note on unit conversion.
2. **[Low — carry-in]** `status.sh`'s `resume_on_disk()` (tuples at L56/61 + per-agent artifact check) needs an `opencode` branch or status queries will report `no` for every opencode session. Still absent from the 29-item table.
3. **[Low — carry-in]** `run_loop.sh::resolve_agent_type`'s segment matching (`if 'agy' ... elif 'hermes' ... else claude`) needs an opencode arm — absent. Note item 28 (SKILL.md lists) partially covers the loop skill's docs but not this code path.
4. **[Info]** The plan's Rev.3 attribution says reviewers were `planner-reviewer-claude-01` (job `1d63595f`) and `reviewer-creator-grok-01` (job `56120ad3`) — both jobs exist with briefs. My review (9c6b3390) is not cited, consistent with the above non-incorporation.
5. **[Info]** `opencode` binary on this machine is at `~/.opencode/bin/opencode` (not on default PATH) — worth noting for the smoke-test DoD item (create_session.sh's `command -v "$AGENT"` preflight would fail unless PATH is extended or a symlink made; the plan does not mention install-path discovery).

## 4. Regression & Compliance

- Full suite: **439 passed, 0 failures** (549.4 s)
- `git status`: only the two plan files (untracked); root `implementation_plan.md` byte-restored; no code touched — brief's "DO NOT implement code changes" constraint ✅
- Both plan copies byte-identical ✅

## 5. Assessment

Rev.3 is a genuine improvement over Rev.2: the destructive root-file overwrite is corrected (F1), the three touch-point gaps I enumerated are closed (F2 items 23/26/29), the DB-path error is fixed with a verified-live dynamic resolver (F3), and the permission architecture is more honest about config-file boundaries (F4, correctly spike-gated). All five changelog claims check out against the live repo and live CLI. The two carry-in items my previous review supplied that remain unincorporated (`status.sh` branch, `run_loop.sh` resolver) are real but small — two more rows in an already-extensible table — and the schema-column staleness is gated by the plan's own spike requirement rather than being an error that would ship. None of these require replanning; they are additive line-items for the implementer, and the plan's structure (DoD-gated spike, empirical TUI capture) already forces them to surface before merge.

[VERDICT: PASS]