7.7 KiB
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.shintegration, including the changeset that resolves the G-1/G-2 findings from the prior review (job71741b21). - Changeset:
git diff—lib.sh(layout block refactor, 30 deletions / 4 additions), newlib_py/layout.py(199 lines), newtests/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
71741b21bridged the shim heredoc to_delegate_py_bin()— a bash function defined outside the heredoc (lib.sh:1379) and notexport -f'd — so the standalone shim subprocess hitcommand not found, silently falling back toright(engine bypassed). - Fix:
lib.sh:432now invokes the engine as a real module:No bash function is referenced;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")python3(present on PATH, parity with the 17 otherpython3 -ccalls in the heredoc) runs the module directly. - Verification:
- Source:
grepof the edited block (lib.sh:428-435) -> no_delegate_py_bin, nolocal, noPYTHONPATH=prefix. - Real generated shim (
$WORKSPACE_ROOT/.mam/shim/herdr):grep -c "python3 -m lib_py.layout"= 1;grep -c "_delegate_py_bin"= 0; nolocal layout_/local split_. - Empirical reproduction (simulated shim,
set -euo pipefail, no_delegate_py_binin scope): outputsplit_dir=down split_target=p1, exit 0, empty stderr — the engine executes and yields the correct direction, with nocommand not found.
- Source:
G-2 MAJOR -> FIXED (false-positive test removed)
- Prior issue:
test_lib_sh_layout_split_in_set_e_subshell(job71741b21) defined_delegate_py_binin 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 withpython3 -m lib_py.layoutand assertsSPLIT_DIR=down/SAMPLE_PANE=p1underset -euo pipefail. A real generated shim integration test (test_real_generated_shim_layout_split, line 301) was added that sourceslib.sh, calls_init_herdr_isolation, and inspects the real artifact (not heredoc text) for executability and absence oflocal layout_.
F-1 -> still FIXED
- No
localkeyword in the layout block (plain assignments). Static guardtest_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 theexport PYTHONPATH(lib.sh:25) inherited by the shim subprocess. Confirmed empirically: the module loads under the inheritedPYTHONPATHand emitsdown.
F-3 -> still FIXED
- Single
python3 -m lib_py.layoutprocess, output parsed once byread -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 (
<dir> <pane>) - no-
localstatic guard; malformed/empty fallback - set-e subshell (F-1/F-2/G-1 live snippet); real generated shim (G-2 artifact inspection)
Broader suite (DoD #4 — sampled; the e2e/tier3-4 files are slow/subprocess-heavy and exceed the 30s run-window; sampled the relevant contracts):
tests/test_layout.py-> 16 passedtests/test_tier1_unit.py-> 45 passedtests/test_sanity.py+tests/test_deploy_freshness.py-> 33 passedtests/test_herdr_shim_contract.py-> 5 passed
Total confirmed passing: 99 tests across 5 files, 0 failures.
§3 Soundness & Cleanup
layout.py(199 lines): pure stdlib (dataclasses,typing,json,sys,os,argparse) — no external dependency, sopython3on PATH suffices (consistent with the other 17python3 -cheredoc calls).- CLI contract: emits
<direction> <target_pane_id>(or<direction>), parsed by the singleread -r— contract aligned with the integration. - Cleanup: orphan scan of the heredoc (lib.sh:142-907) -> no
_delegate_py_bin, no legacyMAM_MIN_COLS=/MAM_MIN_ROWS=env-prefix style; the old ~30-line inline snippet was deleted cleanly (no dangling comments/variables). - Fallback safety net:
|| echo "right $sample_pane"+${split_dir:-right}preserve graceful degradation if the module ever fails to load, without aborting underset -e.
§4 Minor Observations (non-blocking)
test_real_generated_shim_layout_splitdocstring vs. body: the docstring claims to verify the shim "executes layout.py without command not found", but the body only checks (a) the shim is generated & executable and (b) nolocal layout_appears — it does not run the shim'snew-sessionlayout path end-to-end. This is adequately compensated bytest_lib_sh_layout_split_in_set_e_subshell, which runs the exact snippet live and assertsdown. Recommend aligning the docstring with what the test actually asserts, or adding an end-to-end shim execution step. (Cosmetic/coverage, not a defect.)- Real-shim grep pattern
'^[[:space:]]*local layout_'is narrower than the heredoc-text test's broad"local "check; it would not catch a hypotheticallocal split_target. The two guards together cover the keyword, so this is acceptable. Slightly tightening the pattern to'^[[:space:]]*local 'would be more robust. - PYTHONPATH inheritance dependency: the shim relies on
export PYTHONPATH(lib.sh:25) being inherited by the subprocess. This holds whenever the shim is invoked viamam_herdrfrom a context that sourcedlib.sh(the intended call path) and was confirmed empirically. No regression vs. the prior design; noted for completeness.
None of the above warrant a NOT PASS verdict or a planner escalation. They are improvement opportunities only.
§5 Verdict
All findings from the prior review are resolved, the implementation meets the brief's four objectives (algorithm, integration, tests, DoD), the cleanup is complete, and 99 sampled tests pass with the layout engine empirically confirmed to execute in the real shim context.
[VERDICT: PASS]