alef_component_runtime/lib.rs
1//! Verified artifact installation and dynamic loading for Alef native components.
2//!
3//! # Downloads
4//!
5//! [`DownloadOptions`] tunes timeouts, retries (transient errors only), progress reporting and
6//! cancellation; pass it to [`ComponentManager::with_download_options`] or
7//! [`ArtifactCache::with_download_options`]. The defaults match the historical 10 s connect and
8//! 300 s total timeouts.
9//!
10//! # Root certificates
11//!
12//! Downloads trust the compiled-in Mozilla roots ([`RootCerts::WebPki`]). Behind a TLS-inspecting
13//! proxy, enable this crate's `platform-verifier` feature and select
14//! [`RootCerts::PlatformVerifier`] with [`DownloadOptions::with_root_certs`] to use the operating
15//! system trust store. Requesting it without the feature fails the download with a clear error.
16//!
17//! # Mirrors
18//!
19//! A lock entry's `url` is fixed when the lock is generated. Air-gapped and corporate hosts can
20//! redirect downloads at runtime with [`ComponentManager::with_url_override`] (any
21//! `Fn(&ComponentLockEntry) -> String`) or [`ComponentManager::with_mirror_base`] (serve every
22//! archive as `{base}/{archive file name}`). Integrity does not depend on the URL: the archive
23//! size and SHA-256 and the manifest signature are checked against the lock regardless of where
24//! the bytes came from, so a mirror cannot substitute content.
25//!
26//! # Cache maintenance
27//!
28//! [`ComponentManager::list_cached`], [`ComponentManager::remove`] and
29//! [`ComponentManager::prune`] (with [`Retain`]) manage the shared on-disk cache. Loading an
30//! object touches a last-used stamp so several host versions can share one cache and prune by
31//! recency. Prune also sweeps crash leftovers (`.install-*` staging dirs, orphaned temp files and
32//! stamps). Removal holds the object's install lock, so an object another thread or process is
33//! installing is skipped by prune and waited for by remove; the empty per-digest `.lock` files are
34//! never deleted. Files Windows refuses to delete because a library is loaded are listed under
35//! [`RemovalReport::skipped`].
36//!
37//! # Verified stamp
38//!
39//! [`ComponentManager::with_verified_stamp`] (off by default) skips re-hashing an installed
40//! library when a stamp recorded after a full check still matches the file's size, mtime and, on
41//! Unix, device, inode and ctime. See [`ArtifactCache::with_verified_stamp`] for what this does
42//! and does not protect against. The stamp is ignored in a cache that other users can write.
43
44mod cache;
45mod download;
46mod error;
47mod host_services;
48mod identity;
49mod keys;
50mod loader;
51mod maintenance;
52mod manager;
53mod manifest;
54mod proxy_support;
55mod stamp;
56pub mod stdio;
57pub mod target;
58
59pub use cache::{ArtifactCache, CachedArtifact, SignaturePolicy, TrustPolicy};
60pub use download::{DownloadOptions, ProgressCallback, RootCerts};
61pub use error::ComponentError;
62pub use host_services::HostServices;
63pub use keys::decode_public_key;
64pub use loader::{ComponentInstance, ComponentRequirements, LoadedComponent, take_owned_bytes, take_owned_text};
65pub use maintenance::{CachedObject, RemovalReport, Retain, SkippedRemoval};
66pub use manager::{ComponentManager, ComponentStatus};
67pub use manifest::{
68 COMPONENT_ABI_VERSION, COMPONENT_MANIFEST_SCHEMA, ComponentArtifactRecord, ComponentDeliveryMode,
69 ComponentIdentity, ComponentLibrary, ComponentLock, ComponentLockEntry, ComponentManifest,
70 ComponentProvidedContract, ComponentSignature, canonical_json,
71};
72pub use proxy_support::{InfallibleCallFailure, report_infallible_failure, set_infallible_failure_hook};
73pub use stdio::{SidecarRestartEvent, SidecarSession, SidecarSessionSetup};
74
75pub use ed25519_dalek::VerifyingKey;