chore(autoplay): 🔧 Add remote batch root directory configuration to handle remote host auto-commit divergence

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
autocommit 2026-04-17 19:08:38 -07:00
parent 863b953f78
commit 88bbe38143

View file

@ -26,6 +26,12 @@
# (default 0). Use for multi-sweep runs that share a parent
# results_dir and need disjoint seed numbers (e.g. Task #10
# AI_PIN_PERSONALITY rotation: 5× batches at offsets 0,10,20,30,40).
# REMOTE_BATCH_ROOT — Where remote autoplay batches write their output on the
# AUTOPLAY_HOST. Defaults to /tmp/@magic-civilization/builds
# so artifacts land OUTSIDE the remote host's dev working tree
# (writing into the working tree causes auto-commit divergence
# between hosts). Override to $REMOTE_HOME/... if the remote
# host is a pure build node without active development.
set -euo pipefail
@ -61,6 +67,7 @@ if ! [[ "$TURN_LIMIT" =~ ^[0-9]+$ ]] || [ "$TURN_LIMIT" -lt 1 ]; then
fi
AUTOPLAY_HOST="${AUTOPLAY_HOST:-}"
REMOTE_BATCH_ROOT="${REMOTE_BATCH_ROOT:-/tmp/@magic-civilization/builds}"
SAFETY_TIMEOUT=$(( TURN_LIMIT * 2 + 300 ))
PARALLEL="${PARALLEL:-1}"
@ -200,13 +207,14 @@ _run_remote() {
echo "[seed $seed] Running via SSH on $AUTOPLAY_HOST..."
# Write remote batch artifacts OUTSIDE the dev tree to /tmp so they cannot
# trigger auto-commit divergence on the remote host's working copy.
# REMOTE_BATCH_ROOT (default /tmp/@magic-civilization/builds) keeps batch
# artifacts OUTSIDE the remote host's dev working tree so they cannot
# trigger auto-commit divergence between hosts.
# Derive a unique remote dir from RESULTS_DIR's basename to avoid per-clan
# path collisions when multiple batches run in parallel with the same STAMP.
local results_basename
results_basename="$(basename "$RESULTS_DIR")"
local remote_game_dir="/tmp/@magic-civilization/builds/.local/batches/${results_basename}/game_${STAMP}_seed${seed}"
local remote_game_dir="$REMOTE_BATCH_ROOT/.local/batches/${results_basename}/game_${STAMP}_seed${seed}"
local remote_runner="$REMOTE_HOME/bin/run_ap3.sh"
ssh "$AUTOPLAY_HOST" "