euv-cli 0.51.0

Cross-platform CLI tool for the euv native UI framework supporting run, build, check, fmt, doctor, new, and Hyperlane SSE dynamic updates across all supported platforms.
Documentation
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
use super::*;

/// Configuration for the read-only Hyperlane HTTP + SSE update server (never holds signing keys).
#[derive(Clone, Data, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct UpdateServerConfig {
    /// Local filesystem store root containing `staging/`, `blobs/`, `releases/`, `channels/`, and `state/`.
    pub(crate) store_root: PathBuf,
    /// Bind host address (default `127.0.0.1`).
    pub(crate) host: String,
    /// Bind TCP port (`0` selects an ephemeral port).
    #[get(type(copy))]
    pub(crate) port: u16,
    /// Optional external reverse-proxy base URL (e.g. `https://ota.example.com/euv`).
    #[serde(default)]
    pub(crate) proxy_base: String,
    /// SSE keep-alive heartbeat interval in milliseconds.
    #[get(type(copy))]
    pub(crate) heartbeat_ms: u64,
    /// SSE client reconnect retry hint in milliseconds.
    #[get(type(copy))]
    pub(crate) retry_ms: u64,
    /// Bounded per-topic SSE `Last-Event-ID` replay buffer size.
    #[get(type(copy))]
    pub(crate) replay_capacity: usize,
    /// Filesystem pointer watcher polling interval in milliseconds.
    #[get(type(copy))]
    pub(crate) watch_poll_ms: u64,
    /// Maximum allowed artifact byte size enforced during staging and publishing.
    #[get(type(copy))]
    pub(crate) max_artifact_bytes: u64,
    /// When `true`, initializes the store, validates bind readiness, and exits immediately.
    #[get(type(copy))]
    pub(crate) once: bool,
}

/// Atomically swapped active release pointer persisted in `channels/<project>/<channel>/active.json`.
#[derive(Clone, Data, Debug, Default, Deserialize, Eq, New, PartialEq, Serialize)]
pub struct ChannelPointer {
    /// Logical project identifier.
    pub(crate) project: String,
    /// Release channel name.
    pub(crate) channel: String,
    /// Compatibility track label.
    pub(crate) track: String,
    /// Strictly monotonic active release sequence number.
    #[get(type(copy))]
    pub(crate) active_release_seq: u64,
    /// SHA-256 hex digest of the active signed `ReleaseManifest`.
    pub(crate) manifest_sha256: String,
    /// UNIX epoch timestamp in seconds of the atomic pointer swap.
    #[get(type(copy))]
    pub(crate) updated_at_unix: u64,
}

/// Persisted bounded event record written to `state/events/<project>/<channel>.jsonl`.
#[derive(Clone, Data, Debug, Deserialize, Eq, New, PartialEq, Serialize)]
pub struct StoredReleaseEvent {
    /// Monotonic event identifier matching `event.to_release`.
    #[get(type(copy))]
    pub(crate) event_id: u64,
    /// Minimal `release.activated` metadata frame.
    pub(crate) event: ReleaseActivatedEvent,
}

/// Local filesystem update store managing `staging/`, `blobs/sha256/`, `releases/`, `channels/`, and `state/`.
#[derive(Clone, Data, Debug, Eq, New, PartialEq)]
pub struct UpdateStore {
    /// Root filesystem directory of the update store.
    pub(crate) root: PathBuf,
    /// Maximum allowed byte size for any single artifact (`0` disables cap).
    #[new(skip)]
    #[get(type(copy))]
    pub(crate) max_artifact_bytes: u64,
}

/// RAII writer lock guard owning `state/writer.lock` across multi-process CLI publish/rollback operations.
#[derive(Debug)]
pub(crate) struct UpdateWriterLockGuard {
    /// Lockfile path removed automatically on drop.
    pub(crate) lock_path: PathBuf,
}

