Skip to main content

ic_query/ic/node_status/
model.rs

1//! Module: ic::node_status::model
2//!
3//! Responsibility: public observed node-status requests, evidence, reports, and errors.
4//! Does not own: source calls, cache IO, projection, or rendering.
5//! Boundary: preserves raw Dashboard status data and explicit off-chain/cache provenance.
6
7use crate::ic::IcDashboardReportProvenance;
8use serde::{Deserialize as SerdeDeserialize, Serialize};
9use std::fmt;
10#[cfg(feature = "dashboard-host")]
11use std::path::PathBuf;
12use thiserror::Error as ThisError;
13
14///
15/// IcNodeStatusScope
16///
17/// Dashboard collection scope retained by an observed node-status snapshot.
18///
19
20#[derive(Clone, Copy, Debug, Eq, PartialEq, SerdeDeserialize, Serialize)]
21#[serde(rename_all = "snake_case")]
22pub enum IcNodeStatusScope {
23    /// Dashboard's default public-mainnet node set, excluding cloud-engine Type4 nodes.
24    DashboardMainnetDefault,
25}
26
27impl IcNodeStatusScope {
28    /// Return the stable serialized scope label.
29    #[must_use]
30    pub const fn as_str(self) -> &'static str {
31        match self {
32            Self::DashboardMainnetDefault => super::IC_NODE_STATUS_SCOPE,
33        }
34    }
35}
36
37///
38/// IcNodeOperationalStatus
39///
40/// Known Dashboard node-status classification used for filtering and counts.
41///
42
43#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, Serialize)]
44#[serde(rename_all = "snake_case")]
45pub enum IcNodeOperationalStatus {
46    /// The Dashboard reports the node as up.
47    Up,
48    /// The Dashboard reports the node as down.
49    Down,
50    /// The Dashboard reports the node as administratively disabled.
51    Disabled,
52    /// The Dashboard reports degraded operation.
53    Degraded,
54    /// The raw Dashboard value is not recognized by this release.
55    Unknown,
56}
57
58impl IcNodeOperationalStatus {
59    /// Classify raw Dashboard status text without discarding unknown future values.
60    #[must_use]
61    pub fn from_raw(raw: &str) -> Self {
62        match raw {
63            "UP" => Self::Up,
64            "DOWN" => Self::Down,
65            "DISABLED" => Self::Disabled,
66            "DEGRADED" => Self::Degraded,
67            _ => Self::Unknown,
68        }
69    }
70
71    /// Return the stable lowercase display label.
72    #[must_use]
73    pub const fn as_str(self) -> &'static str {
74        match self {
75            Self::Up => "up",
76            Self::Down => "down",
77            Self::Disabled => "disabled",
78            Self::Degraded => "degraded",
79            Self::Unknown => "unknown",
80        }
81    }
82}
83
84impl fmt::Display for IcNodeOperationalStatus {
85    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
86        formatter.write_str(self.as_str())
87    }
88}
89
90///
91/// IcNodeStatusCounts
92///
93/// Exact status totals derived from raw observed node rows.
94///
95
96#[derive(Clone, Debug, Default, Eq, PartialEq, SerdeDeserialize, Serialize)]
97pub struct IcNodeStatusCounts {
98    /// Total observed rows in the group.
99    pub total: usize,
100    /// Rows classified as `UP`.
101    pub up: usize,
102    /// Rows classified as `DOWN`.
103    pub down: usize,
104    /// Rows classified as `DISABLED`.
105    pub disabled: usize,
106    /// Rows classified as `DEGRADED`.
107    pub degraded: usize,
108    /// Rows whose raw status is not recognized.
109    pub unknown: usize,
110}
111
112impl IcNodeStatusCounts {
113    /// Return every row not classified as raw Dashboard `UP`.
114    #[must_use]
115    pub const fn non_up(&self) -> usize {
116        self.total.saturating_sub(self.up)
117    }
118}
119
120///
121/// IcNodeAssignmentStatusCounts
122///
123/// Operational-status totals partitioned by mutually exclusive assignment class.
124///
125
126#[derive(Clone, Debug, Default, Eq, PartialEq, SerdeDeserialize, Serialize)]
127pub struct IcNodeAssignmentStatusCounts {
128    /// Status totals for nodes with an observed assigned Subnet.
129    pub assigned: IcNodeStatusCounts,
130    /// Status totals for rows whose raw node type is `UNASSIGNED`.
131    pub unassigned: IcNodeStatusCounts,
132    /// Status totals for rows whose raw node type is `API_BOUNDARY`.
133    pub api_boundary: IcNodeStatusCounts,
134    /// Status totals for rows without a known assignment class.
135    pub unknown: IcNodeStatusCounts,
136}
137
138///
139/// IcNodeStatusGroupCounts
140///
141/// Overall and assignment-partitioned status totals for one aggregate group.
142///
143
144#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize)]
145pub struct IcNodeStatusGroupCounts {
146    /// Raw operational-status totals for the group.
147    pub statuses: IcNodeStatusCounts,
148    /// Raw operational-status totals partitioned by assignment class.
149    pub assignment_statuses: IcNodeAssignmentStatusCounts,
150}
151
152///
153/// IcNodeCountComparison
154///
155/// Ordering of one observed node count relative to another.
156///
157
158#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize)]
159#[serde(rename_all = "snake_case")]
160pub enum IcNodeCountComparison {
161    /// The left-hand count is smaller.
162    Less,
163    /// The two counts are equal.
164    Equal,
165    /// The left-hand count is larger.
166    Greater,
167}
168
169impl IcNodeCountComparison {
170    /// Compare a left-hand count with a right-hand count.
171    #[must_use]
172    pub const fn from_counts(left: usize, right: usize) -> Self {
173        if left < right {
174            Self::Less
175        } else if left > right {
176            Self::Greater
177        } else {
178            Self::Equal
179        }
180    }
181
182    /// Return the stable lowercase label.
183    #[must_use]
184    pub const fn as_str(self) -> &'static str {
185        match self {
186            Self::Less => "less",
187            Self::Equal => "equal",
188            Self::Greater => "greater",
189        }
190    }
191}
192
193///
194/// IcNodeCountComparisonCounts
195///
196/// Number of provider groups in each node-count comparison outcome.
197///
198
199#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize)]
200pub struct IcNodeCountComparisonCounts {
201    /// Provider groups whose left-hand count is smaller.
202    pub less: usize,
203    /// Provider groups whose counts are equal.
204    pub equal: usize,
205    /// Provider groups whose left-hand count is larger.
206    pub greater: usize,
207}
208
209///
210/// IcNodeStatusRow
211///
212/// One raw node observation retained from the official Dashboard node resource.
213///
214
215#[derive(Clone, Debug, Eq, PartialEq, SerdeDeserialize, Serialize)]
216pub struct IcNodeStatusRow {
217    /// Canonical node principal.
218    pub node_id: String,
219    /// Canonical node-operator principal.
220    pub node_operator_id: String,
221    /// Canonical node-provider principal.
222    pub node_provider_id: String,
223    /// Off-chain Dashboard node-provider name.
224    pub node_provider_name: String,
225    /// Raw Dashboard node type.
226    pub node_type: String,
227    /// Raw Registry reward type reported by the Dashboard.
228    pub node_reward_type: String,
229    /// Raw Dashboard operational status.
230    pub status: String,
231    /// Raw Dashboard alert name when present.
232    pub alert_name: Option<String>,
233    /// Assigned Subnet principal when present.
234    pub subnet_id: Option<String>,
235    /// CloudEngine Subnet principal when reported by the selected Dashboard scope.
236    pub cloud_engine_subnet_id: Option<String>,
237    /// Dashboard data-center identifier.
238    pub data_center_id: String,
239    /// Dashboard data-center name.
240    pub data_center_name: String,
241    /// Dashboard infrastructure owner label.
242    pub owner: String,
243    /// Raw Dashboard geographic region label.
244    pub region: String,
245    /// Observed GuestOS version when reported.
246    pub guestos_version: Option<String>,
247    /// Observed GuestOS trusted-execution status when reported.
248    pub guestos_tee_active: Option<bool>,
249    /// Observed node IP address when reported.
250    pub ip_address: Option<String>,
251    /// Observed IPv4-connectivity state when reported.
252    pub ipv4_connectivity_status: Option<bool>,
253    /// Dashboard hardware-generation label when reported.
254    pub node_hardware_generation: Option<String>,
255}
256
257impl IcNodeStatusRow {
258    /// Return the known classification of this row's raw status.
259    #[must_use]
260    pub fn operational_status(&self) -> IcNodeOperationalStatus {
261        IcNodeOperationalStatus::from_raw(&self.status)
262    }
263
264    /// Return whether the raw row is anything other than known `UP`.
265    #[must_use]
266    pub fn is_non_up(&self) -> bool {
267        self.operational_status() != IcNodeOperationalStatus::Up
268    }
269}
270
271///
272/// IcNodeStatusCacheEvidence
273///
274/// Caller-relative local cache evidence attached to a projected status report.
275///
276
277#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
278pub struct IcNodeStatusCacheEvidence {
279    /// Canonical local cache path used by the report.
280    pub cache_path: String,
281    /// Whether the cache is within the default age policy for this caller's time.
282    pub cache_fresh: bool,
283    /// Cache age at report construction.
284    pub age_seconds: u64,
285    /// Age threshold used to classify freshness.
286    pub stale_after_seconds: u64,
287}
288
289///
290/// IcNodeStatusObservation
291///
292/// Shared source, scope, and optional cache evidence for status reports.
293///
294
295#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
296pub struct IcNodeStatusObservation {
297    #[serde(flatten)]
298    /// Official Dashboard source provenance.
299    pub source: IcDashboardReportProvenance,
300    /// Explicit node collection scope.
301    pub scope: IcNodeStatusScope,
302    /// Whether cloud-engine nodes were included in the source collection.
303    pub cloud_engine_nodes_included: bool,
304    /// Local cache evidence, absent for a pure live snapshot.
305    pub cache: Option<IcNodeStatusCacheEvidence>,
306}
307
308///
309/// IcNodeStatusSnapshot
310///
311/// Complete canonical observed node snapshot used by every status projection.
312///
313
314#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
315pub struct IcNodeStatusSnapshot {
316    #[serde(flatten)]
317    /// Shared source and scope evidence.
318    pub observation: IcNodeStatusObservation,
319    /// Canonically ordered raw node rows.
320    pub nodes: Vec<IcNodeStatusRow>,
321}
322
323///
324/// IcNodeStatusSourceData
325///
326/// Untrusted raw node rows and provenance returned by a Dashboard source capability.
327///
328
329#[cfg(feature = "dashboard-host")]
330#[derive(Clone, Debug, Eq, PartialEq)]
331pub struct IcNodeStatusSourceData {
332    /// Source-call provenance echoed by the source.
333    pub source: crate::ic::IcSourceRequest,
334    /// Explicit Dashboard collection scope.
335    pub scope: IcNodeStatusScope,
336    /// Whether the source claims cloud-engine node inclusion.
337    pub cloud_engine_nodes_included: bool,
338    /// Raw observed node rows.
339    pub nodes: Vec<IcNodeStatusRow>,
340}
341
342///
343/// IcNodeStatusView
344///
345/// Target and attention selection shared by node, Subnet, and provider views.
346///
347
348#[derive(Clone, Debug, Default, Eq, PartialEq)]
349pub struct IcNodeStatusView {
350    /// Optional exact identifier or unique principal prefix.
351    pub target: Option<String>,
352    /// Whether fully-up rows or groups are included without a target.
353    pub include_all: bool,
354}
355
356impl IcNodeStatusView {
357    /// Construct the default attention-only view.
358    #[must_use]
359    pub const fn attention() -> Self {
360        Self {
361            target: None,
362            include_all: false,
363        }
364    }
365}
366
367///
368/// IcNodeStatusReport
369///
370/// Node-level view over one complete observed status snapshot.
371///
372
373#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
374pub struct IcNodeStatusReport {
375    #[serde(flatten)]
376    /// Shared source, scope, and cache evidence.
377    pub observation: IcNodeStatusObservation,
378    /// Total rows in the complete source snapshot.
379    pub snapshot_node_count: usize,
380    /// Snapshot-wide overall and assignment-partitioned totals.
381    pub counts: IcNodeStatusGroupCounts,
382    /// Whether the view includes fully-up rows.
383    pub include_all: bool,
384    /// Target text supplied by the caller.
385    pub requested_target: Option<String>,
386    /// Canonical target resolved by exact or unique-prefix matching.
387    pub resolved_target: Option<String>,
388    /// Stable label describing how the target resolved.
389    pub resolved_from: Option<String>,
390    /// Selected canonical node rows.
391    pub nodes: Vec<IcNodeStatusRow>,
392}
393
394///
395/// IcSubnetStatusRow
396///
397/// Observed operational counts and conservative threshold evidence for one Subnet.
398///
399
400#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
401pub struct IcSubnetStatusRow {
402    /// Canonical Subnet principal.
403    pub subnet_id: String,
404    /// Operational-status totals for observed assigned nodes.
405    pub statuses: IcNodeStatusCounts,
406    /// Byzantine fault count `floor((n - 1) / 3)` for the observed membership size.
407    pub fault_tolerance_node_count: usize,
408    /// Additional down nodes required for the down count to exceed the derived threshold.
409    pub additional_down_nodes_to_exceed_fault_tolerance: usize,
410    /// Additional non-up nodes required for the conservative count to exceed the threshold.
411    pub additional_non_up_nodes_to_exceed_fault_tolerance: usize,
412    /// Whether the observed down count already exceeds the derived threshold.
413    pub down_fault_tolerance_exceeded: bool,
414    /// Whether the observed conservative non-up count already exceeds the threshold.
415    pub conservative_non_up_fault_tolerance_exceeded: bool,
416    /// Raw non-up node evidence in canonical node order.
417    pub non_up_nodes: Vec<IcNodeStatusRow>,
418}
419
420///
421/// IcSubnetStatusReport
422///
423/// Subnet-level operational view over one complete observed node snapshot.
424///
425
426#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
427pub struct IcSubnetStatusReport {
428    #[serde(flatten)]
429    /// Shared source, scope, and cache evidence.
430    pub observation: IcNodeStatusObservation,
431    /// Total rows in the complete source snapshot.
432    pub snapshot_node_count: usize,
433    /// Snapshot rows with an assigned Subnet.
434    pub assigned_node_count: usize,
435    /// Number of observed Subnets before view filtering.
436    pub subnet_count: usize,
437    /// Number of observed Subnets containing a non-up node.
438    pub attention_subnet_count: usize,
439    /// Whether fully-up Subnets are included without a target.
440    pub include_all: bool,
441    /// Target text supplied by the caller.
442    pub requested_target: Option<String>,
443    /// Canonical Subnet target resolved by exact or unique-prefix matching.
444    pub resolved_target: Option<String>,
445    /// Stable label describing how the target resolved.
446    pub resolved_from: Option<String>,
447    /// Canonically ordered selected Subnet rows.
448    pub subnets: Vec<IcSubnetStatusRow>,
449}
450
451///
452/// IcNodeProviderStatusRow
453///
454/// Assignment and raw operational counts for one observed node provider.
455///
456
457#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
458pub struct IcNodeProviderStatusRow {
459    /// Canonical node-provider principal.
460    pub node_provider_id: String,
461    /// Off-chain Dashboard provider name.
462    pub node_provider_name: String,
463    /// Operational-status and assignment totals for the provider.
464    pub counts: IcNodeStatusGroupCounts,
465    /// Unassigned up-node count compared with assigned up-node count.
466    pub unassigned_up_vs_assigned_up: IcNodeCountComparison,
467    /// Unassigned non-up-node count compared with assigned non-up-node count.
468    pub unassigned_non_up_vs_assigned_non_up: IcNodeCountComparison,
469    /// Raw non-up node evidence in canonical node order.
470    pub non_up_nodes: Vec<IcNodeStatusRow>,
471}
472
473///
474/// IcNodeProviderStatusReport
475///
476/// Node-provider operational view over one complete observed node snapshot.
477///
478
479#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
480pub struct IcNodeProviderStatusReport {
481    #[serde(flatten)]
482    /// Shared source, scope, and cache evidence.
483    pub observation: IcNodeStatusObservation,
484    /// Total rows in the complete source snapshot.
485    pub snapshot_node_count: usize,
486    /// Number of observed provider principals before view filtering.
487    pub provider_count: usize,
488    /// Number of provider groups containing a non-up node.
489    pub attention_provider_count: usize,
490    /// All-provider outcomes for unassigned up nodes compared with assigned up nodes.
491    pub unassigned_up_vs_assigned_up_provider_counts: IcNodeCountComparisonCounts,
492    /// All-provider outcomes for unassigned non-up nodes compared with assigned non-up nodes.
493    pub unassigned_non_up_vs_assigned_non_up_provider_counts: IcNodeCountComparisonCounts,
494    /// Whether fully-up providers are included without a target.
495    pub include_all: bool,
496    /// Target text supplied by the caller.
497    pub requested_target: Option<String>,
498    /// Canonical provider target resolved by exact or unique-prefix matching.
499    pub resolved_target: Option<String>,
500    /// Stable label describing how the target resolved.
501    pub resolved_from: Option<String>,
502    /// Canonically ordered selected provider rows.
503    pub providers: Vec<IcNodeProviderStatusRow>,
504}
505
506///
507/// IcNodeStatusProjectionError
508///
509/// Failure to resolve or project a requested observed status view.
510///
511
512#[derive(Clone, Debug, Eq, PartialEq, ThisError)]
513pub enum IcNodeStatusProjectionError {
514    /// Observation provenance, raw rows, canonical ordering, or counts are invalid.
515    #[error("invalid observed node-status snapshot: {reason}")]
516    InvalidSnapshot {
517        /// Deterministic validation failure.
518        reason: String,
519    },
520    /// The supplied target is empty after trimming.
521    #[error("{kind} target must not be empty")]
522    EmptyTarget {
523        /// Projection kind being selected.
524        kind: &'static str,
525    },
526    /// No observed identifier matches the supplied target.
527    #[error("{kind} target {target:?} did not match the observed snapshot")]
528    UnknownTarget {
529        /// Projection kind being selected.
530        kind: &'static str,
531        /// Unmatched target text.
532        target: String,
533    },
534    /// More than one observed identifier matches the supplied prefix.
535    #[error("{kind} prefix {prefix:?} is ambiguous; matches: {matches:?}")]
536    AmbiguousTarget {
537        /// Projection kind being selected.
538        kind: &'static str,
539        /// Ambiguous principal prefix.
540        prefix: String,
541        /// Canonically ordered matching principals.
542        matches: Vec<String>,
543    },
544}
545
546///
547/// IcNodeStatusCacheRequest
548///
549/// Stable identity of one network-level observed node-status cache.
550///
551
552#[cfg(feature = "dashboard-host")]
553#[derive(Clone, Debug, Eq, PartialEq)]
554pub struct IcNodeStatusCacheRequest {
555    /// Root directory containing all `ic-query` caches.
556    pub cache_root: PathBuf,
557    /// Requested network name.
558    pub network: String,
559}
560
561#[cfg(feature = "dashboard-host")]
562impl IcNodeStatusCacheRequest {
563    /// Construct one observed node-status cache identity.
564    #[must_use]
565    pub fn new(cache_root: impl Into<PathBuf>, network: impl Into<String>) -> Self {
566        Self {
567            cache_root: cache_root.into(),
568            network: network.into(),
569        }
570    }
571}
572
573///
574/// IcNodeStatusRefreshRequest
575///
576/// Settings for one forced observed node-status snapshot refresh.
577///
578
579#[cfg(feature = "dashboard-host")]
580#[derive(Clone, Debug, Eq, PartialEq)]
581pub struct IcNodeStatusRefreshRequest {
582    /// Stable cache identity.
583    pub cache: IcNodeStatusCacheRequest,
584    /// Explicit Dashboard API base endpoint.
585    pub source_endpoint: String,
586    /// Caller-supplied observation time as Unix seconds.
587    pub now_unix_secs: u64,
588}
589
590#[cfg(feature = "dashboard-host")]
591impl IcNodeStatusRefreshRequest {
592    /// Construct one forced node-status snapshot refresh request.
593    #[must_use]
594    pub fn new(
595        cache_root: impl Into<PathBuf>,
596        network: impl Into<String>,
597        source_endpoint: impl Into<String>,
598        now_unix_secs: u64,
599    ) -> Self {
600        Self {
601            cache: IcNodeStatusCacheRequest::new(cache_root, network),
602            source_endpoint: source_endpoint.into(),
603            now_unix_secs,
604        }
605    }
606}
607
608///
609/// IcNodeStatusReadRequest
610///
611/// Cache-backed status-view request shared by node, Subnet, and provider reports.
612///
613
614#[cfg(feature = "dashboard-host")]
615#[derive(Clone, Debug, Eq, PartialEq)]
616pub struct IcNodeStatusReadRequest {
617    /// Live and cache settings used when refresh is required.
618    pub refresh: IcNodeStatusRefreshRequest,
619    /// Projection target and attention selection.
620    pub view: IcNodeStatusView,
621    /// Whether to force a live replacement before reading.
622    pub force_refresh: bool,
623}
624
625#[cfg(feature = "dashboard-host")]
626impl IcNodeStatusReadRequest {
627    /// Construct one stale-refresh status-view request.
628    #[must_use]
629    pub fn new(
630        cache_root: impl Into<PathBuf>,
631        network: impl Into<String>,
632        source_endpoint: impl Into<String>,
633        now_unix_secs: u64,
634    ) -> Self {
635        Self {
636            refresh: IcNodeStatusRefreshRequest::new(
637                cache_root,
638                network,
639                source_endpoint,
640                now_unix_secs,
641            ),
642            view: IcNodeStatusView::attention(),
643            force_refresh: false,
644        }
645    }
646}
647
648///
649/// IcNodeStatusRefreshReport
650///
651/// Result of atomically replacing the complete observed node-status cache.
652///
653
654#[cfg(feature = "dashboard-host")]
655#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
656pub struct IcNodeStatusRefreshReport {
657    /// Cache/report schema version.
658    pub schema_version: u32,
659    /// Network identity attached to the replacement.
660    pub network: String,
661    /// Explicit Dashboard endpoint queried.
662    pub source_endpoint: String,
663    /// Canonical UTC collection timestamp.
664    pub fetched_at: String,
665    /// Collector identity.
666    pub fetched_by: String,
667    /// Published cache path.
668    pub cache_path: String,
669    /// Sibling refresh-lock path.
670    pub refresh_lock_path: String,
671    /// Whether an existing complete snapshot was replaced.
672    pub replaced_existing_cache: bool,
673    /// Number of published node rows.
674    pub node_count: usize,
675    /// Published overall and assignment-partitioned status totals.
676    pub counts: IcNodeStatusGroupCounts,
677}
678
679///
680/// IcNodeStatusHostError
681///
682/// Host source, cache, and projection failures for observed node-status reports.
683///
684
685#[cfg(feature = "dashboard-host")]
686#[derive(Debug, ThisError)]
687pub enum IcNodeStatusHostError {
688    /// The observed Dashboard source supports only public mainnet identity.
689    #[error("observed IC node status supports only the mainnet `ic` network, not {network:?}")]
690    UnsupportedNetwork {
691        /// Unsupported requested network.
692        network: String,
693    },
694    /// Live-source or source-validation failure.
695    #[error(transparent)]
696    Source(#[from] crate::ic::IcHostError),
697    /// Pure projection failure.
698    #[error(transparent)]
699    Projection(#[from] IcNodeStatusProjectionError),
700    /// Strict cache load found no complete snapshot.
701    #[error("observed node-status cache is missing at {}", path.display())]
702    MissingCache {
703        /// Expected cache path.
704        path: PathBuf,
705    },
706    /// Existing cache snapshot-key identity does not match its path.
707    #[error(
708        "observed node-status cache identity mismatch at {}: {field} is {actual:?}, expected {expected:?}",
709        path.display()
710    )]
711    CacheIdentityMismatch {
712        /// Cache path that failed validation.
713        path: PathBuf,
714        /// Identity field that differs.
715        field: &'static str,
716        /// Required identity value.
717        expected: String,
718        /// Stored identity value.
719        actual: String,
720    },
721    /// Existing cache is structurally readable but semantically invalid.
722    #[error("invalid observed node-status cache at {}: {reason}", path.display())]
723    InvalidCache {
724        /// Cache path that failed validation.
725        path: PathBuf,
726        /// Deterministic validation failure.
727        reason: String,
728    },
729    /// Shared generic JSON, filesystem, or refresh-lock cache failure.
730    #[error(transparent)]
731    Cache(#[from] crate::cache_file::HostCacheError),
732}