Skip to main content

Module local_daemon

Module local_daemon 

Source
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

  1. serve(...) opens the Repository, the OperationDedupStore, and the UDS listener.
  2. 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.
  3. tonic’s Server::serve_with_shutdown runs the W2 services until the shutdown future 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§

LocalDaemonConfig
Configuration for serve. The socket and pidfile default to the well-known locations under the repo’s .heddle/sockets/ directory.
PidFileContents
Parsed pidfile contents. Format on disk is three newline-terminated lines:

Constants§

PIDFILE_MARKER
Magic marker line written to the pidfile so heddle agent stop can distinguish a heddle pidfile from a foreign one before signalling the PID. See PidFileContents for 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 pid actually belongs to a heddle binary.
pid_alive
serve
Open a Repository at repo_path, then run the local gRPC daemon over the configured UDS until shutdown resolves.