From 263a72483ad06539d8edf3e0f168469b1a15301f Mon Sep 17 00:00:00 2001 From: Godopu Date: Sun, 25 Oct 2026 17:00:25 +0000 Subject: [PATCH] fix(stop): a row-less stop uses the environment's server; only "no row" is row-less (Issue #71) With no --herdr-session the server is chosen as create_session.sh chose it (HERDR_SESSION_NAME, else the workspace's), not always derived from the workspace. The row-less path runs only when the lookup says the row is missing (exit 7); any other lookup failure stops with exit 1 as before. Pins of the shifted stop_session.sh lines updated. Refs #71 Co-Authored-By: Claude Opus 5.5 --- .../multi-agent-mux-stop/scripts/stop_session.sh | 16 ++++++++++++++-- tests/data/skill_code_blocks.json | 8 ++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.agents/skills/multi-agent-mux-stop/scripts/stop_session.sh b/.agents/skills/multi-agent-mux-stop/scripts/stop_session.sh index 2bb91ba..0bff957 100755 --- a/.agents/skills/multi-agent-mux-stop/scripts/stop_session.sh +++ b/.agents/skills/multi-agent-mux-stop/scripts/stop_session.sh @@ -106,6 +106,7 @@ if [ "$PURGE" = "1" ]; then trap 'rm -f "$WORKSPACE_ROOT/.mam/purging-$SESSION_NAME"' EXIT fi +AMBIENT_HERDR_SESSION="${HERDR_SESSION_NAME:-}" if [ -n "$HERDR_SERVER_OPT" ]; then export HERDR_SESSION_NAME="$HERDR_SERVER_OPT" else @@ -116,12 +117,17 @@ fi # Issue #71: a session with no registry row (its create/resume died before # registering it) is closed here - herdr only, the registry is left alone. It # has no agent kind, so --agent is not needed. Only a session herdr runs -# inside this workspace is closed; anything else changes nothing. +# inside this workspace is closed; anything else changes nothing. With no row +# the server is chosen as create_session.sh chose it: --herdr-session, else +# the environment's HERDR_SESSION_NAME, else the workspace's server. stop_rowless() { if [ "$PURGE" = "1" ]; then echo "ERROR: session '$SESSION_NAME' not in $AGENT_SESSIONS_YAML; --purge-conversation needs its row. Nothing changed." >&2 exit 1 fi + if [ -z "$HERDR_SERVER_OPT" ] && [ -n "$AMBIENT_HERDR_SESSION" ] && [ "$AMBIENT_HERDR_SESSION" != "default" ]; then + export HERDR_SESSION_NAME="$AMBIENT_HERDR_SESSION" + fi local info cwd info=$(herdr agent get "$SESSION_NAME" 2>/dev/null) || info="" if [ -z "$info" ]; then @@ -173,7 +179,13 @@ for s in d.get('herdr_sessions', []): 'delegate_job_logs_dir': cp.get('delegate_job_logs_dir', '') or ''})) sys.exit(0) sys.exit(7) -") || stop_rowless +") || MAPPED_RC=$? +# 7 = no row; any other failure (registry unreadable) stops as before. +[ "${MAPPED_RC:-0}" -ne 7 ] || stop_rowless +if [ "${MAPPED_RC:-0}" -ne 0 ]; then + echo "ERROR: cannot read the row of '$SESSION_NAME' from $AGENT_SESSIONS_YAML" >&2 + exit 1 +fi # --agent 미지정 시 레지스트리 기록으로 해석 (B-21). # ① row['agent'] → ② 세션명 접미사 → ③ pane.cmd 순. 셋 다 실패하면 diff --git a/tests/data/skill_code_blocks.json b/tests/data/skill_code_blocks.json index 4c1eea2..2a7addb 100644 --- a/tests/data/skill_code_blocks.json +++ b/tests/data/skill_code_blocks.json @@ -433,7 +433,7 @@ "class": "c", "kind": "diagram", "evidence": [ - "multi-agent-mux-stop/scripts/stop_session.sh:228-242" + "multi-agent-mux-stop/scripts/stop_session.sh:240-254" ], "mismatch": null, "note": "state machine" @@ -504,8 +504,8 @@ "class": "a", "evidence": [ "multi-agent-mux-stop/scripts/stop_session.sh:101", - "multi-agent-mux-stop/scripts/stop_session.sh:120-176", - "multi-agent-mux-stop/scripts/stop_session.sh:228-232" + "multi-agent-mux-stop/scripts/stop_session.sh:123-188", + "multi-agent-mux-stop/scripts/stop_session.sh:240-244" ], "mismatch": [ "T1: the doc offered --force-no-yaml, which no script accepts" @@ -601,7 +601,7 @@ "other" ], "passthrough": { - "1": "multi-agent-mux-stop/scripts/stop_session.sh:367" + "1": "multi-agent-mux-stop/scripts/stop_session.sh:379" } }, "multi-agent-mux-create/scripts/create_session.sh": {