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 <noreply@anthropic.com>
This commit is contained in:
GodopuandClaude Fable 5.1 committed 2026-10-15 00:02:50 +00:00
1 parent 75c004222c
commit 151af99765
2 files changed
+33 -4

No files matched your search

@@ -1093,19 +1093,24 @@ cmd_logs() {
# (Issue #57; $DELEGATE_JOB_LOGS_DIR overrides). parse_opts is for submit's # (Issue #57; $DELEGATE_JOB_LOGS_DIR overrides). parse_opts is for submit's
# globals, so the few options are read here. # globals, so the few options are read here.
PY="$(pick_python)" 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 while [[ $# -gt 0 ]]; do
case "$1" in case "$1" in
--registry-dir) reg="$2"; shift 2;; --registry-dir) reg=(--registry-dir "$2"); shift 2;;
--list) list=1; shift;; --list) list=1; shift;;
*) jid="$1"; shift;; *) jid="$1"; shift;;
esac esac
done done
if [[ "$list" == "1" ]]; then 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 else
[[ -n "$jid" ]] || { echo "logs requires <job_id> or --list" >&2; exit 1; } [[ -n "$jid" ]] || { echo "logs requires <job_id> 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 fi
} }
@@ -533,3 +533,27 @@ d['herdr_sessions'] = [{{'name': 's57-creator-claude', 'status': 'running', 'del
else: else:
(line,) = [l for l in res.stdout.splitlines() if l.startswith("s57-creator-claude")] (line,) = [l for l in res.stdout.splitlines() if l.startswith("s57-creator-claude")]
assert "completed" in line, line 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()