Repository navigation
feat(scripts): pr-env.sh --peer serves one build twice and peers the two servers - #255
Merged
Merged
Conversation
…two servers Testing cross-server A2A needs two servers on one host, peered, every time. --peer serves the PR's build as "Local" (the ordinary port and state dir) and "Remote" (port+100, its own state dir), waits for both descriptors with a bounded probe, then peers them headlessly with `j5 a2a peer` against each state dir. That mints and revokes a temporary local admin session and never touches the startup pairing grants, so both pairing URLs stay valid; the summary reprints them. Both logs stream interleaved, each line prefixed [Local] or [Remote]. Rerunning re-peers idempotently. Ctrl-C stops both by the PIDs the script captured. Three traps found while proving it on a host that runs the J5 service: the inherited T3_SERVICE_LAUNCHER_CONTEXT must be unset or serve refuses the version mismatch; the readiness probe needs a timeout because the server binds its port before it can answer; and the credential must be captured from stdout alone, since a prefixed stderr inside $(...) ends up in the captured value. Built by Claude Fable 5.1 in Claude Code. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Built by Claude Fable 5.1 in Claude Code. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Jacksondr5
marked this pull request as ready for review
September 23, 2026 03:43
This was referenced Sep 24, 2026
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.
Standalone against
j5/main; not part of the peering stack.--peerneeds a PR build that contains thej5 a2a peerCLI (#173 or later), which every stack PR from #173 up does.Problem
Testing cross-server A2A means two servers on one host, peered, every time. Doing it by hand takes two terminals, a second pairing URL, and four CLI calls in the right order with the right ids.
What this does
scripts/j5/pr-env.sh <pr> --peerserves the PR's build twice from one worktree:statedir, so a single-server rerun of the same PR reuses it.J5_ENV_PEER_PORT) with its ownstate-remotedir.[Local]or[Remote](coloured on a tty), and each is also kept inlocal.log/remote.logunder the env root. The summary reprints both pairing URLs so nobody has to scroll for them.Single-server mode is unchanged.
Traps found while proving it
Eight scratch runs on a host that itself runs the J5 background service surfaced three real defects, all fixed:
T3_SERVICE_LAUNCHER_CONTEXT, andserverefuses the version mismatch. A PR-env server is never a launcher child, so the script unsets it.curlneeded a timeout: the server binds its port before it can answer, so an unbounded request sat on the listen backlog for twenty minutes instead of retrying.$(...)put the prefixed warning lines into the captured value, so Local presented a multi-line bearer token and the hello failed at the transport layer. The credential is now captured from stdout alone, with stderr shown only on failure.The third one also showed the server's unreachable reason was unhelpful; #198 gained a small commit that joins the cause chain into the message.
Verification
Scratch run against
j5/peering-7-nameson this host withpr-env.sh 998 --branch … --peer:j5 a2a peer liston each state dir shows the other server under its Local / Remote label.access:write.Built by Claude Fable 5.1 in Claude Code.
🤖 Generated with Claude Code