/// Summary report emitted by `euv update stage`.
#[derive(Clone, Data, Debug, Deserialize, Eq, New, PartialEq, Serialize)]
pub struct StageReport {
    /// Stage identifier inside `staging/`.
    pub(crate) stage_id: String,
    /// Logical project identifier.
    pub(crate) project: String,
    /// Target release channel.
    pub(crate) channel: String,
    /// Number of verified blobs staged.
    #[get(type(copy))]
    pub(crate) blob_count: usize,
    /// Total verified staged bytes.
    #[get(type(copy))]
    pub(crate) total_bytes: u64,
}

/// Summary report emitted by `euv update publish` and `euv update rollback`.
#[derive(Clone, Data, Debug, Deserialize, Eq, New, PartialEq, Serialize)]
pub struct PublishReport {
    /// Logical project identifier.
    pub(crate) project: String,
    /// Release channel name.
    pub(crate) channel: String,
    /// Compatibility track name.
    pub(crate) track: String,
    /// Previous active release sequence (`0` if initial release).
    #[get(type(copy))]
    pub(crate) from_release: u64,
    /// Newly activated strictly monotonic release sequence.
    #[get(type(copy))]
    pub(crate) to_release: u64,
    /// Optional historical release sequence targeted when this publish is a rollback.
    #[new(skip)]
    #[get(skip)]
    pub(crate) rollback_of: Option<u64>,
    /// SHA-256 hex digest of the sealed signed manifest.
    pub(crate) manifest_sha256: String,
    /// Routes whose pinned dependency graphs changed.
    #[new(skip)]
    pub(crate) affected_routes: Vec<String>,
    /// Number of new blobs written into `blobs/sha256/`.
    #[new(skip)]
    #[get(type(copy))]
    pub(crate) blobs_written: usize,
}

/// Status summary for a single project/channel inside `UpdateStoreStatus`.
#[derive(Clone, Data, Debug, Deserialize, Eq, New, PartialEq, Serialize)]
pub struct ChannelStatusEntry {
    /// Logical project identifier.
    pub(crate) project: String,
    /// Channel name.
    pub(crate) channel: String,
    /// Current active channel pointer.
    pub(crate) pointer: ChannelPointer,
    /// Number of immutable release manifests stored under this channel.
    #[get(type(copy))]
    pub(crate) release_count: usize,
    /// Number of retained event log records under `state/events/`.
    #[get(type(copy))]
    pub(crate) event_count: usize,
}

/// Complete status snapshot emitted by `euv update status`.
#[derive(Clone, Data, Debug, Deserialize, Eq, New, PartialEq, Serialize)]
pub struct UpdateStoreStatus {
    /// Store root path string.
    pub(crate) store_root: String,
    /// Total immutable blobs currently stored in `blobs/sha256/`.
    #[get(type(copy))]
    pub(crate) blob_count: usize,
    /// Total disk bytes occupied by immutable blobs.
    #[get(type(copy))]
    pub(crate) blob_total_bytes: u64,
    /// Active channel summaries.
    pub(crate) channels: Vec<ChannelStatusEntry>,
}

/// Machine-readable report emitted by `euv update serve`.
#[derive(Clone, Data, Debug, Deserialize, Eq, New, PartialEq, Serialize)]
pub struct UpdateServerReport {
    /// Store root directory served.
    pub(crate) store_root: String,
    /// Bound HTTP base URL (e.g. `http://127.0.0.1:8787`).
    pub(crate) url: String,
    /// Manifest endpoint route template.
    pub(crate) manifest_route: String,
    /// Blob endpoint route template.
    pub(crate) blob_route: String,
    /// SSE events endpoint route template.
    pub(crate) events_route: String,
    /// Whether the server exited immediately after readiness validation (`--once`).
    #[get(type(copy))]
    pub(crate) once: bool,
}

