From 60838c293f234d06ddae7cf946e736ff22fd1384 Mon Sep 17 00:00:00 2001 From: Natalie Date: Sat, 16 May 2026 23:10:37 -0700 Subject: [PATCH] =?UTF-8?q?fix(@projects/magic-civilization):=20?= =?UTF-8?q?=F0=9F=90=9B=20add=20godot=20process=20check=20for=20batch=20st?= =?UTF-8?q?atus?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- scripts/apricot-run.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/apricot-run.sh b/scripts/apricot-run.sh index 5ad23b33..4aa8e9e0 100755 --- a/scripts/apricot-run.sh +++ b/scripts/apricot-run.sh @@ -263,18 +263,27 @@ if [[ "${MODE}" == "status" ]]; then QUERY_STAMP="${1:?usage: apricot-run.sh status }" UNIT="mc-batch-${QUERY_STAMP}" - # Single ssh probe with short ConnectTimeout. Three lightweight queries: + # Single ssh probe with short ConnectTimeout. Four lightweight queries: # 1. systemctl --user is-active (active|inactive|failed|unknown) # 2. count of completion.marker files under /*/ # 3. count of turn_stats.jsonl files under /*/game_*/ + # 4. count of live godot processes for THIS batch stamp # We also read seeds_total from the first submode dir if present. + # + # The godot-proc count is load-bearing: `flatpak run` detaches into a + # systemd user scope, so autoplay-batch.sh's `wait` returns and + # completion.marker is touched while the actual godot processes are still + # running headless games. Without checking live procs, fetch would pull + # mid-run turn_stats with outcome=in_progress and the consumer would + # think the gate failed when in fact games hadn't finished yet. PROBE='set +e IS_ACTIVE=$(systemctl --user is-active '"${UNIT}"' 2>/dev/null || echo unknown) MARKER_COUNT=$(ls "$HOME/.cache/mc-batches/'"${QUERY_STAMP}"'"/*/completion.marker 2>/dev/null | wc -l | tr -d " ") STATS_COUNT=$(ls "$HOME/.cache/mc-batches/'"${QUERY_STAMP}"'"/*/game_*/turn_stats.jsonl 2>/dev/null | wc -l | tr -d " ") + GODOT_PROCS=$(pgrep -af "godot.*'"${QUERY_STAMP}"'" 2>/dev/null | grep -c "godot --path" || echo 0) SEEDS_TOTAL=$(cat "$HOME/.cache/mc-batches/'"${QUERY_STAMP}"'"/*/seeds_total 2>/dev/null | head -1) SEEDS_TOTAL=${SEEDS_TOTAL:-0} - printf "%s|%s|%s|%s\n" "$IS_ACTIVE" "$MARKER_COUNT" "$STATS_COUNT" "$SEEDS_TOTAL"' + printf "%s|%s|%s|%s|%s\n" "$IS_ACTIVE" "$MARKER_COUNT" "$STATS_COUNT" "$SEEDS_TOTAL" "$GODOT_PROCS"' PROBE_OUT="$(ssh -o ConnectTimeout=5 -o BatchMode=yes "${APRICOT}" "${PROBE}" 2>/dev/null)" || PROBE_OUT=""