launch.sh: resolve script to absolute path (SELF) so the watchdog re-invokes correctly

Bug: start_watchdog used $0, which breaks when launch.sh is called by a relative path
(the watchdog tmux session cd's into PLAN_DIR, so a relative $0 no longer resolves —
"No such file or directory", watchdog dies instantly). Resolve BASH_SOURCE to an absolute
SELF once and use it for the watchdog self-invocation. Verified: watchdog now starts and
its handoff_check immediately pinged the Adversary about a standing CLAIMED gate.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-27 06:16:54 +01:00
parent 239dfd8e26
commit 649b90b586

View File

@ -23,6 +23,10 @@
set -euo pipefail
# Absolute path to this script, so the watchdog re-invokes it correctly regardless of how it
# was called or what cwd the tmux session uses (a relative $0 breaks once we cd into PLAN_DIR).
SELF="$(readlink -f "${BASH_SOURCE[0]}")"
# ----- config -------------------------------------------------------------
PLAN_DIR="${PLAN_DIR:-/srv/cc-ci/cc-ci-plan}"
CLAUDE_BIN="${CLAUDE_BIN:-claude}"
@ -181,7 +185,7 @@ start_watchdog() {
fi
log "starting watchdog"
tmux new-session -d -s "$WATCHDOG_SESSION" -c "$PLAN_DIR" \
"exec >>'$LOG_DIR/watchdog.log' 2>&1; '$0' watchdog"
"exec >>'$LOG_DIR/watchdog.log' 2>&1; '$SELF' watchdog"
}
stop_loops() {