/// Shared state mounted into Hyperlane routes for read-only manifest, blob, and SSE delivery.
#[cfg(feature = "update-server")]
#[derive(Clone)]
pub struct UpdateServerState {
    /// Backing atomic local filesystem update store.
    pub(crate) store: UpdateStore,
    /// Shared Hyperlane SSE pub/sub hub with bounded `Last-Event-ID` replay.
    pub(crate) sse_hub: SseHub,
    /// SSE stream heartbeat and reconnect configuration.
    pub(crate) sse_config: SseConfig,
    /// Optional configured reverse-proxy base URL advertised to clients.
    pub(crate) proxy_base: String,
    /// Last release sequence dispatched per `(project, channel)` to ensure exactly-once SSE fan-out per sequence.
    pub(crate) dispatched_seqs: Arc<Mutex<HashMap<(String, String), u64>>>,
    /// Cooperative running flag shared with the background pointer watcher.
    pub(crate) running: Arc<AtomicBool>,
}

/// Running handle to a live Hyperlane HTTP + SSE update server with clean programmatic shutdown.
#[cfg(feature = "update-server")]
pub struct UpdateServerHandle {
    /// Bound socket address (`ip:port`).
    pub(crate) address: SocketAddr,
    /// Shared update server state (store + SSE hub).
    pub(crate) state: Arc<UpdateServerState>,
    /// Hyperlane shutdown control hook.
    pub(crate) control: Option<ServerControlHook>,
    /// Dedicated Tokio runtime hosting the Hyperlane server and pointer watcher.
    pub(crate) runtime: Option<runtime::Runtime>,
}

/// Hyperlane `ServerHook` serving `GET /v1/projects/{project}/channels/{channel}/manifest`.
#[cfg(feature = "update-server")]
pub struct ManifestRouteHook;

/// Hyperlane `ServerHook` serving `GET /v1/blobs/{sha256}` with Range resume support.
#[cfg(feature = "update-server")]
pub struct BlobRouteHook;

/// Hyperlane `ServerHook` streaming `GET /v1/projects/{project}/channels/{channel}/events` via `hyperlane-plugin-sse`.
#[cfg(feature = "update-server")]
pub struct EventsRouteHook;

/// Hyperlane `ServerHook` serving `GET /healthz` JSON health and update store diagnostics.
#[cfg(feature = "update-server")]
pub struct HealthRouteHook;

/// JSON health and store status payload emitted by `GET /healthz`.
#[derive(Clone, Data, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct UpdateHealthResponse {
    /// Health status indicator (`"ok"`).
    pub(crate) status: String,
    /// Backing update store root directory path.
    pub(crate) store_root: String,
    /// Total content-addressed blobs currently stored in `blobs/sha256/`.
    #[get(type(copy))]
    pub(crate) blob_count: usize,
    /// Total disk bytes occupied by immutable blobs.
    #[get(type(copy))]
    pub(crate) blob_total_bytes: u64,
    /// Total active project/channel pointers discovered.
    #[get(type(copy))]
    pub(crate) channel_count: usize,
    /// Active channel status entries.
    pub(crate) channels: Vec<ChannelStatusEntry>,
    /// Whether the update server background watcher is running.
    #[get(type(copy))]
    pub(crate) running: bool,
    /// Current UNIX epoch timestamp in seconds.
    #[get(type(copy))]
    pub(crate) timestamp_unix: u64,
}

/// Generated HMAC-SHA256 signing secret summary emitted by `euv update keygen`.
#[derive(Clone, Data, Debug, Deserialize, Eq, New, PartialEq, Serialize)]
pub struct KeygenReport {
    /// 64-character lowercase hexadecimal 256-bit signing secret.
    pub(crate) signing_key: String,
    /// Target environment variable name (`EUV_UPDATE_SIGNING_KEY`).
    pub(crate) env_var: String,
    /// Ready-to-run shell export snippet.
    pub(crate) export_hint: String,
    /// Entropy bit length of the generated secret (`256`).
    #[get(type(copy))]
    pub(crate) bit_length: usize,
}

