Expand description
Local-mode gRPC daemon over a Unix-domain socket.
Hosts the W2 grpc_local_impl services on
a UDS inside a single repo, reachable by the same-user CLI for the
latency-sensitive agent loop. No Biscuit, no TLS, no multi-tenant —
local-only, single-user, same-process auth via SO_PEERCRED on Linux and
getpeereid on macOS.
The CLI wraps this behind heddle agent serve (W2 / A16). Out of scope
for first ship: multi-user, remote daemon-as-service, TLS. Documented
in the verb’s --help long form.
§Lifecycle
serve(...)opens theRepository, theOperationDedupStore, and the UDS listener.- A pidfile and the socket path are guarded by [
PidGuard] so a stale daemon’s leftover files don’t block restart and a clean exit removes them. - tonic’s
Server::serve_with_shutdownruns the W2 services until theshutdownfuture resolves.
§Cross-platform notes
Building the daemon binary on Windows is not supported — UDS support
there is nascent. The module compiles only on unix and the rest of the
crate doesn’t reach for it on other platforms.
Structs§
- Local
Daemon Config - Configuration for
serve. The socket and pidfile default to the well-known locations under the repo’s.heddle/sockets/directory. - PidFile
Contents - Parsed pidfile contents. Format on disk is three newline-terminated lines:
Constants§
- PIDFILE_
MARKER - Magic marker line written to the pidfile so
heddle agent stopcan distinguish a heddle pidfile from a foreign one before signalling the PID. SeePidFileContentsfor the on-disk format.
Functions§
- check_
peer_ uid_ matches_ self - Verify that a connecting peer’s UID matches our own. Called by tonic’s connection acceptor if the local-impl decides to enforce per-connection peer credentials. For first ship we rely on the socket file’s mode 0600 to keep other users out, which is the standard Unix posture for a single-user daemon. This helper is exported so a future hardening pass can wire it into a tonic interceptor without rewriting the daemon.
- default_
pid_ path - Default pidfile path inside a repo:
<heddle_dir>/sockets/grpc.pid. - default_
socket_ path - Default socket path inside a repo:
<heddle_dir>/sockets/grpc.sock. - is_
heddle_ process - Best-effort check that
pidactually belongs to a heddle binary. - pid_
alive - serve
- Open a
Repositoryatrepo_path, then run the local gRPC daemon over the configured UDS untilshutdownresolves.