Module server

Module server 

Source

Structs§

ServerCtx
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.

Statics§

NEXT_CONN_ID 🔒
Per-connection counter for log-correlation IDs (NOT the wire client_id — that comes from the reducer). Allocated even for pre-Register failures so log lines can be correlated.

Functions§

bind_first_pipe_instance
Bind the first named-pipe instance synchronously.
dispatch_synthetic_goodbye 🔒
Phase E.1b — synthetic Goodbye dispatch for ungraceful disconnects (EOF / read error before the client sent an explicit Goodbye). Without this, the reducer’s process record stays Running and a reconnect from the same live PID hits AlreadyRegistered. (codex P1 #610.)
enforce_register_first 🔒
Enforce the “first message must be Register” invariant. Returns Some(Event::Error) if the command violates the contract; the caller sends it and closes the connection.
handle_connection 🔒
Drive one connection: read newline-delimited JSON Commands, write back JSON Events. First message MUST be Register.
launcher_start_ms 🔒
Phase B.9.1 — milliseconds since the launcher’s IPC server started (first call seeds the epoch). Used as the monotonic clock for WRR observability timestamps in reducer::Ctx::now_ms. Distinct from chrono::Utc::now() because the WRR arm wants elapsed time, not wall clock — and we don’t want clock-skew jitter (NTP adjustment, DST) showing up as drift.
patch_launcher_identity 🔒
Patch launcher_pid + launcher_version into Event::Registered. The reducer leaves these as sentinels (it can’t read env without breaking determinism) — the server fills them in here, just before serializing to the wire.
run_ipc_server
Run the named-pipe IPC server until cancelled (or task panics).
send_event_shared 🔒
Serialize an Event as one JSON line + \n and write atomically (under the per-connection writer mutex). Returns Err if the connection died mid-write.