/// Persisted project OTA configuration written to `euv-ota.json` (never stores raw signing secrets).
#[derive(Clone, Data, Debug, Deserialize, Eq, New, PartialEq, Serialize)]
pub struct OtaProjectConfig {
    /// Configuration schema version (`1`).
    #[get(type(copy))]
    pub(crate) schema_version: u32,
    /// Logical project identifier.
    pub(crate) project: String,
    /// Default release channel name.
    pub(crate) channel: String,
    /// Relative or absolute local update store root path.
    pub(crate) store_root: String,
    /// Default update server HTTP base URL.
    pub(crate) server_url: String,
    /// Environment variable name holding the offline signing secret.
    pub(crate) signing_key_env: String,
}

/// Configuration for initializing an update store and optional `euv-ota.json` project config.
#[derive(Clone, Data, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct OtaInitConfig {
    /// Local update store root directory (default `.euv-updates`).
    pub(crate) store_root: PathBuf,
    /// Logical project identifier.
    pub(crate) project: String,
    /// Default release channel name.
    pub(crate) channel: String,
    /// Optional path where `euv-ota.json` should be written.
    pub(crate) config_path: Option<PathBuf>,
    /// Optional explicit signing secret (auto-generated when `None`).
    pub(crate) signing_key: Option<String>,
    /// Default update server URL written into `euv-ota.json`.
    pub(crate) server_url: String,
}

/// Summary report emitted by `euv update init`.
#[derive(Clone, Data, Debug, Deserialize, Eq, New, PartialEq, Serialize)]
pub struct OtaInitReport {
    /// Initialized update store root directory path.
    pub(crate) store_root: String,
    /// Logical project identifier.
    pub(crate) project: String,
    /// Default release channel name.
    pub(crate) channel: String,
    /// Path to generated `euv-ota.json`, or empty when omitted.
    pub(crate) config_file: String,
    /// Generated or provided 256-bit HMAC-SHA256 signing secret.
    pub(crate) signing_key: String,
    /// Environment variable name for the signing secret.
    pub(crate) signing_key_env: String,
    /// Subdirectories created or ensured under `store_root`.
    pub(crate) created_dirs: Vec<String>,
}

/// Sandbox and ABI verification summary for a dynamic `.wasm` widget binary.
#[derive(Clone, Data, Debug, Deserialize, Eq, New, PartialEq, Serialize)]
pub struct DynamicWasmValidation {
    /// Verified `euv_abi_version` return value.
    #[get(type(copy))]
    pub(crate) abi_version: u32,
    /// Sorted list of exported WASM function/memory names.
    pub(crate) exports: Vec<String>,
    /// Lowercase SHA-256 hex digest of the `.wasm` bytes.
    pub(crate) sha256: String,
    /// Byte length of the verified `.wasm` binary.
    #[get(type(copy))]
    pub(crate) size_bytes: u64,
}

/// Configuration for compiling, validating, and optionally pushing a Rust dynamic WASM widget crate.
#[derive(Clone, Data, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct OtaBuildConfig {
    /// Crate or workspace root directory containing `Cargo.toml`.
    pub(crate) manifest_dir: PathBuf,
    /// Optional Cargo package name to build (`--package`).
    pub(crate) package: Option<String>,
    /// Optional output file path for the validated `.wasm` artifact.
    pub(crate) out_path: Option<PathBuf>,
    /// Whether to compile with `--release` optimization profile.
    #[get(type(copy))]
    pub(crate) release: bool,
    /// Whether to immediately sign and publish the built `.wasm` into `store_root`.
    #[get(type(copy))]
    pub(crate) push: bool,
    /// Local update store root directory used when `push` is enabled.
    pub(crate) store_root: PathBuf,
    /// Logical project identifier used when `push` is enabled.
    pub(crate) project: String,
    /// Release channel name used when `push` is enabled.
    pub(crate) channel: String,
    /// Optional target route path updated when `push` is enabled.
    pub(crate) route: Option<String>,
    /// Optional target component slot identifier updated when `push` is enabled.
    pub(crate) slot: Option<String>,
    /// Optional signing secret used when `push` is enabled.
    pub(crate) signing_key: Option<String>,
}

