Repository navigation
Keep CLI socket-discovery tests off the host's real cmux - #14919
Conversation
CLI subprocess tests in CMUXCLIErrorOutputRegressionTests redirected only CFFIXED_USER_HOME. Implicit socket discovery still reads the machine-wide /tmp last-socket-path markers, so on a runner (or developer Mac) where a real cmux runs as the same user, tests that expect no live socket were rerouted to that app's socket (cmuxs-mac-mini-3: /Users/cmux/.local/state/cmux/cmux-501.sock). Add BundledCLITestSupport.hermeticCLIEnvironment, which points HOME, CFFIXED_USER_HOME, the XDG base directories and TMPDIR into the temp home, drops inherited CMUX_*/CMUXTERM_*/XDG_* variables, and asks the Debug CLI to confine discovery to its state directory. Route every CFFIXED_USER_HOME call site in the suite through it, and add: - a guard that the helper never exposes the real home or socket pins, - a CLI regression where a per-tag /tmp marker names a live socket, - a resolver test for the isolated candidate list. The regression and resolver tests fail until the CLI honors the isolation key (next commit). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Implicit discovery walks the state-directory markers, then the machine-wide /tmp last-socket-path mirrors and the legacy /tmp socket aliases. Those /tmp entries are shared by every cmux running as the same user, so a test that moves the state directory with CFFIXED_USER_HOME still reached the host's real app (CI runner cmuxs-mac-mini-3 rerouted to /Users/cmux/.local/state/cmux/cmux-501.sock). Debug builds now honor CMUX_TEST_ISOLATED_SOCKET_DISCOVERY=1: marker files outside the state directory are skipped, and the legacy /tmp aliases and non-state-dir requested paths are dropped from the candidate list. The variant's own default socket and state-directory markers still count. Release builds compile the check out, and production discovery order is unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
All contributors have signed the CLA ✍️ ✅ |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: manaflow-ai/cmux/.coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughThe CLI socket resolver adds debug-only confinement for implicit discovery candidates. CLI subprocess tests now use a hermetic environment and include coverage for environment paths and socket discovery. ChangesCLI socket discovery
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The CLI tests exclude machine-wide socket markers and legacy aliases while retaining their intended test-local candidates. No issue identified here needs to block merging. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change appears to reduce the chance that tests contact a running cmux on the host, without changing release behavior. Isolation is deliberately limited rather than a guarantee that every reachable socket is test-owned, and the tests were not observed running in this review. Retained concerns Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
🚥 Pre-merge checks | ✅ 24 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (24 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Merge receipt for |
f5c179f iOS: fix the test failures that keep iOS CI red on main (manaflow-ai#14803) 8685bf5 Hold update relaunch while agents are mid-turn (manaflow-ai#14969) dc90332 Keep CLI socket-discovery tests off the host's real cmux (manaflow-ai#14919) dd3c91b docs: shorten root agent instructions and link existing procedures (manaflow-ai#14998) 8c744df Rename edits inline or in the palette, never in an alert (manaflow-ai#14986) 9ae4383 Calmer chrome motion: appear instantly, fade out only, no overshoot (manaflow-ai#14984) 6510f56 Write opencode config JSON without escaping slashes (cmux 7140) (manaflow-ai#14805) ab5e7da ci: stop catch-up merges from failing the CLA check (manaflow-ai#14913) 52c8f41 Add cmux session move for Claude sessions (manaflow-ai#14959) 36785b1 Hide decorative Settings sidebar icons from VoiceOver (manaflow-ai#14989) 4c7158c Label the sound preview button and fix mistranslated action verbs (manaflow-ai#14983) e704a77 Bound untracked paths stored in last-turn diff baselines (manaflow-ai#14980) f073df1 Fix remote Files sidebar for names that change under NFD (manaflow-ai#14978) 5c68499 Bump bonsplit: mouse wheel scrolls the overflowed tab strip (manaflow-ai#14985) 9466dcb Keep agent resume bindings through the update-relaunch save (manaflow-ai#14971) ef8b037 docs: take release notes from a Changelog section in each PR instead of CHANGELOG.md edits (manaflow-ai#14934) 6eddfd7 ci: skip the delta diff when main moved further than the pull request (manaflow-ai#14987) fefcec7 ci: attribute red PR runs to the machine or the code, re-run machine failures once (manaflow-ai#14977) c185deb Accept file drops on remote tmux mirror panes (manaflow-ai#14981) 90773c7 test: make CmuxSidebarGit probe waits event-driven (manaflow-ai#14973) 1f2dbfe ci: skip the scheduled Blacksmith cache warmers while owned pools serve PRs (manaflow-ai#14827) 2850651 docs: add a guide to customizing cmux's look (manaflow-ai#14850) b66e365 Resolve a separate sidebar's content against its own backdrop (manaflow-ai#14841) 88a9360 UI tests: one labelled frame per action, built in CI; scripts/ui-test (manaflow-ai#14966) 20cfa78 fix(omo): resolve relative file refs in the shadow config without double-loading OpenCode config (manaflow-ai#14935) f0e964c ci: make the aggregate app-host product the default, layers opt-in (manaflow-ai#14975) 52dce98 ci: run and register the machine-failure test (manaflow-ai#14972) 7bf48bc ci: route compile admission by kept-build distance across minis (manaflow-ai#14949) 44fa3f5 Offer cmux in Open With for Markdown, source, and text files (manaflow-ai#14968) 45c2d66 Replay the Claude session id of agents in cmux ssh (cmux-tui) panes (manaflow-ai#14906) b4c1b31 Label icon-only chrome buttons and localize project panel text (manaflow-ai#14926) 14a6909 seed prefetch: keep the seed adopt would pick, of any seeded width (manaflow-ai#14944) 19e73d2 ci: self-calibrating warm-distance compile estimates (manaflow-ai#14932) fa98d86 ci: redispatch focused runs the Mac failed before any test started (manaflow-ai#14963)
Summary
Two tests in
CMUXCLIErrorOutputRegressionTestsexpect the CLI to find no live socket:testAmbientTaggedCLIListsEveryDeadSocketCandidateOnFailureandtestLaunchCapableCommandsReachTheirDispatchPathWithoutLiveImplicitSocket. On runnercmuxs-mac-mini-3they failed because the CLI reached the runner's own cmux, which runs as the same user:Failing runs:
Root cause
The tests moved the home directory only through
CFFIXED_USER_HOME. That does move the resolver's state directory, becausehomeDirectoryForCurrentUserhonors it. But implicit discovery also reads the machine-wide/tmp/*-last-socket-pathmarker mirrors and tries the legacy/tmp/cmux.sockand/tmp/cmux-<uid>.sockaliases. Every cmux running as that user shares those paths.writeStableSocketMarkerworked around the stable/tmpmarker back when discovery stopped at the first readable marker. Discovery now walks every marker, so the real app's/tmp/cmux-last-socket-pathwas followed to its live socket. The same leak lets these tests sendping,restoreandforkto a developer's running cmux.Fix
BundledCLITestSupport.hermeticCLIEnvironment(home:)setsHOME,CFFIXED_USER_HOME,XDG_*andTMPDIRinside the temp home. It drops every inheritedCMUX*andXDG_*variable and setsCMUX_TEST_ISOLATED_SOCKET_DISCOVERY=1. All 20CFFIXED_USER_HOMEcall sites in the suite now use it.CLISocketPathResolverhonors that key. It skips marker files outside the state directory and drops the legacy/tmpaliases. The variant's own default socket and state-directory markers still count. Release builds compile the check out, and neither production discovery order nor socket locations change./tmpmarker names a live socket, and the CLI must not use itCommits
ed883fc9ba0: failing regression. The new CLI test fails, because the CLI follows the/tmpmarker, and the resolver test does not compile yet.d52024cbadc: fixVerification
verify-local --affected mf/main --swift-changed mf/main: swift-syntax, test-wiring and feature-flags passed.CFFIXED_USER_HOMEare not migrated here. Most of them pinCMUX_SOCKET_PATH.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by cubic
Fixes socket-discovery tests reaching the host's real cmux by isolating implicit discovery to the test's state directory in Debug builds.
Bug Fixes
CLISocketPathResolverhonorsCMUX_TEST_ISOLATED_SOCKET_DISCOVERY=1in Debug only, skipping/tmpmarker files and legacy aliases outside the state directory.Refactors
BundledCLITestSupport.hermeticCLIEnvironment(home:)and migrated all 20CFFIXED_USER_HOMEcall sites in the suite to it./tmpmarkers naming a live socket, and a resolver test comparing ambient vs isolated candidate lists.Written for commit f859835. Summary will update on new commits.
Summary by CodeRabbit