Repository navigation
fix: refuse Rex spawns when server locality is unproven - #7810
Merged
Merged
Conversation
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.
Intent
Fix 1 from the triage of a user bug report: when firstmate’s Rex backend is pointed at a Rex server running on another machine, refuse right at spawn with a clear message pointing to remote second mates, instead of waiting 60 seconds and failing with a misleading isolated-worktree error.
The user’s report (pasted verbatim): "Setup: Firstmate on a Mac, second mates on a Linux Box, and Rex (rex 0.0.1792878257-g758aab, API 7) running on both. ... Worker spawn on a Linux Rex server fails the worktree check. With REX_SERVER pointed at the Linux host, the Rex adapter opens the tab fine, then fm-spawn.sh#L5599 refuses with "treehouse get did not enter an isolated worktree within 60s"."
Context from the triage: the Rex backend assumes the Rex server runs on the same machine as firstmate. It compares the block’s foreground cwd against local filesystem paths, and bin/backends/rex.sh reads the local process table to find harness processes below a shell foreground, so a Rex server on another host can never give a correct spawn or liveness answer even if the worktree check passed. The supported way to run workers on another machine is a remote second mate (docs/remote-secondmates.md).
What Changed
unix://Rex endpoint for new spawns, rejecting unreadable endpoints and other transports before leasing a worktree or opening a tab.Risk Assessment
✅ Low: The change adds a bounded, conservative spawn check before endpoint creation or worktree leasing, with actionable guidance and no substantiated material defects.
Testing
Targeted adapter tests passed, and live checks demonstrated prompt refusal, actionable guidance, no leftover sessions or task state, and Unix-socket acceptance. The installed API-5 Rex CLI required explicit endpoint forwarding through a wrapper invoking the real CLI; no server responses were mocked. CLI transcripts were captured.
Evidence: Live Rex endpoint validation transcript
Source: Live Rex endpoint validation transcript
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-backend-rex.test.shpassed. An initial run with worktree-local TMPDIR hit the existing secondmate-removal safety guard; rerunning with normal temporary storage resolved that setup issue.python3 .live-rex/validate.pydrove actual fm-spawn against a disposable Rex HTTP server and an unreachable endpoint, checked refusal timing and cleanup, and exercised the locality guard against its Unix socket.Stopped the disposable Rex server, removed lab files, and confirmed a clean worktree.✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.