/// Summary report emitted by `euv update build`.
#[derive(Clone, Data, Debug, Deserialize, Eq, New, PartialEq, Serialize)]
pub struct OtaBuildReport {
    /// Output filesystem path of the verified `.wasm` widget artifact.
    pub(crate) wasm_path: String,
    /// SHA-256 hex digest of the compiled `.wasm` binary.
    pub(crate) sha256: String,
    /// Byte length of the compiled `.wasm` binary.
    #[get(type(copy))]
    pub(crate) size_bytes: u64,
    /// Verified host ABI version reported by `euv_abi_version`.
    #[get(type(copy))]
    pub(crate) abi_version: u32,
    /// Sorted list of WASM module exports.
    pub(crate) exports: Vec<String>,
    /// Optional publish report when `--push` was enabled.
    #[new(skip)]
    pub(crate) pushed: Option<PublishReport>,
}

/// Configuration for the unified single-command `euv update dev` serve-and-watch loop.
#[derive(Clone, Data, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct OtaDevConfig {
    /// Local update store root directory.
    pub(crate) store_root: PathBuf,
    /// Host bind address (`127.0.0.1` or `0.0.0.0`).
    pub(crate) host: String,
    /// TCP listen port (`0` selects an ephemeral port).
    #[get(type(copy))]
    pub(crate) port: u16,
    /// Optional external reverse-proxy base URL.
    pub(crate) proxy_base: String,
    /// Logical project identifier.
    pub(crate) project: String,
    /// Release channel name (default `"dev"`).
    pub(crate) channel: String,
    /// Optional target route path for watched artifacts.
    pub(crate) route: Option<String>,
    /// Optional target component slot identifier for watched artifacts.
    pub(crate) slot: Option<String>,
    /// Optional watched `.json`, `.wasm`, or Rust widget crate directory path.
    pub(crate) watch_path: Option<PathBuf>,
    /// Optional Cargo package name when watching a Rust dynamic widget crate.
    pub(crate) package: Option<String>,
    /// Signing secret used for live pushes (auto-generated when empty).
    pub(crate) signing_key: String,
    /// SSE keep-alive heartbeat interval in milliseconds.
    #[get(type(copy))]
    pub(crate) heartbeat_ms: u64,
    /// Watcher poll interval in milliseconds.
    #[get(type(copy))]
    pub(crate) poll_ms: u64,
    /// When `true`, performs initial startup/push readiness verification and exits immediately.
    #[get(type(copy))]
    pub(crate) once: bool,
}

/// Machine-readable report emitted by `euv update dev`.
#[derive(Clone, Data, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct OtaDevReport {
    /// Backing update store root directory.
    pub(crate) store_root: String,
    /// Bound localhost HTTP URL.
    pub(crate) local_url: String,
    /// Detected LAN HTTP manifest URLs reachable from mobile devices and emulators.
    pub(crate) lan_urls: Vec<String>,
    /// Full manifest URL for the configured project and channel.
    pub(crate) manifest_url: String,
    /// Full SSE events URL for the configured project and channel.
    pub(crate) events_url: String,
    /// Health endpoint URL (`/healthz`).
    pub(crate) health_url: String,
    /// Configured logical project identifier.
    pub(crate) project: String,
    /// Configured release channel name.
    pub(crate) channel: String,
    /// Optional initial release published from `watch_path`.
    pub(crate) initial_release: Option<PublishReport>,
    /// Whether `--once` smoke mode exited immediately.
    #[get(type(copy))]
    pub(crate) once: bool,
}

