# ๐Ÿ“‹ Code Review Report โ€” OpenCode Adapter Iteration-3 (OPENCODE_PERMISSION fix) (Job 8d04f9f3) - **Reviewer**: `reviewer-hermes-01` (role: reviewer) โ€” reviewer chain: plan Rev.2/Rev.3 (9c6b3390, 90aa4208), implementation NOT PASS (08041d33), fix PASS (8cc8f403), quoting regression NOT PASS (6a3d73d4) - **Reviewed diff**: same 23-file OpenCode integration; the delta from the prior iteration is precisely the blocking fix โ€” the `OPENCODE_PERMISSION` export rewritten to the empty-guard form โ€” plus a behavior-level test replacing the prior form-assertion. - **Method**: exact script-arm replication in isolation (both unset and preset paths), live source verification of both sites, tier1 test content read, full suite run. --- ## 1. Prior Blocking Defect โ€” Fix Verification **Prior finding (6a3d73d4)**: `export OPENCODE_PERMISSION="${OPENCODE_PERMISSION:-{\"*\":\"allow\"}}"` corrupted user-supplied values โ€” a preset `{"*":"deny"}` became `{"*":"deny"}}` (invalid JSON) on both create and resume paths, because the `\"` escapes inside an unquoted `${:-}` default are stripped when the variable is set, and the default's closing `}` collides with the JSON's. **Fix verified in live source** โ€” both sites now use the exact empty-guard I specified: - create_session.sh:216โ€“219 (inside the `opencode)` spawn arm): `if [ -z "${OPENCODE_PERMISSION:-}" ]; then export OPENCODE_PERMISSION='{"*":"allow"}'; fi` - resume_session.sh:129โ€“133 (pre-`new-session`, agent-gated): identical guard **Isolation replication of the exact fixed arm** (both paths): ``` unset โ†’ '{"*":"allow"}' โ†’ json.loads VALID preset โ†’ '{"*":"deny"}' โ†’ json.loads VALID + preserved byte-identically ``` No escaping in the default, so no expansion-order hazard exists in this form. The user-override contract promised by `.mam.env.example` and the brief is now honored. ## 2. Test Upgrade โ€” Form-Assertion Replaced by Behavior Test Prior iteration's tier1 test asserted the export line verbatim (a form-assertion that green-lit the broken quoting). The new test (test_tier1_unit.py L991โ€“1028) exercises **both paths behaviorally**: - unset path: env scrubbed of `OPENCODE_PERMISSION` โ†’ guard+export โ†’ output parses as `{"*": "allow"}` - preset path: `OPENCODE_PERMISSION='{"*":"deny"}'` injected โ†’ guard+export โ†’ output parses as `{"*": "deny"}` โ€” **proving the user value passes through intact** Run for both create and resume script arms. This is the behavior-lock my prior review required; the exact failure class I demonstrated (set-path corruption) is now mechanically caught by the suite rather than only by review. ## 3. Carry-Over State โ€” Re-Confirmed Unchanged (no regression in the fix round) | Prior-verified item | Status | |---|---| | Real-schema probe (`directory`/`time_created` ms) in adapter + drift-C | โœ… unchanged from the 8cc8f403-verified state (probe lines L118โ€“119/145/213โ€“223; reconcile L379โ€“394) | | `_resolve_db` CLI invocation + sandbox-safe env (`HOME`/`HOME_DIR`/`XDG_DATA_HOME` overrides) | โœ… unchanged | | run_loop resolver arms (opencode + grok) | โœ… unchanged | | status.sh `resume_on_disk` dispatch (both functions, 5 agents) | โœ… unchanged | | conftest real-schema seeding + adaptive seeder | โœ… unchanged | | `test_opencode_real_schema_directory_and_time_created_ms` | โœ… present | | `test_opencode_resolve_db_cli_path` | โœ… present | | update_yaml_resumed.sh opencode elif | โœ… present | | paste-skip membership (lib.sh:2125) | โš ๏ธ still deferred to live TUI smoke test โ€” unchanged posture, correctly gated per plan ยง4 | ## 4. Verification Summary | Check | Result | |---|---| | Full suite | โœ… **447 passed, 0 failures** (734.0 s) | | Prior blocking defect (quoting corruption) | โœ… fixed at both sites; both paths proven in isolation and by behavior test | | Form-assertion โ†’ behavior-assertion upgrade | โœ… done, preset-path preservation asserted | | All other refinement items | โœ… unchanged from verified state, no collateral edits | ## 5. Verdict The single blocking item from 6a3d73d4 is fixed exactly as specified โ€” the empty-guard form with no escape hazards, at both the create spawn arm and the resume pre-spawn gate โ€” and, more importantly, the test that let the regression through has been converted from a form-assertion to a behavior test that would have caught it. Nothing else in the diff changed from the previously-verified state, so no new risk was introduced in this round. All five brief items are now simultaneously satisfied for the first time across the three iterations. [VERDICT: PASS]