Expand description
POST /v1/agent/events — inbound event ingestion (RFC-0005 §4.2).
The agent posts a single AgentEvent per call. The handler:
- Authenticates the caller via mTLS (
require_cn_layermiddleware has already verified the cert and stampedAuthenticatedCn). - Cross-checks the cert CN’s machine_id against the body’s
hostname— same pattern as/v1/agent/report. CN-vs-body mismatch ⇒ 403. - Deduplicates by
(hostname, rollout_id, seq)against thehost_rollout_records.last_event_seqcolumn. A seq ≤ the stored value is a replay/duplicate and silently 204s (the agent retries are idempotent by design). - Maps the wire
AgentEventonto the matchingnixfleet_state_machine::Event::Remote*variant and sends it into the reducer’s input MPSC. - Returns 204 on success, 503 if the runtime channel is unavailable
(only observable during a narrow startup window before
serve()wiresstate.runtime_input_tx).
Signature verification on the body is a forward-looking TODO. v0.2
trusts the mTLS cert chain (RFC-0002 §3) — a Phase 7+ pass adds
per-event signatures so an event_log replay can detect tampering
against a stored cert change. The wire envelope already carries an
optional signature field so adding enforcement is non-breaking.
Functions§
- events 🔒