# Cross-Code Review Report — Job b6fc4e5a (Re-review after fix) - **Job ID**: b6fc4e5a - **Target**: `multi-agent-mux-orc-onboard` skill + `orchestrator_uuids` exclusion gate in `lib.sh` - **Reviewer**: cline - **Context**: Re-review of the same changeset reviewed in job e7c13ec2 (which returned NOT PASS). The implementer has since applied the fix recommended in that prior review. - **Scope**: lint, behavior (동작성), loss (유실) of the uncommitted working-tree changeset: - `M .agents/skills/lib.sh` - `M .gitignore` - `M deploy/gitea-ci.yml`, `M deploy/remove.sh` - `?? .agents/skills/multi-agent-mux-orc-onboard/` (SKILL.md + scripts/orc_onboard.sh) - `?? tests/test_orc_onboard.py` - **Baseline commit**: `1e1ab8c` (changes uncommitted, reviewed against working tree) --- ## 1. Executive Summary The prior review (job e7c13ec2) returned **NOT PASS** for two reasons: (a) the orc-onboard test suite was non-deterministic — `test_o19`/`test_o33` failed 2/40 when run as a descendant of an orchestrator agent (the skill's own deployment context), and (b) stale test-pollution artifacts (`d.db*`, `d.update*`) were ungitignored in the repo root. The implementer has now fixed **both** issues: 1. **`MAM_AUTODETECT_FORCE_FAIL` testability hook** added to `detect_nearest_agent()` in `orc_onboard.sh`; `test_o19`/`test_o33` now set it → the autodetect-*failure* path is exercised deterministically regardless of process ancestry. 2. **`.gitignore`** now includes `d.db*` and `d.update*` patterns. 3. **Bonus**: the prior review's minor "equals-form argv parsing" edge note (`-r=`) is also resolved — the regex now uses `[[:space:]=]+` (matches both space and `=` forms). The full orc-onboard suite now passes **40/40 in both foreground and detached contexts** (deterministic), and the lib.sh-dependent regression subset passes **69/69** (no regressions). The implementation logic — previously verified correct in e7c13ec2 — is unchanged in substance. --- ## 2. Fix Verification (delta from prior review e7c13ec2) ### 2.1 `MAM_AUTODETECT_FORCE_FAIL` hook — `orc_onboard.sh:76-79` ```bash detect_nearest_agent() { if [ "${MAM_AUTODETECT_FORCE_FAIL:-0}" = "1" ]; then return 3 fi ... ``` Correctly placed at the **top** of `detect_nearest_agent`, before the process-tree walk, returning `3` (the autodetect-failure exit code). The hook is opt-in (defaults to `0`), so the real autodetect-success path is unaffected — confirmed by `test_o25`–`test_o31` still passing. This makes the autodetect-*failure* path testable without depending on live process ancestry. ### 2.2 Test updates — `test_o19` (line 331), `test_o33` (line 537) Both now pass `env={..., "MAM_AUTODETECT_FORCE_FAIL": "1"}` and assert `returncode == 3`. This is the exact fix recommended in the prior report (one env hook + two test edits), applied surgically. ### 2.3 `.gitignore` — `d.db*` / `d.update*` ```diff + d.db* + d.update* ``` Addresses the prior review's hygiene recommendation. Verified no stray `d.db*`/`d.update*` files remain in the repo root after a clean test run. ### 2.4 Bonus: equals-form argv parsing (lines 120/123/126) The prior review noted `--id=` (equals form) parsed empty because the regex only handled the space form. The implementer widened it to `[[:space:]=]+`, handling both forms: - `(-r|--session-id)[[:space:]=]+[^[:space:]]+` (claude) - `--conversation[[:space:]=]+[^[:space:]]+` (agy) - `(--id|--session-id)[[:space:]=]+[^[:space:]]+` (cline) Low-impact robustness improvement, consistent with the SKILL.md auto-detection spec. --- ## 3. Lint | Check | Tool | Result | |---|---|---| | `orc_onboard.sh` syntax | `bash -n` | ✅ PASS | | `lib.sh` syntax | `bash -n` | ✅ PASS | | `orc_onboard.sh` shellcheck | `shellcheck` | ⚠️ Not installed locally; `deploy/gitea-ci.yml` adds the required `shellcheck .../orc_onboard.sh` line (covered by `test_o35`). CI gate covers it. | | `lib.sh` shellcheck | `shellcheck` | ⚠️ Not installed locally (pre-existing, not introduced by this change). | --- ## 4. Behavior (동작성) — Test Results ### 4.1 `tests/test_orc_onboard.py` — DETERMINISTIC ✅ | Run context | Prior review (e7c13ec2) | This review (b6fc4e5a) | |---|---|---| | Foreground (pytest descendant of cline orchestrator session) | 38 passed, 2 failed | **40 passed** (6.27s) | | Detached / reparented to PID 1 | 40 passed | **40 passed** (6.34s) | The two previously-flaky tests (`test_o19_autodetect_failure_exits_3`, `test_o33_no_workspace_cache_fallback`) now pass deterministically in **both** contexts via the `MAM_AUTODETECT_FORCE_FAIL` hook. The non-determinism root cause (live process-tree ancestry) is bypassed for the failure-path tests, and the success-path tests (`test_o25`–`test_o31`) remain unaffected. Full suite: 40/40 PASS. ### 4.2 Regression (lib.sh-dependent suites) — PASS ✅ `tests/test_uuid_target.py tests/test_b4_session_created.py tests/test_o1_rebuttal.py tests/test_deploy_layout.py tests/test_deploy_freshness.py tests/test_deploy_registry_merge.py` → **69 passed in 103.07s**. The lib.sh changes (orchestrator_uuids gate, `verify_session_uuid`/`find_workspace_uuid` exclusion, `atomic_dump_yaml`/`load_state_json` touchpoints) introduced **no regressions** — identical to the prior review's result. --- ## 5. Implementation Review (unchanged in substance from e7c13ec2; re-confirmed) ### 5.1 `lib.sh` — exclusion gate (correct) - `_validate` orchestrator_uuids: list, non-empty strings, no duplicates. ✅ (`test_o20`–`test_o22`) - `get_all_sessions_status`: `__orchestrator_uuids__` sha256 entry for reconcile change detection. ✅ - `mam_orchestrator_uuids()`: cached; `MAM_ORCHESTRATOR_UUIDS` override (empty/JSON/comma) → `MAM_STATE_JSON` → sqlite DB → YAML; malformed → stderr warning + degrade to `[]` (open gate). ✅ (`test_o40`) - `mam_row_own_uuid(row)`: first non-null `*_own` across agent families. ✅ - `verify_session_uuid` discover exclusion: `if mode=="discover" and uuid in mam_orchestrator_uuids() and uuid != mam_row_own_uuid(row): return False` + `workspace_key()` normalization. ✅ (`test_o39`) - `find_workspace_uuid` discovery: builds `orchestrator_ids`, discards target's own UUID, `emit()` skips `running_ids ∪ orchestrator_ids`. ✅ (`test_o1`–`test_o16`) ### 5.2 `orc_onboard.sh` (correct) - Arg parsing, `is_valid_id` (UUID + cline `^[0-9]{10,}_[0-9A-Za-z]+$`), `--list`, running-session conflict (exit 1), `atomic_dump_yaml` mutation. ✅ (`test_o17`/`test_o18`/`test_o38`) - `detect_nearest_agent()`: process-tree walk, family basename match, argv-then-env extraction, stop at nearest agent ancestor, `return 3` on failure. `MAM_AUTODETECT_FORCE_FAIL` hook short-circuits to `return 3`. ✅ - `SKILL.md` frontmatter + auto-detection hierarchy docs. ✅ (`test_o37`) ### 5.3 Deploy wiring `deploy/gitea-ci.yml` (+shellcheck line) and `deploy/remove.sh` (+fallback_assets entry). ✅ (`test_o34`/`test_o35`) --- ## 6. Loss / Hygiene (유실) - **No orphaned call sites**: `verify_session_uuid`/`find_workspace_uuid` signatures preserved; 69-test regression confirms backward compatibility. - **Artifacts now gitignored**: `d.db*`/`d.update*` added to `.gitignore`; no stray files in repo root after a clean run. Prior hygiene issue resolved. - **No regressions**: lib.sh changes are behavior-preserving for non-orchestrator-uuid paths. --- ## 7. Verdict The prior review's two blockers are both resolved: 1. **Non-deterministic test suite** → fixed via `MAM_AUTODETECT_FORCE_FAIL` hook + updated `test_o19`/`test_o33`; suite now passes 40/40 deterministically in both foreground and detached contexts. 2. **Ungitignored test-pollution artifacts** → fixed via `.gitignore` `d.db*`/`d.update*` patterns. A bonus robustness fix (equals-form argv parsing) was also applied. The implementation logic is correct, atomic, and regression-free (69/69). No design-level rework is needed. [VERDICT: PASS] [VERDICT: PASS]