You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test: isolate real-Rex suites on private servers - #7649
The real-Rex tests should create their own test-only Rex server on the fly, like the Herdr lab, instead of running against the live Rex server the user is working in. Context: Firstmate's Rex session backend landed in #7633 and #7639. The current real-Rex smoke test (tests/fm-backend-rex-smoke.test.sh) never starts a server: it requires an already reachable Rex server (the user's live one) and protects it only with a forwarding guard that limits state changes to sessions the test created. A rex link at ~/.local/bin/rex now makes the CLI reachable from the no-mistakes review pipeline, so without this change pipeline live validation (including a planned server-stop scenario) would hit the user's live Rex. Rex supports a throwaway server directly: rex server run --listen --state-dir
--config --exit-empty, with clients pointed at it through REX_SERVER or -S.
What Changed
Start and clean up private Rex servers with temporary sockets, state directories, and configs for real-Rex smoke, event-wait, composer, and AFK tests.
Add server stop/restart coverage for passive reads without autostart and reclaim after session loss; distinguish missing-tool skips from setup failures.
Update contributor and backend documentation to describe private-server isolation and mark historical personal-server evidence.
Risk Assessment
✅ Low: The changes are bounded to test-server isolation and documentation, with explicit private routing and cleanup and no substantiated remaining defects.
Testing
Exercised private-server lifecycle, stop/recovery, event delivery, routing guards, interruption cleanup, AFK topology, and Claude composer behavior. Initial capped exploratory runs timed out; focused isolation and extended AFK reruns passed. CLI transcripts were captured; no UI-facing code changed. No full suite, lint, or static analysis ran.
Live validation: ✅ go - 7 of 7 scenarios driven live against the product
Scenario
Result
Live
Evidence
Run smoke tests on a newly created private server, then stop and recover it
✅ pass
live
rex-smoke.log
Receive real blocked and endpoint-gone events through the private server
✅ pass
live
rex-eventwait.log
Ignore an inherited server endpoint and reject mutations of unowned sessions
✅ pass
live
rex-isolation-final.log
Fail private-server startup without falling back to a reachable inherited server
✅ pass
live
rex-isolation-final.log
Interrupt preparation during readiness polling without leaking the server or state
✅ pass
live
rex-interruption.log
Start and stop an AFK terminal without changing the captain's Rex topology
✅ pass
live
rex-afk-trace.log
Launch real Claude idle on the private server and classify its composer
ok - real rex: created the test's own session session:01a164a9-e1b5-76be-b551-7d80835d2cc1
ok - real rex: a Rex-hosted launcher gets a focus-safe 200x50 tab in its own session; duplicates are refused
ok - real rex: line submit, capture, and a derived viewport of exactly size.rows lines; literal and every mapped key send
ok - real rex: current_path follows a nested shell; agent_state reads dead at a shell, ambiguous under another program
ok - real rex: OSC 7501 records from the foreground shell drive busy_state
ok - real rex: kill closes exactly the task tab and the recorded server proves it gone
ok - real rex: relaunch reclaim opens a tab in the exact session, and a gone session returns 2 creating nothing
ok - real rex: all state-changing calls stayed within this run's private server
ok - real rex: passive reads disable autostart and do not start a stopped server
ok - real rex: after server restart, the recorded session is gone and reclaim creates nothing
ok - real rex: the push capability gate passes without starting a server
ok - real rex: a driven blocked edge returns its record, with Rex's kind and message, 192ms after the report was sent
ok - real rex: the watcher fast path enqueues a stale wake carrying Rex's blocked kind and message
ok - real rex: an escalated block is not re-delivered and the reader runs its whole budget (2104ms for 2s)
ok - real rex: closing a watched block ends the wait 153ms later for an immediate poll
ok - real rex: a reader that cannot start returns 2 and the watcher falls back to polling
ok - real rex: all state-changing calls stayed within this run's private server
Evidence: Routing isolation and fail-closed startup
Disposable sentinel endpoint: unix:///private/tmp/fm-rex-test.ohcQJF/rex.sock
Sentinel session: session:01a164b0-6b6e-7f2a-a519-0da42ee01b99
not ok - private Rex server failed to start; see ~/.no-mistakes/worktrees/016d88035d58/01M5JA9A65YZTDHAZYVVJGGM9G/.rex-validation/fm-rex-test.C25Jv3/server.log
PASS: real startup error failed closed (2), cleaned scratch, and did not fall back to reachable inherited server
Nested endpoint: unix:///private/tmp/fm-rex-test.07CeKW/rex.sock
session:01a164b0-6e82-79ee-8fe1-ade09dfbf487 block:01a164b0-6e82-7b08-9307-26d4dc1382f7
Nested restart: no persisted sessions
PASS: nested helper ignored inherited REX_SERVER; sentinel remained byte-identical and reachable after private stop/restart
fm-rex-test guard: refused kill session:01a164b0-73d9-7119-b766-198fd25feb22
PASS: guard refused kill of unowned session (97); real session still exists
PASS: cleanup removed owned state and terminated the private server
Real server during readiness: ~/.local/bin/rex --autostart=false server run --listen unix:///private/tmp/fm-rex-test.7Kbquq/rex.sock --state-dir /private/tmp/fm-rex-test.7Kbquq/server-state --config /private/tmp/fm-rex-test.7Kbquq/rex-config.lua --exit-empty
Interrupted suite exit: -15
PASS: readiness interruption terminated owned real server
PASS: readiness interruption removed owned scratch directory
ok - claude (2.1.308 (Claude Code)): real idle composer classifies empty on rex
ok - claude (2.1.308 (Claude Code)): the same idle screen read cursorless is not pending (verdict: empty)
ok - real rex: all state-changing calls stayed within this run's private server
⚠️tests/rex-test-safety.sh:35 - The private server starts before the standalone suites install their EXIT cleanup traps. Interrupting preparation during readiness polling leaves temporary data and potentially the server behind. Affected callers: tests/fm-backend-rex-smoke.test.sh:20–21, tests/fm-backend-rex-eventwait-smoke.test.sh:24–25, and tests/fm-backend-rex-composer-live-e2e.test.sh:45–46. Register cleanup before calling rex_test_prepare so startup interruptions also release owned resources.
⚠️tests/fm-backend-rex-smoke.test.sh:117 - The new stop/restart checks can pass without proving their claimed adapter behavior. The guard forces --autostart=false at tests/rex-test-safety.sh:121, so removing the adapter's passive-read protection would still pass this assertion. Also, the restarted-server absence check at tests/fm-backend-rex-smoke.test.sh:122 uses T, which was already killed at line 94; it cannot demonstrate disappearance caused by server shutdown. Detect passive calls that omit autostart protection while retaining private routing, and use an endpoint confirmed present immediately before stopping the server.
🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
Live validation: ✅ go - 7 of 7 scenarios driven live against the product
Scenario
Result
Live
Evidence
Run smoke tests on a newly created private server, then stop and recover it
✅ pass
live
rex-smoke.log
Receive real blocked and endpoint-gone events through the private server
✅ pass
live
rex-eventwait.log
Ignore an inherited server endpoint and reject mutations of unowned sessions
✅ pass
live
rex-isolation-final.log
Fail private-server startup without falling back to a reachable inherited server
✅ pass
live
rex-isolation-final.log
Interrupt preparation during readiness polling without leaking the server or state
✅ pass
live
rex-interruption.log
Start and stop an AFK terminal without changing the captain's Rex topology
✅ pass
live
rex-afk-trace.log
Launch real Claude idle on the private server and classify its composer
✅ pass
live
rex-composer-claude.log
rex --autostart=false version confirmed API revision 5.
bash tests/fm-backend-rex-smoke.test.sh with inherited fleet-path overrides cleared.
bash tests/fm-backend-rex-eventwait-smoke.test.sh with inherited fleet-path overrides cleared.
Focused execution of e2e_rex from tests/fm-afk-launch.test.sh; extended-timeout retry passed.
Focused execution of check_harness_idle_empty claude claude with FM_REX_COMPOSER_LIVE=1.
bash .rex-validation/isolation.sh: two disposable real servers, inherited-endpoint isolation, startup failure, unowned-session refusal, and cleanup.
python3 .rex-validation/lifecycle.py: SIGTERM during readiness polling against a real Rex server.
Removed transient drivers and verified a clean worktree and no remaining test-server processes.
Intent
The real-Rex tests should create their own test-only Rex server on the fly, like the Herdr lab, instead of running against the live Rex server the user is working in. Context: Firstmate's Rex session backend landed in #7633 and #7639. The current real-Rex smoke test (tests/fm-backend-rex-smoke.test.sh) never starts a server: it requires an already reachable Rex server (the user's live one) and protects it only with a forwarding guard that limits state changes to sessions the test created. A rex link at ~/.local/bin/rex now makes the CLI reachable from the no-mistakes review pipeline, so without this change pipeline live validation (including a planned server-stop scenario) would hit the user's live Rex. Rex supports a throwaway server directly: rex server run --listen --state-dir
--config --exit-empty, with clients pointed at it through REX_SERVER or -S.What Changed
Risk Assessment
✅ Low: The changes are bounded to test-server isolation and documentation, with explicit private routing and cleanup and no substantiated remaining defects.
Testing
Exercised private-server lifecycle, stop/recovery, event delivery, routing guards, interruption cleanup, AFK topology, and Claude composer behavior. Initial capped exploratory runs timed out; focused isolation and extended AFK reruns passed. CLI transcripts were captured; no UI-facing code changed. No full suite, lint, or static analysis ran.
Evidence: Private-server smoke and recovery
Source: Private-server smoke and recovery
Evidence: Real Rex event transitions
Source: Real Rex event transitions
Evidence: Routing isolation and fail-closed startup
Source: Routing isolation and fail-closed startup
Evidence: Startup interruption cleanup
Source: Startup interruption cleanup
Evidence: Rex AFK lifecycle trace
Source: Rex AFK lifecycle trace
Evidence: Real Claude composer on private Rex
Source: Real Claude composer on private Rex
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 2 issues found → auto-fixed ✅
tests/rex-test-safety.sh:35- The private server starts before the standalone suites install their EXIT cleanup traps. Interrupting preparation during readiness polling leaves temporary data and potentially the server behind. Affected callers: tests/fm-backend-rex-smoke.test.sh:20–21, tests/fm-backend-rex-eventwait-smoke.test.sh:24–25, and tests/fm-backend-rex-composer-live-e2e.test.sh:45–46. Register cleanup before calling rex_test_prepare so startup interruptions also release owned resources.tests/fm-backend-rex-smoke.test.sh:117- The new stop/restart checks can pass without proving their claimed adapter behavior. The guard forces --autostart=false at tests/rex-test-safety.sh:121, so removing the adapter's passive-read protection would still pass this assertion. Also, the restarted-server absence check at tests/fm-backend-rex-smoke.test.sh:122 uses T, which was already killed at line 94; it cannot demonstrate disappearance caused by server shutdown. Detect passive calls that omit autostart protection while retaining private routing, and use an endpoint confirmed present immediately before stopping the server.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
rex --autostart=false versionconfirmed API revision 5.bash tests/fm-backend-rex-smoke.test.shwith inherited fleet-path overrides cleared.bash tests/fm-backend-rex-eventwait-smoke.test.shwith inherited fleet-path overrides cleared.Focused execution ofe2e_rexfromtests/fm-afk-launch.test.sh; extended-timeout retry passed.Focused execution ofcheck_harness_idle_empty claude claudewithFM_REX_COMPOSER_LIVE=1.bash .rex-validation/isolation.sh: two disposable real servers, inherited-endpoint isolation, startup failure, unowned-session refusal, and cleanup.python3 .rex-validation/lifecycle.py: SIGTERM during readiness polling against a real Rex server.Removed transient drivers and verified a clean worktree and no remaining test-server processes.✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.