# Cross-Code Review — Job 8f0cb35f - **Reviewer**: cline (session: herdr:canary-projects-multi-agent-mux-creator-cline) - **Subject**: Final implementation of the right-growth 2xK grid TUI layout engine (`.agents/skills/lib_py/layout.py`) + `lib.sh` integration, including the changeset that resolves the G-1/G-2 findings from the prior review (job `71741b21`). - **Changeset**: `git diff` — `lib.sh` (layout block refactor, 30 deletions / 4 additions), new `lib_py/layout.py` (199 lines), new `tests/test_layout.py` (333 lines, 16 tests). - **Date**: 2026-08-23 --- ## §0 Executive Summary The changeset fully and correctly resolves every finding raised in the prior review cycle (F-1, F-2, F-3, G-1, G-2). The critical regression — the shim invoking the undefined `_delegate_py_bin` bash function, which silently bypassed the layout engine — is eliminated: the layout block now calls `python3 -m lib_py.layout` directly, exactly as the brief required. I verified the fix at three independent levels (source diff, real generated shim artifact, and an empirical `set -euo pipefail` reproduction) and ran the relevant test suites (99 tests across 5 files, all passing). The layout engine itself is a clean, pure-stdlib implementation covering the full 2xK transition graph (1->2 ... 5->6), overflow, and headless 0x0 mode. The legacy ~30-line inline Python snippet was removed cleanly with no orphaned references. **Verdict: PASS.** --- ## §1 Prior-Finding Resolution (all verified fixed) ### G-1 CRITICAL -> FIXED (root cause eliminated) - **Prior root cause**: The fix in job `71741b21` bridged the shim heredoc to `_delegate_py_bin()` — a bash function defined *outside* the heredoc (lib.sh:1379) and not `export -f`'d — so the standalone shim subprocess hit `command not found`, silently falling back to `right` (engine bypassed). - **Fix**: `lib.sh:432` now invokes the engine as a real module: ``` read -r split_dir split_target < <(printf '%s' "$layout_raw" | python3 -m lib_py.layout --min-cols "${MAM_MIN_PANE_COLS:-60}" --min-rows "${MAM_MIN_PANE_ROWS:-20}" --sample-pane "$sample_pane" 2>/dev/null || echo "right $sample_pane") ``` No bash function is referenced; `python3` (present on PATH, parity with the 17 other `python3 -c` calls in the heredoc) runs the module directly. - **Verification**: 1. *Source*: `grep` of the edited block (lib.sh:428-435) -> no `_delegate_py_bin`, no `local`, no `PYTHONPATH=` prefix. 2. *Real generated shim* (`$WORKSPACE_ROOT/.mam/shim/herdr`): `grep -c "python3 -m lib_py.layout"` = **1**; `grep -c "_delegate_py_bin"` = **0**; no `local layout_`/`local split_`. 3. *Empirical reproduction* (simulated shim, `set -euo pipefail`, no `_delegate_py_bin` in scope): output `split_dir=down split_target=p1`, exit 0, empty stderr — the engine executes and yields the correct direction, with **no `command not found`**. ### G-2 MAJOR -> FIXED (false-positive test removed) - **Prior issue**: `test_lib_sh_layout_split_in_set_e_subshell` (job `71741b21`) defined `_delegate_py_bin` in its own script, masking G-1 (14/14 pass while the live path was broken). - **Fix**: The test (now at test_layout.py:265) no longer references `_delegate_py_bin`; it runs the exact lib.sh:429-435 snippet verbatim with `python3 -m lib_py.layout` and asserts `SPLIT_DIR=down` / `SAMPLE_PANE=p1` under `set -euo pipefail`. A *real generated shim* integration test (`test_real_generated_shim_layout_split`, line 301) was added that sources `lib.sh`, calls `_init_herdr_isolation`, and inspects the **real artifact** (not heredoc text) for executability and absence of `local layout_`. ### F-1 -> still FIXED - No `local` keyword in the layout block (plain assignments). Static guard `test_lib_sh_no_local_in_shim_heredoc` (checks `"local "` absent from an 800-char window of the heredoc) plus the real-shim grep guard both present. Real shim grep -> none. ### F-2 -> still FIXED - No `PYTHONPATH=...` command-prefix. The invocation relies on the `export PYTHONPATH` (lib.sh:25) inherited by the shim subprocess. Confirmed empirically: the module loads under the inherited `PYTHONPATH` and emits `down`. ### F-3 -> still FIXED - Single `python3 -m lib_py.layout` process, output parsed once by `read -r split_dir split_target`. No double-invocation / double-parse. --- ## §2 Test Coverage & DoD **Layout unit/integration suite** (`tests/test_layout.py`, 16 tests, 0.16s) — all PASS: - 1->2 split down; height-constrained -> right; width overflow - 2->3 new column right; 3->4 fill singleton down; 4->5 new column right; 5->6 fill 3rd-col singleton down - 4-panes overflow; max-columns limit; headless 0x0 (count-N alternation) - real-herdr 0.80 nested format; CLI pipe contract (`