From 7572d619b28c27775a88cb15daa4d9b16284f3b3 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 26 Oct 2026 14:17:19 +0000 Subject: [PATCH 1/2] test: check the lanes' first look by structure, not by a zero-second clock Two lanes-observe assertions required lane_wait_s == 0 and failed once on a GitHub-hosted macOS runner with 1 (run 40331626282, passed on rerun). lane_wait_s is WAITED when the lanes first said yes, and WAITED starts before the hook resolves its owner and worker log, so a loaded runner can cross a second boundary before the first look. The held row is written once, at the end of the hook's first pass, so the checks now say what they meant without a clock: - held: lane_wait_s is a number, not null (recorded at the first look) - admitted: lane_wait_s equals the held row's value, and is less than waited_s (not re-taken when the single lane let the job in) Mutation-checked: making the hook overwrite ADMIT_LANE_WAIT on every pass fails both admitted-row checks. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_019W86FcknjPBqAPtVcnH8Ja --- hooks/tests/run.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/hooks/tests/run.sh b/hooks/tests/run.sh index 05adf68..117b071 100755 --- a/hooks/tests/run.sh +++ b/hooks/tests/run.sh @@ -962,7 +962,14 @@ start_bg l-1 wait_for "1" "events held" 10 ok "the single lane held the light job" "$(field "$(row l-1 held)" reason)" "1 job(s) already running, at the limit of 1" ok "...where the lanes would not have" "$(field "$(row l-1 held)" lane_would_hold)" "false" -ok "...from the start of the wait" "$(field "$(row l-1 held)" lane_wait_s)" "0" +# lane_wait_s is WAITED when the lanes first said yes, and the held row is +# written once, at the end of the hook's first pass. So a number there, rather +# than null, is the lanes' answer at the first look. Its value is not checked: +# WAITED starts before the hook resolves its owner and worker log, so a loaded +# runner can cross a second boundary first and record 1 (run 40331626282). +L1_LANE_WAIT="$(field "$(row l-1 held)" lane_wait_s)" +ok "...from its first look" \ + "$(case "$L1_LANE_WAIT" in '' | *[!0-9]*) echo "not recorded ($L1_LANE_WAIT)" ;; *) echo first ;; esac)" "first" ok "the row says which policy decided" "$(field "$(row l-1 held)" lanes)" "observe" ok "the single lane's limit is the one reported" "$(field "$(row l-1 held)" limit)" "1" start_bg h-2 @@ -975,7 +982,12 @@ ok "the single lane admitted its oldest waiter" \ "$(grep '"event":"admitted"' "$LOG" | tail -1 | sed -n 's/.*"runner":"\([^"]*\)".*/\1/p')" "l-1" ok "it waited under the single lane" \ "$([ "$(field "$(row l-1 admitted)" waited_s)" -ge 1 ] && echo waited || echo instant)" "waited" -ok "the lanes would have let it in at once" "$(field "$(row l-1 admitted)" lane_wait_s)" "0" +# Still the first look's answer, not one taken when the single lane let it in: +# that would read as the full wait, which is at least a poll past the first. +L1_ADMITTED="$(row l-1 admitted)" +ok "the lanes would have let it in at once" "$(field "$L1_ADMITTED" lane_wait_s)" "$L1_LANE_WAIT" +ok "...before the single lane did" \ + "$([ "$(field "$L1_ADMITTED" lane_wait_s)" -lt "$(field "$L1_ADMITTED" waited_s)" ] && echo before || echo "not before")" "before" end_jobs echo "== lanes observe with admission observe: would-hold carries the lane view ==" From 91f53b74ecd5ecc986cf000dad0fb19561a84324 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 26 Oct 2026 14:24:58 +0000 Subject: [PATCH 2/2] test: keep the first-look case out of $(...) for macOS bash 3.2 CI's Shell tests stopped at line 972 with "syntax error near unexpected token `('": macOS's /bin/bash 3.2 cannot parse a case statement inside a command substitution, though bash 5 (and bash -n there) accept it. The case now sets a variable that the ok line compares. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_019W86FcknjPBqAPtVcnH8Ja --- hooks/tests/run.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hooks/tests/run.sh b/hooks/tests/run.sh index 117b071..610cd76 100755 --- a/hooks/tests/run.sh +++ b/hooks/tests/run.sh @@ -967,9 +967,13 @@ ok "...where the lanes would not have" "$(field "$(row l-1 held)" lane_would_hol # than null, is the lanes' answer at the first look. Its value is not checked: # WAITED starts before the hook resolves its owner and worker log, so a loaded # runner can cross a second boundary first and record 1 (run 40331626282). +# (The case stays out of $(...): macOS's bash 3.2 cannot parse one in there.) L1_LANE_WAIT="$(field "$(row l-1 held)" lane_wait_s)" -ok "...from its first look" \ - "$(case "$L1_LANE_WAIT" in '' | *[!0-9]*) echo "not recorded ($L1_LANE_WAIT)" ;; *) echo first ;; esac)" "first" +case "$L1_LANE_WAIT" in + '' | *[!0-9]*) L1_FIRST_LOOK="not recorded ($L1_LANE_WAIT)" ;; + *) L1_FIRST_LOOK=first ;; +esac +ok "...from its first look" "$L1_FIRST_LOOK" "first" ok "the row says which policy decided" "$(field "$(row l-1 held)" lanes)" "observe" ok "the single lane's limit is the one reported" "$(field "$(row l-1 held)" limit)" "1" start_bg h-2