pub struct ServerCtx {
pub launcher_pid: u32,
pub launcher_version: String,
pub state: Arc<Mutex<State>>,
pub events_tx: Sender<Event>,
pub event_log: Arc<EventLog>,
pub host_pipe: Arc<HostPipe>,
}Expand description
State the IPC server shares across connections. Carries the launcher’s identity (for patching into Registered events the reducer emits with sentinel values) plus the canonical State.
Fields§
§launcher_pid: u32§launcher_version: String§state: Arc<Mutex<State>>Canonical state owned by the server. Mutex held only during reducer dispatch — sub-millisecond.
Phase E.1a — moved from Mutex<State> to Arc<Mutex<State>>
so the saga coordinator can share access. The coordinator
needs bump_version when emitting saga lifecycle events and
will (in E.5) inspect state during saga decisions. Sharing
via Arc keeps the existing single-writer-mutex discipline.
events_tx: Sender<Event>Phase B.8 — broadcast bus for reducer-emitted events. Every
reducer event from reducer::update is published here; each
connection subscribes and writes received events to its own
pipe. Lets observability clients (--diag wrr, future Tools)
see cross-process activity, not just replies to their own
commands. Per-connection direct sends (Error replies for
parse failures, register-first violations) bypass the bus —
they’re response-to-this-client-only by intent. (codex P1
PR #605.)
event_log: Arc<EventLog>Phase D.2 — event log: in-memory ring of recent reducer
events (replay source for D.3’s GetEvents) + disk
persistence stream for crash forensics. Server appends to
the in-memory ring synchronously after each reducer
dispatch; the disk writer is a separate task spawned in
main.rs that subscribes to the broadcast bus.
host_pipe: Arc<HostPipe>CPD-2 — launcher → host pipe wrapper. The per-connection
handler hands the host’s writer half to HostPipe::set_writer
once the connecting client registers as ClientKind::Host,
and clears it on disconnect. The host’s per-connection event
fanout task routes events through HostPipe::send_event
instead of send_event direct (so frames carry the
HostFrame envelope and traverse the pending-buffer path
when the host reconnects).