From 534a26dfdcac61ec03c401c77efe13e34727093c Mon Sep 17 00:00:00 2001 From: chemica_tan Date: Tue, 21 Jul 2026 07:07:51 +0900 Subject: [PATCH] fix(codex): compare status metadata project as canonical normalized paths The bridge records its meta project via Node's path.resolve (C:\x\y on Windows) while delivery.sh callers pass Git Bash spellings (/c/x/y or C:/x/y), so the verbatim compare from f6a8bcb (#232) labeled every live bridge "stale pidfile (metadata mismatch)" on Windows. Reuse the project-identity machinery the launcher already relies on (agmsg_canonical_path + agmsg_normalize_project_path) on both sides. Read-only status path; kill/spawn gating is unaffected. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01PwnD2ZoEN1adKuqfbeBKg5 --- scripts/drivers/types/codex/_delivery.sh | 12 +++++- tests/test_delivery.bats | 48 ++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/scripts/drivers/types/codex/_delivery.sh b/scripts/drivers/types/codex/_delivery.sh index 8fc262e4..976e33f8 100644 --- a/scripts/drivers/types/codex/_delivery.sh +++ b/scripts/drivers/types/codex/_delivery.sh @@ -103,7 +103,7 @@ agmsg_delivery_runtime_status() { fi found=1 - local base pidfile metafile pid meta_pid meta_project meta_type meta_ok + local base pidfile metafile pid meta_pid meta_project meta_type meta_ok want_proj have_proj base="$RUN_DIR/codex-bridge.$team.$name" pidfile="$base.pid" metafile="$base.meta" @@ -129,7 +129,15 @@ agmsg_delivery_runtime_status() { meta_project=$(awk -F= '/^project=/{sub(/^project=/, ""); print; exit}' "$metafile" 2>/dev/null || true) meta_type=$(awk -F= '/^type=/{sub(/^type=/, ""); print; exit}' "$metafile" 2>/dev/null || true) [ -n "$meta_pid" ] && [ "$meta_pid" != "$pid" ] && meta_ok=0 - [ -n "$meta_project" ] && [ "$meta_project" != "$project" ] && meta_ok=0 + # The bridge records its project via Node's path.resolve (C:\x\y on + # Windows) while callers pass Git Bash spellings (/c/x/y or C:/x/y), so a + # verbatim compare mislabels every live bridge stale. Compare canonical + # normalized forms instead. + if [ -n "$meta_project" ]; then + want_proj="$(agmsg_normalize_project_path "$(agmsg_canonical_path "$project")")" + have_proj="$(agmsg_normalize_project_path "$(agmsg_canonical_path "$meta_project")")" + [ "$have_proj" != "$want_proj" ] && meta_ok=0 + fi [ -n "$meta_type" ] && [ "$meta_type" != "$type" ] && meta_ok=0 if [ "$meta_ok" -ne 1 ]; then echo "Codex bridge: $team/$name stale pidfile (metadata mismatch)" diff --git a/tests/test_delivery.bats b/tests/test_delivery.bats index effda25f..15b93dd9 100644 --- a/tests/test_delivery.bats +++ b/tests/test_delivery.bats @@ -1767,6 +1767,54 @@ EOF [[ "$output" != *"watch processes:"* ]] } +@test "delivery status (codex): metadata project spelling variant is not a mismatch" { + bash "$SCRIPTS/join.sh" team alice codex "$TEST_PROJECT" >/dev/null + bash "$SCRIPTS/delivery.sh" set monitor codex "$TEST_PROJECT" >/dev/null + mkdir -p "$TEST_SKILL_DIR/run" + + # Same directory, different spelling (trailing slash). A verbatim compare + # calls this a mismatch; canonical comparison must not. + printf '%s\n' "$$" > "$TEST_SKILL_DIR/run/codex-bridge.team.alice.pid" + cat > "$TEST_SKILL_DIR/run/codex-bridge.team.alice.meta" </dev/null + bash "$SCRIPTS/delivery.sh" set monitor codex "$TEST_PROJECT" >/dev/null + mkdir -p "$TEST_SKILL_DIR/run" + + # The bridge records the project via Node's path.resolve, i.e. the + # backslash form cygpath -w produces — the exact shape that made every + # live bridge read as "metadata mismatch" on Windows. + local win_project + win_project="$(cygpath -w "$TEST_PROJECT")" + printf '%s\n' "$$" > "$TEST_SKILL_DIR/run/codex-bridge.team.alice.pid" + cat > "$TEST_SKILL_DIR/run/codex-bridge.team.alice.meta" </dev/null bash "$SCRIPTS/delivery.sh" set monitor codex "$TEST_PROJECT" >/dev/null