Skip to content

test: check the lanes' first look by structure, not by a zero-second clock - #121

Merged
addisdev merged 3 commits into
mainfrom
test/lane-wait-first-look
Oct 27, 2026
Merged

addisdev merged 3 commits into
mainfrom
test/lane-wait-first-look

Conversation

@addisdev

@addisdev addisdev commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

Two assertions in hooks/tests/run.sh's "lanes observe" block required lane_wait_s to be exactly 0. They failed once on a GitHub-hosted macOS runner with 1 (run 40331626282 on #120, a docs-only PR) and passed on a rerun.

Why it flakes: lane_wait_s is WAITED at the moment the lanes first said yes. WAITED starts counting before the hook runs admit_resolve_wait_owner and admit_resolve_worker_log. On a loaded runner that setup can cross a whole-second boundary before the first look, so the first look records 1.

Why not just allow ≤ 1: that would weaken the second check. The bug it guards against is lane_wait_s being re-taken at admission instead of at the first look, and then it would equal waited_s, which can itself be 1.

What it checks instead. The hook writes the held row once, at the end of its first pass, which gives checks that don't depend on timing:

Row Was Now
held lane_wait_s == 0 lane_wait_s is a number, not null, so it was recorded at the first look
admitted lane_wait_s == 0 equals the held row's lane_wait_s, and lane_wait_s < waited_s (not re-taken at admission, which is always at least one poll later)

This is the same idea as #76, which times two other "promptly" checks from the hook's own events. The two PRs touch different hunks of run.sh.

Mutation-checked: I temporarily made the hook overwrite ADMIT_LANE_WAIT on every pass (dropping the [ -n "$ADMIT_LANE_WAIT" ] || guard). Both admitted-row checks fail (expected '0', got '2' and not before). The hook was restored and is not part of this diff.

Second commit (91f53b7): the first push put a case … esac inside $(…). macOS's /bin/bash 3.2 can't parse that, so CI stopped at line 972 with a syntax error. Bash 5 and bash -n on Linux accept it. The case now sets a variable that the ok line compares; no other $(case exists in the repo.

Platform tested on

  • macOS: not run locally on macOS. CI's Shell tests job runs this file on macos-latest, and that's what caught the bash 3.2 parse error above. I couldn't get a bash 3.2 binary into this environment (GNU's FTP site and GitHub mirrors are blocked by its proxy), so macOS CI is the bash 3.2 check.
  • Linux (cloud container, bash 5.2): the whole lanes-observe block passes. Two other checks, "beta got in promptly" and "orphaned hook exited", fail in this container on unmodified main too (148 pass / 2 fail on main, 149 / 2 with this change). So they're environmental here and unrelated.
  • Node: node -v → v22.22.0 (not used by this test)

Checklist

  • Tests pass: cd dashboard && npm test (no dashboard change)
  • Shell syntax clean: bash -n OK; shellcheck --severity=warning hooks/tests/run.sh clean (same 5 info-level notes as main)
  • No host-specific data: CI's "Release check (offline)" passed on the first push; couldn't run locally (no authenticated gh)
  • Docs updated if behaviour changed (test-only change)
  • Schema migration (n/a)
  • New environment variables (n/a)
  • Security-sensitive change (n/a)

🤖 Generated with Claude Code

https://claude.ai/code/session_019W86FcknjPBqAPtVcnH8Ja

…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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019W86FcknjPBqAPtVcnH8Ja
claude and others added 2 commits October 26, 2026 14:24
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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019W86FcknjPBqAPtVcnH8Ja
@addisdev
addisdev merged commit 22a6f5f into main Oct 27, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants