Skip to main content

clawft_kernel/node_facts/
mod.rs

1//! Node facts probing, local advertisement and the facts TTL cache
2//! (ADR-099 section 2, card mesh-placement-03).
3//!
4//! - [`host`]: the [`ProbeHost`] seam (real [`SystemHost`], fakes in tests).
5//! - [`probe`]: orchestration, shared helpers, [`ProbeConfig`].
6//! - `macos` / `linux`: OS probes (CPU, OS, memory, storage, Metal, ANE,
7//!   board class, binfmt emulation).
8//! - `runtimes`: native, Docker/OrbStack, Podman, Apple container,
9//!   llama-server, mlx_lm, ollama.
10//! - `accel`: vendor accelerators, only when their tool or device exists
11//!   (nvidia-smi, hailortcli, Coral `/dev/apex_*` or USB id).
12//! - [`measured`]: `perf.*` results from the conformance harness.
13//! - [`cache`]: the verified-facts TTL cache held by `ClusterMembership`.
14//!
15//! The data type ([`clawft_types::placement::NodeFacts`]) lives in
16//! clawft-types; signing lives in [`crate::node_facts_advert`], beside the
17//! coarse `SignedCapabilityAdvertisement`.
18
19mod accel;
20pub mod host;
21pub mod linux;
22pub mod macos;
23pub mod measured;
24pub mod probe;
25pub mod runtimes;
26
27#[cfg(any(feature = "mesh", feature = "exochain"))]
28pub mod cache;
29
30#[cfg(test)]
31mod fake_host;
32#[cfg(test)]
33mod tests_linux;
34#[cfg(test)]
35mod tests_mac;
36
37pub use host::{ProbeHost, SystemHost};
38pub use probe::{
39    Collected, DEFAULT_FACTS_TTL_SECS, EmulationCache, ProbeConfig, build_facts, probe_capabilities,
40    refresh_live, valid_image_ref,
41};
42
43#[cfg(any(feature = "mesh", feature = "exochain"))]
44pub use cache::{CacheError, CachedNodeFacts, InsertOutcome, NodeFactsCache, TierSource};
45
46/// Probe `host`, build facts for the node owning `key`, and sign them.
47#[cfg(any(feature = "mesh", feature = "exochain"))]
48pub fn probe_and_sign(
49    host: &dyn ProbeHost,
50    cfg: &ProbeConfig,
51    key: &ed25519_dalek::SigningKey,
52    now: u64,
53    seq: u64,
54    ttl_secs: u64,
55) -> Result<crate::node_facts_advert::SignedNodeFacts, crate::node_facts_advert::NodeFactsAdvertError>
56{
57    let node_id = crate::node_registry::node_id_from_pubkey(&key.verifying_key().to_bytes());
58    let facts = build_facts(&node_id, now, ttl_secs, seq, probe_capabilities(host, cfg));
59    crate::node_facts_advert::sign_node_facts(&facts, key)
60}