Skip to content

feat(bin): add Rex runtime backend for crewmates and scouts - #1

Merged
roderik merged 2 commits into
mainfrom
fm/rex-backend-p1
Oct 22, 2026
Merged

roderik merged 2 commits into
mainfrom
fm/rex-backend-p1

Conversation

@roderik

@roderik roderik commented Oct 21, 2026

Copy link
Copy Markdown
Owner

Intent

I want to add Rex support /rex to firstmate, with full support for first and second mates, at the same level as the herdr support. It should use the Rex capabilties to the maximum, using its multiplexing and pane management and all other things to the maximum for an optimal development experience

Context: a planning investigation split this into three sequential phases. This task is Phase 1: a rex runtime backend that spawns, steers, peeks, interrupts, exits, and cleans up crewmates and scouts in Rex tabs, selected by --backend rex, config/backend, or auto-detection when firstmate runs inside Rex. Secondmates and away mode (Phase 2) and Rex-native status, events, and notifications (Phase 3) follow as separate tasks.

What Changed

  • Added a rex runtime backend (bin/backends/rex.sh) that spawns, steers, peeks, interrupts, exits, and cleans up crewmates and scouts in Rex tabs. It is selectable via --backend rex, config/backend, or auto-detection when running inside Rex. bin/fm-backend.sh, fm-spawn.sh, fm-brief.sh, fm-control-lib.sh, fm-crew-state.sh, and related scripts were updated to route through it. Added bin/fm-rex-lab.sh as a helper script.
  • Added docs/rex-backend.md and updated architecture, configuration, scripts, runtime-backend verification, README, and other docs and skill references to cover the new backend.
  • Added tests for the Rex backend (unit, smoke, and a live Claude e2e script) and updated existing backend, bootstrap, control, teardown, and trace-context tests, plus the test runner and isolation-proof scripts, to cover Rex.

Risk Assessment

⚠️ Medium: The previously reported label race is correctly fixed (lock now spans the label check, session ensure, window creation and rename), but the change is a large experimental backend and only rex.sh was examined in depth.

Testing

I ran the Rex backend contract test and the shared backend test; both pass. They cover container setup, task tab creation, targets, capture and send, agent state, kill and cleanup, listing, auto-detection and config selection, and the refusal of --secondmate on Rex. The live Rex smoke test skipped itself because rex is not on PATH, and the lab helper bin/fm-rex-lab.sh needs rex, so no real Rex server could be started. Every Rex-specific result therefore comes from stubs and is not live.

  • Live validation: ⚠️ inconclusive - 0 of 2 scenarios driven live against the product
Scenario Result Live Evidence
Spawn, steer, peek, interrupt and clean up a task in a Rex tab through the rex backend ⏸️ untested no The rex CLI is not on PATH and the instructions forbid searching the host for it. bin/fm-rex-lab.sh needs it to start a private lab server. To run this live, install rex and re-run the smoke tes…
Backend selection via --backend rex, config/backend, and auto-detection inside Rex; --secondmate on rex is refused ⏸️ untested no The prior payload only exercised this through the repo's scripts with a stubbed rex (tests/fm-backend-rex.test.sh and tests/fm-backend.test.sh), not a real Rex server, so it did not establish a live r…
  • Outcome: ⚠️ 1 warning across 1 run (2m39s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - medium risk

✅ No issues found.

⚠️ **Test** - 1 warning
  • ⚠️ live validation verdict: inconclusive (0 of 2 scenarios were driven live against the product); untested: Spawn, steer, peek, interrupt and clean up a task in a Rex tab through the rex backend, Backend selection via --backend rex, config/backend, and auto-detection inside Rex; --secondmate on rex is refused
  • Live validation: ⚠️ inconclusive - 0 of 2 scenarios driven live against the product
Scenario Result Live Evidence
Spawn, steer, peek, interrupt and clean up a task in a Rex tab through the rex backend ⏸️ untested no The rex CLI is not on PATH and the instructions forbid searching the host for it. bin/fm-rex-lab.sh needs it to start a private lab server. To run this live, install rex and re-run the smoke tes…
Backend selection via --backend rex, config/backend, and auto-detection inside Rex; --secondmate on rex is refused ⏸️ untested no The prior payload only exercised this through the repo's scripts with a stubbed rex (tests/fm-backend-rex.test.sh and tests/fm-backend.test.sh), not a real Rex server, so it did not establish a live r…
  • bash tests/fm-backend-rex.test.sh
  • bash tests/fm-backend-rex-smoke.test.sh (skipped: rex absent)
  • bash tests/fm-backend.test.sh
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Add bin/backends/rex.sh, a session-provider adapter that spawns, steers,
peeks, interrupts, exits, and cleans up ship and scout workers as unfocused
Rex tabs, selected by --backend rex, config/backend, or auto-detection from
a structurally proven Rex pane (after $TMUX and HERDR_ENV).

Every rex call passes the recorded server with -S and --autostart=false,
addresses sessions and blocks by full id, and strips REX_SESSION, REX_BLOCK,
REX_CLIENT, and REX_SERVER. Exit 3 on a full id means gone; exit 4 means
unknown. Tasks record rex_server, rex_server_instance, rex_session_id,
rex_window_id, and rex_block_id. Outside Rex each home adopts or creates
one firstmate session under state/.rex-session.lock and retires it with
its last tab. Rex capture includes scrollback, so rex stays out of the
visible-capture list. Secondmates and relaunch rebinding are refused.

Add bin/fm-rex-lab.sh (private lab server with a live-server tripwire) and
fm-brief.sh --rex-lab, a fake-binary suite, a token-free real-binary smoke,
an opt-in live Claude guard, docs/rex-backend.md, and the verification
record.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-21T17:18:04.952582Z
We couldn’t complete this review. Comment @codex review to try again.
fa41988 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

1 participant