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//! stale `.lock` files). Files Windows refuses to delete because a library is loaded are listed
33//! under [`RemovalReport::skipped`].
34//!
35//! # Verified stamp
36//!
37//! [`ComponentManager::with_verified_stamp`] (off by default) skips re-hashing an installed
38//! library when a stamp recorded after a full check still matches the file's size, mtime and, on
39//! Unix, device, inode and ctime. See [`ArtifactCache::with_verified_stamp`] for what this does
40//! and does not protect against.
41
42mod cache;
43mod download;
44mod error;
45mod host_services;
46mod keys;
47mod loader;
48mod maintenance;
49mod manager;
50mod manifest;
51mod stamp;
52pub mod target;
53
54pub use cache::{ArtifactCache, CachedArtifact, TrustPolicy};
55pub use download::{DownloadOptions, ProgressCallback, RootCerts};
56pub use error::ComponentError;
57pub use host_services::HostServices;
58pub use keys::decode_public_key;
59pub use loader::{
60 ComponentInstance, ComponentRequirements, LoadedComponent, Runtime, take_owned_bytes, take_owned_text,
61};
62pub use maintenance::{CachedObject, RemovalReport, Retain, SkippedRemoval};
63pub use manager::{ComponentManager, ComponentStatus};
64pub use manifest::{
65 COMPONENT_ABI_VERSION, COMPONENT_MANIFEST_SCHEMA, ComponentArtifactRecord, ComponentDeliveryMode,
66 ComponentIdentity, ComponentLibrary, ComponentLock, ComponentLockEntry, ComponentManifest,
67 ComponentProvidedContract, ComponentSignature, canonical_json,
68};
69
70pub use ed25519_dalek::VerifyingKey;