Expand description
stackless-daemon (ARCHITECTURE.md §3): the one resident component —
unix-socket RPC, the reverse proxy, process bookkeeping, and (M7)
the lease reaper. Same binary as the CLI, daemon run subcommand.
Re-exports§
pub use binary::ResolveSource;pub use binary::is_cli_process;pub use binary::mark_cli_process;pub use binary::resolve_daemon_bin;pub use binary::should_replace_daemon;pub use client::DaemonClient;pub use client::DaemonError;pub use server::DaemonRole;
Modules§
- adopt
- Re-adoption on daemon start (ARCHITECTURE.md §3: upgrade = restart +
re-adopt). Routes and supervision records live only in the daemon’s
memory, so they die with the daemon — re-adoption rebuilds them from
the checkpoint journal, the one durable truth. For every ACTIVE
instance, each
start:*checkpoint whose recorded process is still alive has its proxy routes and supervision record re-registered; a dead process is noted, not restarted (v0 supervision policy: observe, don’t restart). - binary
- Resolve the stackless CLI binary used to spawn the operator daemon.
- client
- The CLI side: connect to the daemon, spawning it on demand under a lock file so concurrent commands race safely (§3). Carries the version handshake: a newer CLI tells an older daemon to drain and exit — but only when this process is the CLI (never when an SDK consumer resolved a PATH/env CLI binary).
- launchd
- Boot persistence on macOS (ARCHITECTURE.md §3): register the daemon
as a launchd user agent so the lease is a system guarantee across
reboots and crashes. If registration is refused, stackless degrades
loudly —
status/listread the reason fromdaemon.persistenceand warn that leases hold only while the daemon happens to run. - proxy
- The built-in reverse proxy (§3): HTTP plus transparent HTTP/1
upgrade tunnels, one fixed unprivileged port, routing on the Host
header. Listens on both loopbacks — macOS resolves multi-label
*.localhostto::1(verified 2026-06-11), while the health checker dials 127.0.0.1 with an explicit Host header. - reaper
- The lease reaper (ARCHITECTURE.md §6). Ticks every minute inside the daemon (so lease expiry is a system guarantee across reboots via launchd keep-alive). Each tick:
- rpc
- The daemon RPC protocol: JSON lines over the unix socket, one request line, one response line. Every exchange carries the sender’s version so the upgrade handshake (§3) is just a field compare — a newer CLI tells an older daemon to drain and exit.
- server
- The resident daemon (§3): unix-socket RPC + the reverse proxy.
Spun up on demand by the CLI; same binary,
daemon runsubcommand. - state
- The daemon’s in-memory bookkeeping: the proxy routing table and the supervision records. Instance processes are not the daemon’s children (§3) — a starting daemon reconciles these records against observed reality, which is why they also live in the state store’s checkpoint journal; this map is the hot copy.