/// Configuration controlling offline cryptographic and blob integrity verification (`euv update verify`).
#[derive(Clone, Data, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct OtaVerifyConfig {
    /// Local update store root directory to audit.
    pub(crate) store_root: PathBuf,
    /// Optional project filter.
    pub(crate) project: Option<String>,
    /// Optional channel filter.
    pub(crate) channel: Option<String>,
    /// Optional HMAC-SHA256 signing secret enabling full cryptographic signature verification.
    pub(crate) signing_key: Option<String>,
    /// When `true`, audits every historical release manifest in addition to active pointers.
    #[get(type(copy))]
    pub(crate) all_releases: bool,
    /// Optional explicit release sequence number to audit instead of active/all releases.
    #[get(type(copy))]
    #[serde(default)]
    pub(crate) release_seq: Option<u64>,
}

/// Individual integrity finding recorded during `euv update verify`.
#[derive(Clone, Data, Debug, Deserialize, Eq, New, PartialEq, Serialize)]
pub struct OtaVerifyIssue {
    /// Severity level (`"error"` or `"warning"`).
    pub(crate) severity: String,
    /// Affected channel, release sequence, or blob identifier.
    pub(crate) scope: String,
    /// Human-readable diagnostic description.
    pub(crate) message: String,
}

/// Complete offline integrity audit report emitted by `euv update verify`.
#[derive(Clone, Data, Debug, Deserialize, Eq, New, PartialEq, Serialize)]
pub struct OtaVerifyReport {
    /// Audited update store root path.
    pub(crate) store_root: String,
    /// `true` when zero `"error"` issues were found.
    #[get(type(copy))]
    pub(crate) valid: bool,
    /// Number of channel pointers audited.
    #[get(type(copy))]
    pub(crate) channels_checked: usize,
    /// Number of release manifests audited.
    #[get(type(copy))]
    pub(crate) releases_checked: usize,
    /// Number of manifests cryptographically verified via HMAC-SHA256.
    #[get(type(copy))]
    pub(crate) signatures_verified: usize,
    /// Number of unique content-addressed blobs verified via SHA-256.
    #[get(type(copy))]
    pub(crate) blobs_verified: usize,
    /// Recorded errors and warnings.
    pub(crate) issues: Vec<OtaVerifyIssue>,
}

/// Per-artifact comparison entry inside `OtaReleaseDiff`.
#[derive(Clone, Data, Debug, Deserialize, Eq, New, PartialEq, Serialize)]
pub struct OtaArtifactDiff {
    /// Canonical artifact key (`"module_id@version"`).
    pub(crate) artifact_key: String,
    /// Classification (`"added"`, `"removed"`, `"changed"`, or `"unchanged"`).
    pub(crate) status: String,
    /// SHA-256 digest in the base release, if present.
    pub(crate) from_sha256: Option<String>,
    /// SHA-256 digest in the target release, if present.
    pub(crate) to_sha256: Option<String>,
    /// Byte size in the base release (`0` if added).
    #[get(type(copy))]
    pub(crate) from_bytes: u64,
    /// Byte size in the target release (`0` if removed).
    #[get(type(copy))]
    pub(crate) to_bytes: u64,
    /// Signed byte size difference (`to_bytes - from_bytes`).
    #[get(type(copy))]
    pub(crate) size_delta_bytes: i64,
}

