Expand description
The tcode daemon’s Unix-socket transport — the one every client but the
GUI webview now dials (#6637, ADR-0032).
Why: a loopback TCP port is reachable by any process on the machine,
including a page running in the operator’s browser, which is what forced
the bearer-token and origin-guard stack #6491 added. A 0600 socket inside
a 0700 directory, with a peer-uid check on every accept, is an OS
boundary instead of a convention, so none of that machinery is ported here
— trusty_common::uds::server’s module docs state why re-adding it would
guard nothing. The owner ruling of 2026-09-08 makes UDS this daemon’s
native transport: tcode tui dials the socket directly, and the HTTP the
GUI webview needs moves into trusty-code-gui in PR 2.
What: run_daemon is the persistent daemon’s whole body. It binds the
socket FIRST and treats a bind failure as fatal — a daemon that silently
served HTTP only would leave every socket client reporting “no daemon”
while one is plainly running — then builds the router ONCE and serves it
over both transports, so a session created over the socket is the same
session the GUI’s HTTP call sees.
The method surface is mounted, not restated. Exactly one of the 34
registered JSON-RPC methods (session.attach) uses
crate::jsonrpc::ConnectionContext::notify, and a UDS connection is one
frame in and one frame out, so it cannot push. The other 33 ignore the
context entirely, which is what lets JsonRpcFallback carry the whole
table through trusty_common::uds::server::RpcRouter::fallback rather
than re-registering each name — registering the same table twice is the
silent-drift risk this workspace’s common-entry-point rule exists to stop.
session.attach’s live half is served instead by
crate::session::events_stream, and the workstream fan-out by
crate::workstreams::events_stream; both are registered as STREAM
methods, which the router checks before the fallback, so the names win over
the pass-through.
HTTP is a transient here, not an end state. It stays bound only because
trusty-code-gui’s webview still fetches it; PR 2 moves that bridge into
the GUI crate and this daemon binds the socket alone.
Test: uds_tests.
Structs§
- Json
RpcFallback - Mounts
crate::jsonrpc::Routeras the socket router’s catch-all.
Constants§
- SOCKET_
APP_ NAME - The application name whose data directory holds the daemon’s socket.
Functions§
- build_
rpc_ router - Assemble the socket router: two stream methods plus the whole JSON-RPC table behind them.
- project_
socket_ path - The socket a daemon serving
projectbinds when the shared socket is held by a daemon serving a different project (#4600). - run_
daemon - Run the persistent
tcodedaemon: bind the socket, optionally bind HTTP, and serve both until SIGTERM/SIGINT. - run_
daemon_ on run_daemonwith the socket path, the workstream data directory and the shutdown trigger injected.- run_
project_ daemon run_daemonon this binding’s own socket,project_socket_path, instead of the shared one (#4600,tcode serve --project-socket).- socket_
path - The socket
tcode servebinds and every client dials.