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 <noreply@anthropic.com>
This commit is contained in:
GodopuandClaude Opus 5.5 committed 2026-10-25 17:00:25 +00:00
1 parent 5cd72d2df3
commit 263a72483a
2 files changed
+18 -6

No files matched your search

@@ -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 순. 셋 다 실패하면