Skip to content

feat(agent): default to per-user local IPC, keep TCP as explicit opt-in - #491

Merged
ace331 merged 3 commits into
mainfrom
claude/agent-local-ipc
Sep 4, 2026
Merged

ace331 merged 3 commits into
mainfrom
claude/agent-local-ipc

Conversation

@ace331

@ace331 ace331 commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

The agent's gRPC endpoint moves from a shared loopback TCP port to per-user native IPC; TCP survives only as an explicitly enabled remote/development compatibility mode.

  • macOS/Linux: Unix-domain socket at $XDG_RUNTIME_DIR/future/agent.sock or ~/.future/run/agent.sock — parent dir 0700, socket 0600, directory-ownership check, and SO_PEERCRED peer-UID verification on Linux.
  • Windows: named pipe \\.\pipe\future-agent-<SID> with a current-user-only DACL (D:P(A;;GA;;;SY)(A;;GA;;;<SID>)) and reject_remote_clients.
  • TCP: only when --grpc-addr / FUTURE_AGENT_GRPC_ADDR is set explicitly; clients try the configured TCP address first and fall back to local IPC. The default auto plan never touches the shared port.
  • Shared discovery lives in future_rpc::transport (new transport.rs): connection_plan() + connect_channel() used by the TUI, CLI, channels, and desktop backend.
  • TUI sidecar: mirrors the desktop supervisor — when no agent is reachable, the TUI launches future agent (or the standalone future-agent fallback) as a sidecar and owns it for the process lifetime.

Behavior changes

  • future agent with no flags now binds local IPC instead of 127.0.0.1:50051.
  • Client default address becomes auto (env FUTURE_AGENT_GRPC_ADDR and channel grpc_addr config still honored; "auto"/empty means local IPC).
  • Docs and help text updated (README, docs/tui.md, Feishu/DingTalk wiki, loop control-plane doc).

Verification

  • cargo fmt --all --check, cargo clippy --workspace --all-targets (workspace + desktop) clean.
  • Tests: agent 1603, cli 708, channels 343, future-rpc 113, desktop 1111 passing.
  • New smoke test: default mode creates the private socket dir (0700); rpc transport tests cover plan ordering and socket permissions.
  • End-to-end on macOS: isolated-HOME agent bound ~/.future/run/agent.sock; future models list connected over the socket successfully.
  • Windows named-pipe path is compile-checked only (no Windows host available here).

The agent now binds a Unix-domain socket (mode 0600 under a 0700
directory, with peer-UID verification on Linux/macOS) or a Windows named
pipe carrying a current-user-only DACL instead of listening on
127.0.0.1:50051. TCP remains available only when --grpc-addr is passed
explicitly, as a remote/development compatibility mode.

Shared discovery lives in the future-rpc crate (transport.rs): clients
resolve FUTURE_AGENT_GRPC_ADDR / config to an ordered connection plan —
an explicit TCP address is tried first with local IPC as fallback; the
default 'auto' plan uses local IPC only. TUI, CLI, channels, and the
desktop backend all go through connect_channel().

The TUI mirrors the desktop supervisor: when no agent is reachable it
launches a sidecar (unified 'future agent' or standalone future-agent)
and owns it for the process lifetime; an already-running agent is
attached to instead.
@ace331
ace331 marked this pull request as ready for review September 4, 2026 03:00
- transport.rs: import SDDL_REVISION_1 from Win32::Security::Authorization
  (its actual module in windows-sys 0.59) instead of Win32::Security.
- cli_smoke: force the ~/.future/run socket path by removing
  XDG_RUNTIME_DIR from the child env — ubuntu-latest exports
  /run/user/<uid>, outside the isolated HOME the test asserts on.
- terminal.rs: drain the one-shot FORCE_NEW_FAILURE test seam before
  constructing a Terminal in columns_rows_read_cached_size; a leaked
  injection from another test made Terminal::new unwrap fail (CI flake).
@ace331
ace331 enabled auto-merge (squash) September 4, 2026 03:13
@ace331
ace331 merged commit ae82469 into main Sep 4, 2026
12 checks passed
@ace331
ace331 deleted the claude/agent-local-ipc branch September 4, 2026 03:30
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