Repository navigation
fix: bind an ephemeral port in session-self-exit-test.sh - #327
Merged
Merged
Conversation
bborbe
marked this pull request as ready for review
October 20, 2026 14:16
Contributor
There was a problem hiding this comment.
Review complete. This is a small, targeted bugfix. Here's the assessment:
Diff summary: 2 files — CHANGELOG.md (+1 unreleased bullet) and scripts/session-self-exit-test.sh (+20/−2: ephemeral port function + server-up guard).
Correctness:
free_port()correctly binds port 0 and reads back the assigned ephemeral port- The
server_upguard (lines 158–169) properly fails with exit 2 if the stub never responds, solving the original silent failure mode trapcleanup at line 31 correctly kills the server on exit- Port bound to
127.0.0.1(notlocalhost) — no DNS dependency
No issues found.
{
"verdict": "approve",
"summary": "Targeted bugfix that replaces a hardcoded port (18099) with an ephemeral port and adds a loud failure if the stub server doesn't respond — directly addresses the observed CI failure where port collisions were silent.",
"comments": [],
"concerns_addressed": [
{
"concern": "correctness: test script port binding may fail if ephemeral port selection logic is incorrect",
"disposition": "addressed",
"detail": "free_port() uses Python socket.bind(('127.0.0.1', 0)) which delegates port selection to the OS — correct and standard pattern. The server-up guard (lines 158-169) additionally ensures the stub actually responds before tests run."
}
]
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
scripts/session-self-exit-test.shhardcodedPORT=18099for its stub attention store. On a host where anything else already listens on that port, the stub server fails to bind silently — and the test then reads whatever is on that port. A 404 on/api/1.0/attentionis treated bysession-self-exit.pyas "store unreadable, not a clear gate", so the five cases that expect a clear gate fail.Observed 2026-10-20: two unrelated processes held 18099 on the operator's Mac — a
coding/benchnode fixture up two days, and an orphaned/private/tmp/sc2-stubserver.make testwas red on the host and green in CI, where nothing squats the port.Fix
Verification
bash scripts/session-self-exit-test.sh→session-self-exit: 18 passed(was13 passed, 5 failed)make precommit→ exit 0