1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
//! Host-side telemetry receiver for the in-VM observability path (Phase F).
//!
//! **Status: F3b — vsock listener + host-stamping + agent-silenced detection
//! shipped.** The remaining F-phase work is F4b (supervisor signing of the
//! outbound CloudEvents) and F1b (additive event constructor for
//! `cell.observability.guest.agent_silenced`). ADR-0006 is the doctrine
//! reference.
//!
//! Role: bind a per-cell UDS at `<vsock_uds_base>_9001` BEFORE the workload
//! runs, receive CBOR-framed `cell.observability.guest.*` events from the
//! in-guest [`cellos-telemetry`] agent, host-stamp the non-negotiable
//! attribution fields (`cell_id`, `run_id`, `host_received_at`,
//! `spec_signature_hash`, ADG `output`), and produce internal
//! [`StampedDeclaration`] values the F4b signer projects to `CloudEventV1`
//! via the [`cellos_core::events`] builders.
//!
//! Channel-authenticity model (ADR-0006 §5): the host trusts WHICH UDS path
//! the bytes arrived on (Firecracker proxies the guest's vsock connection
//! to a per-cell UDS at `<vsock_uds_base>_<port>`), not a payload signature.
//! The guest agent must NOT hold a signing key. This crate must NEVER take
//! a dependency on signing primitives that would let it accept guest-signed
//! envelopes; the supervisor signs outbound, period.
//!
//! Module layout:
//!
//! - [`listener`] — per-cell UDS bind + CBOR frame decode + `content_version`
//! major-version gate.
//! - [`host_stamp`] — projects [`GuestDeclaration`] + [`HostStamp`] into
//! the internal [`StampedDeclaration`] value type.
//! - [`keepalive`] — `KeepAlive` tracker, `AgentSilencedTrigger` (fire-once),
//! and `watch_for_silence` watcher loop.
//!
//! See [docs/adr/0006-in-vm-observability-runner-evidence.md] for the
//! complete decision record.
use SystemTime;
use Error;
pub use ;
/// Vsock port reserved for guest telemetry events.
///
/// The supervisor binds the per-cell UDS at `<vsock_uds_base>_9001` BEFORE
/// the workload's first instruction so the channel-authenticity primitive
/// holds (ADR-0006 §5). Mirrors the `_9000` exit-code UDS in
/// `cellos-host-firecracker`.
pub const VSOCK_TELEMETRY_PORT: u32 = 9001;
/// CBOR wire-format major version. Host rejects unknown majors per
/// ADR-0006 §12 wire-schema versioning.
///
/// Value layout: low byte = minor, high byte = major. The major-version
/// check in [`listener::decode_frame`] reads `(content_version >> 8) as u8`.
pub const WIRE_CONTENT_VERSION_MAJOR: u16 = 1;
/// Errors surfaced by the telemetry receiver.
/// Fields a guest-side agent fills. Anything else is host-stamped on
/// receipt and overrides what the guest sent (ADR-0006 §6).
///
/// **Type-level non-forgeability.** The struct has no `cell_id`/`run_id`/
/// `spec_signature_hash` fields — the wire decoder (`listener::decode_frame`)
/// drops any such keys the guest tries to stuff into the CBOR map, and the
/// stamping layer (`host_stamp::stamp`) reads attribution exclusively from
/// [`HostStamp`]. This is the structural enforcement of ADR-0006 §6: a
/// compromised guest cannot forge cross-cell attribution because the
/// attribution fields don't exist on this type.
/// Attribution fields stamped supervisor-side on every guest declaration.
/// Overrides whatever the guest sent — non-negotiable per ADR-0006 §6.
/// Forward-looking F3 host-probe reading shape (ADR-0006 acceptance prep,
/// 2026-05-16). The richer `probes::HostProbe` / `probes::ProbeReading` API
/// in this crate is the F3a implementation; this simpler envelope is the
/// minimal contract documented for future host-side probes that emit
/// `cellos.events.host.probe.v1` CloudEvents without needing the full
/// `ProbeContext` / `EventSink` plumbing.
///
/// Implementations of `probes::HostProbe` are the canonical path today;
/// this struct is the additive forward declaration.
/// Internal value type: a guest declaration with host-stamped attribution.
///
/// **Internal — not a CloudEvent.** F4b owns signing and projects this to
/// [`cellos_core::CloudEventV1`] via the existing
/// `cellos_core::events::observability_*_data_v1` builders. This crate
/// produces unsigned values; the supervisor signs them on the way out.