/// Structured comparison between two release sequences (`from_seq` -> `to_seq`) emitted by `euv update diff`.
#[derive(Clone, Data, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct OtaReleaseDiff {
    /// Logical project identifier.
    pub(crate) project: String,
    /// Release channel name.
    pub(crate) channel: String,
    /// Base release sequence number.
    #[get(type(copy))]
    pub(crate) from_seq: u64,
    /// Target release sequence number.
    #[get(type(copy))]
    pub(crate) to_seq: u64,
    /// Compatibility track label of `from_seq`.
    pub(crate) from_track: String,
    /// Compatibility track label of `to_seq`.
    pub(crate) to_track: String,
    /// Whether the compatibility track changed between releases.
    #[get(type(copy))]
    pub(crate) track_changed: bool,
    /// Delivery channel mode label of `from_seq`.
    pub(crate) from_delivery_mode: String,
    /// Delivery channel mode label of `to_seq`.
    pub(crate) to_delivery_mode: String,
    /// SHA-256 digest of the base release manifest.
    pub(crate) from_manifest_sha256: String,
    /// SHA-256 digest of the target release manifest.
    pub(crate) to_manifest_sha256: String,
    /// Optional rollback origin recorded on `to_seq`.
    #[get(type(copy))]
    pub(crate) rollback_of: Option<u64>,
    /// Routes whose transitive dependency graph changed.
    pub(crate) affected_routes: Vec<String>,
    /// Routes newly introduced in `to_seq`.
    pub(crate) added_routes: Vec<String>,
    /// Routes removed in `to_seq`.
    pub(crate) removed_routes: Vec<String>,
    /// Per-artifact SHA-256 and byte-size deltas.
    pub(crate) artifact_diffs: Vec<OtaArtifactDiff>,
    /// Total artifact bytes in `from_seq`.
    #[get(type(copy))]
    pub(crate) total_from_bytes: u64,
    /// Total artifact bytes in `to_seq`.
    #[get(type(copy))]
    pub(crate) total_to_bytes: u64,
    /// Signed total byte delta (`total_to_bytes - total_from_bytes`).
    #[get(type(copy))]
    pub(crate) total_size_delta_bytes: i64,
}

/// Configuration controlling safe update store garbage collection (`euv update gc`).
#[derive(Clone, Data, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct OtaGcConfig {
    /// Local update store root directory.
    pub(crate) store_root: PathBuf,
    /// Number of newest releases per channel to keep (active, track, and rollback targets are always preserved).
    #[get(type(copy))]
    pub(crate) keep_releases: usize,
    /// When `true`, computes removals without deleting files on disk.
    #[get(type(copy))]
    pub(crate) dry_run: bool,
    /// When `true`, removes stale directories under `staging/`.
    #[get(type(copy))]
    pub(crate) prune_staging: bool,
}

/// Summary report emitted by `euv update gc`.
#[derive(Clone, Data, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct OtaGcReport {
    /// Garbage-collected update store root path.
    pub(crate) store_root: String,
    /// Whether `--dry-run` prevented on-disk deletions.
    #[get(type(copy))]
    pub(crate) dry_run: bool,
    /// Number of release manifests retained across all channels.
    #[get(type(copy))]
    pub(crate) releases_kept: usize,
    /// Number of unreferenced old release manifests removed.
    #[get(type(copy))]
    pub(crate) releases_removed: usize,
    /// Number of referenced content-addressed blobs retained.
    #[get(type(copy))]
    pub(crate) blobs_kept: usize,
    /// Number of orphan blobs removed.
    #[get(type(copy))]
    pub(crate) blobs_removed: usize,
    /// Number of stale staging directories removed.
    #[get(type(copy))]
    pub(crate) staging_dirs_removed: usize,
    /// Total disk bytes reclaimed (or reclaimable in dry-run mode).
    #[get(type(copy))]
    pub(crate) bytes_reclaimed: u64,
    /// Sorted list of removed (or candidate) filesystem paths.
    pub(crate) removed_paths: Vec<String>,
}

/// Protocol-level HTTP response returned by the embeddable v1 OTA request handler mounted inside `euv dev`.
#[derive(Clone, Data, Debug, Eq, New, PartialEq)]
pub struct EmbeddedOtaResponse {
    /// Numeric HTTP status code (`200`, `204`, `206`, `304`, `400`, `404`, `405`, `409`, `416`).
    #[get(type(copy))]
    pub(crate) status_code: u16,
    /// HTTP status reason phrase (`"OK"`, `"Not Modified"`, etc.).
    #[get(type(copy))]
    pub(crate) status_text: &'static str,
    /// Response `Content-Type` header value.
    #[get(type(copy))]
    pub(crate) content_type: &'static str,
    /// Additional HTTP response header `(name, value)` pairs.
    pub(crate) headers: Vec<(String, String)>,
    /// Raw HTTP response body bytes.
    pub(crate) body: Vec<u8>,
}