Summary
On macOS the UDS transport is unusable for any project whose canonical socket path exceeds the 104-byte limit. The server falls back to /tmp/agent-brain-<hash>.sock, then the client refuses to connect because /tmp is mode 0o755, and the server cannot chmod it. --transport auto silently falls back to HTTP, so nobody notices.
Found during the v10.7.0 integration test on 2026-09-19.
Server (.agent-brain/logs/server.err):
Long-path fallback: binding UDS at /tmp/agent-brain-bd5902fa.sock (pointer in .../e2e/sample-project/.agent-brain)
Dual-binding TCP 127.0.0.1:8001 + UDS /tmp/agent-brain-bd5902fa.sock
[WARNING] agent_brain_server.api.uds_bind: Failed to chmod parent dir /tmp: [Errno 1] Operation not permitted: '/tmp'
Client:
$ agent-brain --transport uds status
agent_brain_uds.errors.SocketPermissionError: Refusing to connect: parent directory mode is 0o755, expected 0o700. (socket: /tmp/agent-brain-bd5902fa.sock)
-> chmod 700 /tmp and re-bind the server.
The hint is not actionable. /tmp is a shared directory. Nobody should chmod 700 /tmp.
Also: agent-brain start --uds --json prints "socket_path": null even though the server bound a socket.
Cause
agent_brain_uds/paths.py::_short_fallback_path hard-codes /tmp. The permission check in agent_brin_uds/permissions.py requires the parent to be 0o700, which /tmp can never satisfy.
Proposed fix
Change the fallback directory order to a per-user private dir:
$XDG_RUNTIME_DIR when set (Linux, already 0o700).
tempfile.gettempdir() when its mode is 0o700 (macOS $TMPDIR is /var/folders/.../T, per-user, short).
~/.agent-brain/run/, created with mode 0o700.
Keep the hash-based file name. Update the client to resolve the same directory. Fix start --uds --json to report socket_path. Add a test that runs the fallback with a long state dir on macOS and asserts the parent dir mode is 0o700.
Summary
On macOS the UDS transport is unusable for any project whose canonical socket path exceeds the 104-byte limit. The server falls back to
/tmp/agent-brain-<hash>.sock, then the client refuses to connect because/tmpis mode0o755, and the server cannotchmodit.--transport autosilently falls back to HTTP, so nobody notices.Found during the v10.7.0 integration test on 2026-09-19.
Server (
.agent-brain/logs/server.err):Client:
The hint is not actionable.
/tmpis a shared directory. Nobody shouldchmod 700 /tmp.Also:
agent-brain start --uds --jsonprints"socket_path": nulleven though the server bound a socket.Cause
agent_brain_uds/paths.py::_short_fallback_pathhard-codes/tmp. The permission check inagent_brin_uds/permissions.pyrequires the parent to be0o700, which/tmpcan never satisfy.Proposed fix
Change the fallback directory order to a per-user private dir:
$XDG_RUNTIME_DIRwhen set (Linux, already0o700).tempfile.gettempdir()when its mode is0o700(macOS$TMPDIRis/var/folders/.../T, per-user, short).~/.agent-brain/run/, created with mode0o700.Keep the hash-based file name. Update the client to resolve the same directory. Fix
start --uds --jsonto reportsocket_path. Add a test that runs the fallback with a long state dir on macOS and asserts the parent dir mode is0o700.