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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
//! The wire vocabulary of trusty-console's own Unix socket (#10902, ADR-0065).
//!
//! Why: the owner's D8b ruling gives the console a UDS listener so the TUI can
//! read the console's fleet view over the same transport every other service
//! uses (ADR-0032), and aggregate health over UDS (ADR-0035). The TUI lives in
//! trusty-mpm, which has no Cargo edge on trusty-console, so the method names
//! and the payload types it must decode live here, beside the other per-service
//! RPC vocabularies (`memory_rpc`, `mpm_rpc`).
//! What: the socket's service name, the method names, the
//! [`ConsoleHealth`](crate::console_rpc::ConsoleHealth) and
//! [`ConsoleFleetStatus`](crate::console_rpc::ConsoleFleetStatus) response
//! types, and the per-service row types
//! ([`ServiceInfo`](crate::console_rpc::ServiceInfo),
//! [`ServiceStatus`](crate::console_rpc::ServiceStatus),
//! [`ServiceLifecycle`](crate::console_rpc::ServiceLifecycle)) that moved here from `trusty_console::connector`,
//! which re-exports them. Ungated: the types need only `serde`, and a reader
//! should not compile the socket machinery to decode a payload. The
//! `console.machine_status` and `console.history` payloads embed host metrics,
//! so they live in the `metrics` submodule, gated on `console-metrics` +
//! `host-metrics` (#10942).
//!
//! **Forward compatibility.** No type here uses `deny_unknown_fields`, and every
//! field a later console adds must carry `#[serde(default)]`, so an older TUI
//! decodes a newer console's answer and the reverse.
//!
//! Test: `console_rpc_tests` below, and the console's
//! `console_uds::tests` over a real socket.
// See #10902
use ;
// #10942: the machine-status and history payloads; see the module docs.
/// The service name the console's socket is derived from.
///
/// `crate::daemon_socket_path(CONSOLE_SERVICE)` is `{data_dir}/trusty-console.sock`
/// (ADR-0065 reserves that name for the console's own API).
pub const CONSOLE_SERVICE: &str = "trusty-console";
/// Liveness probe: answers [`ConsoleHealth`] and never touches the poller.
pub const METHOD_HEALTH: &str = "console.health";
/// The console's cached all-services snapshot, as [`ConsoleFleetStatus`].
pub const METHOD_FLEET_STATUS: &str = "console.fleet_status";
/// Whole-machine status, as `metrics::ConsoleMachineStatus` (#10942).
pub const METHOD_MACHINE_STATUS: &str = "console.machine_status";
/// The 10-minute host, transition and per-service window, as
/// `metrics::HistorySnapshot` (#10942, #10943).
pub const METHOD_HISTORY: &str = "console.history";
/// Every method the console's socket serves.
///
/// Why: a contract test compares the router's names against this list, so a
/// rename shows up as a failing assertion rather than as a consumer reporting
/// `method_not_found`. trusty-console's router test compares against it.
/// Test: `console_fleet_status_decodes_a_payload_missing_new_fields`.
pub const METHODS: & = &;
/// The `console.health` answer.
///
/// Why: the TUI's Console tile needs "is the console up, which build, for how
/// long" in one cheap call. The field names match the other `<service>.health`
/// answers (`status`, `service`, `version`, `uptime_secs`) so one decoder reads
/// them all.
/// What: `status` is `"ok"` whenever the console answers; `service` is
/// [`CONSOLE_SERVICE`]; `version` is the console crate's version; `uptime_secs`
/// is whole seconds since the console built its state.
/// Test: `console_health_round_trips_and_tolerates_unknown_fields`.
/// The `console.fleet_status` answer: the console's cached services snapshot.
///
/// Why: the TUI home takes service status from the console when it is up
/// (D8b (b)), which only saves work if the answer comes from the cache the
/// console's own poller keeps warm — never a fresh probe per call.
/// What: `services` is exactly the body `GET /api/console/services` returns for
/// the same cache state: overlaid with MCP-handle state and per-service
/// metrics, ordered for display. `ready` is `false` until the first poll lands;
/// `services` is then empty and the reader should probe the services itself.
/// `overlaid` is `false` when the handle overlay could not finish inside its
/// budget and the rows are the poller's own, unmodified.
/// Test: `console_fleet_status_decodes_a_payload_missing_new_fields`.
/// Runtime status of one detected service.
///
/// Why: Four states capture everything the console needs — whether the binary
/// exists, whether a daemon is running, whether the MCP handshake succeeded but
/// the expected tool is missing (Degraded), and whether the binary is absent.
/// What: Serialises to a lowercase string for the JSON API. `Unknown` is the
/// decode-side catch-all for a spelling this build does not know.
/// Test: `console_fleet_status_decodes_a_payload_missing_new_fields`,
/// `history_snapshot_decodes_unknown_state_and_status_as_unknown`.
/// How a service is meant to run when it is healthy.
///
/// Why (#6416): `ServiceStatus::Available` means "the binary is installed and
/// nothing is serving". For an on-demand member that IS the healthy resting
/// state, and `status` alone cannot tell the two readings apart; this does.
/// What: a per-member constant, not an observation. A connector picks it once
/// and every `ServiceInfo` it builds carries it, `Absent` rows included.
/// Test: `console_fleet_status_decodes_a_payload_missing_new_fields`.
/// All facts gathered about a service in one detection pass.
///
/// Why: `GET /api/console/services` and `console.fleet_status` both serialise
/// this directly, so every reader gets one stable row shape.
/// What: `id` is the stable machine identifier; `display_name` is human-
/// readable; `status` is the current runtime state; `version` is the daemon's
/// reported version when running; `url` is the daemon base URL when reachable;
/// `hint` is a remediation message surfaced when `status` is `Degraded`;
/// `lifecycle` says whether a stopped daemon or an installed on-demand binary
/// is the healthy reading of that status (#6416); `cpu_pct` and `rss_bytes`
/// are the newest per-service samples (#6642, #6773).
/// Test: `console_fleet_status_decodes_a_payload_missing_new_fields`.