From 151af99765f66f711f47db4509628e47c360eabe Mon Sep 17 00:00:00 2001 From: Godopu Date: Thu, 15 Oct 2026 00:02:50 +0000 Subject: [PATCH] fix(delegate-job): logs passes --registry-dir on only when given (Issue #57, Mac F2) cmd_logs always passed the wrapper's cwd-relative default registry, so the usual run (registry not moved, cwd not the workspace) no longer found its jobs. Without the option registry.py's own default decides, as before: MAM_JOBS_DIR, then WORKSPACE_ROOT, then the cwd. Co-Authored-By: Claude Fable 5.1 --- .../multi-agent-mux-delegate-job | 13 ++++++---- tests/test_issue57_logs_follow_registry.py | 24 +++++++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/.agents/skills/multi-agent-mux-delegate-job/multi-agent-mux-delegate-job b/.agents/skills/multi-agent-mux-delegate-job/multi-agent-mux-delegate-job index 9d0b882..d658619 100755 --- a/.agents/skills/multi-agent-mux-delegate-job/multi-agent-mux-delegate-job +++ b/.agents/skills/multi-agent-mux-delegate-job/multi-agent-mux-delegate-job @@ -1093,19 +1093,24 @@ cmd_logs() { # (Issue #57; $DELEGATE_JOB_LOGS_DIR overrides). parse_opts is for submit's # globals, so the few options are read here. PY="$(pick_python)" - local reg="$REGISTRY_DIR_DEFAULT" jid="" list=0 + # --registry-dir is passed on only when given: registry.py's own default + # follows MAM_JOBS_DIR, then WORKSPACE_ROOT, so the usual run works from any + # cwd (the wrapper's REGISTRY_DIR_DEFAULT is cwd-relative). bash 3.2 + set -u: + # an empty array expands through ${reg[@]+"${reg[@]}"}. + local -a reg=() + local jid="" list=0 while [[ $# -gt 0 ]]; do case "$1" in - --registry-dir) reg="$2"; shift 2;; + --registry-dir) reg=(--registry-dir "$2"); shift 2;; --list) list=1; shift;; *) jid="$1"; shift;; esac done if [[ "$list" == "1" ]]; then - "$PY" "$SCRIPT_DIR/scripts/registry.py" --registry-dir "$reg" logs --list + "$PY" "$SCRIPT_DIR/scripts/registry.py" ${reg[@]+"${reg[@]}"} logs --list else [[ -n "$jid" ]] || { echo "logs requires or --list" >&2; exit 1; } - "$PY" "$SCRIPT_DIR/scripts/registry.py" --registry-dir "$reg" logs "$jid" + "$PY" "$SCRIPT_DIR/scripts/registry.py" ${reg[@]+"${reg[@]}"} logs "$jid" fi } diff --git a/tests/test_issue57_logs_follow_registry.py b/tests/test_issue57_logs_follow_registry.py index c7bc625..94c544c 100644 --- a/tests/test_issue57_logs_follow_registry.py +++ b/tests/test_issue57_logs_follow_registry.py @@ -533,3 +533,27 @@ d['herdr_sessions'] = [{{'name': 's57-creator-claude', 'status': 'running', 'del else: (line,) = [l for l in res.stdout.splitlines() if l.startswith("s57-creator-claude")] assert "completed" in line, line + + +# --------------------------------------------------------------------------- +# Mac review F2: `logs` without --registry-dir follows the workspace, not the cwd +# --------------------------------------------------------------------------- + +def test_logs_without_registry_dir_follows_the_workspace_from_any_cwd(tmp_path, monkeypatch): + for k in DROP: + monkeypatch.delenv(k, raising=False) + ws, elsewhere = tmp_path / "ws", tmp_path / "elsewhere" + (ws / ".mam").mkdir(parents=True) + elsewhere.mkdir() + monkeypatch.setenv("WORKSPACE_ROOT", str(ws)) + res = subprocess.run([sys.executable, str(REGISTRY_PY), "register", "--prompt", "f2", "--agent", "human", + "--agent-session", "herdr:f2"], capture_output=True, text=True, env=_env(ws), + cwd=str(elsewhere), timeout=60) + assert res.returncode == 0, res.stderr + jid = res.stdout.strip() + assert (ws / ".mam" / "jobs" / f"{jid}.json").is_file() and (ws / ".mam" / "delegate_job_logs" / jid).is_dir() + res = _wrapper(ws, "logs", "--list", cwd=elsewhere) + assert res.returncode == 0 and jid in res.stdout, res.stdout + res.stderr + res = _wrapper(ws, "logs", jid, cwd=elsewhere) + assert res.returncode == 0 and "registered" in res.stdout, res.stdout + res.stderr + assert not (elsewhere / ".mam").exists()