Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions scripts/drivers/types/codex/_delivery.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)"
Expand Down
48 changes: 48 additions & 0 deletions tests/test_delivery.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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" <<EOF
pid=$$
project=$TEST_PROJECT/
team=team
name=alice
type=codex
EOF

run bash "$SCRIPTS/delivery.sh" status codex "$TEST_PROJECT"
[ "$status" -eq 0 ]
[[ "$output" == *"Codex bridge: team/alice"* ]]
[[ "$output" != *"metadata mismatch"* ]]
}

@test "delivery status (codex): metadata project in native Windows spelling is not a mismatch" {
case "$(uname -s)" in MINGW*|MSYS*|CYGWIN*) ;; *) skip "needs a real Windows path spelling (cygpath)" ;; esac
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"

# 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" <<EOF
pid=$$
project=$win_project
team=team
name=alice
type=codex
EOF

run bash "$SCRIPTS/delivery.sh" status codex "$TEST_PROJECT"
[ "$status" -eq 0 ]
[[ "$output" == *"Codex bridge: team/alice"* ]]
[[ "$output" != *"metadata mismatch"* ]]
}

@test "delivery status (codex): missing bridge metadata is reported as stale" {
bash "$SCRIPTS/join.sh" team alice codex "$TEST_PROJECT" >/dev/null
bash "$SCRIPTS/delivery.sh" set monitor codex "$TEST_PROJECT" >/dev/null
Expand Down
Loading