Expand description
Reducer task body. Sole nixfleet_state_machine::step caller per
invariant (1) in runtime::mod.
State held in-task:
- per-rollout
HostRolloutStatekeyed byrollout_id(the agent owns its own host’s state, so the key is just the rollout id) - cached
SignedManifestSet(refreshed by themanifest_pollworker per RFC-0004 §1 invariant #1 — single signed source of truth fetched + verified once per tick; the reducer reads rollout policy from it forstep()calls)
Seq assignment: workers emit events with seq = 0. The reducer
rewrites it to state.last_event_seq + 1 before calling step()
— single mutator owns the per-rollout monotonic counter, so
cross-worker ordering can’t race.
Constants§
- SUSTAINED_
FAILURE_ 🔒THRESHOLD_ SECS - Sustained-failure window cap. RFC-0005 §6 — the agent transitions Soaking → Failed when a probe has been failing continuously past this threshold.
Functions§
- all_
enforce_ 🔒probes_ pass - All enforce-mode probes have status
Pass. Observe and Disabled are ignored per RFC-0007 §3.3 (ProbeMode docstring, state.rs); they do not gate convergence. Mirror ofcollect_failing_enforce_probeson the Soaking → Converged exit path. Empty enforce set trivially satisfies — matches the shared verifier’s “empty probe map acceptable” semantic inverify_converged_invariants. - apply_
bootstrap_ 🔒snapshot - LIFT #3 + LIFT #4: apply a CP-supplied HostRolloutSnapshot to the agent’s in-memory reducer cache, then emit the worker re-priming effects the rehydrated state demands.
- bootstrap_
pending_ 🔒state - First-touch bootstrap for a fresh
LocalActivateevent. Pure: derives channel from the canonicalRolloutIdcomposite (RFC-0008 §6.3); the caller threads in the manifest-looked-uptarget_closurefor this host (selecting byhostname == cfg.machine_id) and the CP-resolvedsoak_due_atcarried by theLocalActivateevent fromDispatchResponse.soak_due_at(CP is the single source of truth for the policy-resolved soak window per RFC-0004 §1 invariant 1). Caller also threadsnowso the helper stays clock-injection-free. - collect_
failing_ 🔒enforce_ probes - Collect probe names that are currently failing AND declared with
mode = Enforce. Per RFC-0007 §3.4, onlyEnforce-mode probes participate in the soak gate;ObserveandDisabledrecords events but does not gate. The pre-fix builder filtered only bystatus == Fail, which silently included failingObserve-mode probes inLocalSustainedFailureCrossed.failing_probesand gated soak promotion against the documented contract. - handle_
input 🔒 - merge_
snapshot_ 🔒into_ state - Pure merge of a wire snapshot with the existing in-memory entry.
Canonical fields (state, target_closure, dispatch/activation
timestamps, last_event_seq) come from the snapshot. Agent-local
fields not carried in the wire shape are preserved from
existingwhen present, defaulted when not. - resolve_
policy 🔒 - run
- run_
advance_ 🔒tick - run_
host_ 🔒event - with_
seq 🔒 - Rewrite the
seqfield on aLocal*event. The reducer owns the monotonic counter (single mutator) so workers can emit withseq = 0and let this function fill it in.