Skip to main content

a3s_box_runtime/
lib.rs

1//! A3S Box Runtime - MicroVM runtime implementation.
2//!
3//! This module provides the actual runtime implementation for A3S Box,
4//! including VM management, OCI image handling, rootfs building, and gRPC health checks.
5//!
6//! # Feature Flags
7//!
8//! - `pool` — Warm VM pool with autoscaling (enabled by default)
9//! - `scale` — Multi-node scale manager and instance registry (enabled by default)
10//! - `compose` — Multi-container compose orchestration (enabled by default)
11//! - `operator` — Kubernetes CRD autoscaler controller (enabled by default)
12//! - `build` — Dockerfile/Containerfile build engine (enabled by default)
13
14#![allow(clippy::result_large_err)]
15
16// -- Core modules (always compiled) --
17pub mod audit;
18pub mod cache;
19pub(crate) mod file_lock;
20pub mod fs;
21pub mod grpc;
22pub mod host_check;
23pub mod log;
24pub mod network;
25pub mod oci;
26pub mod prom;
27pub mod resize;
28pub mod rootfs;
29pub mod snapshot;
30#[cfg(unix)]
31pub mod tee;
32#[cfg(feature = "vm")]
33pub mod vm;
34#[cfg(feature = "vm")]
35pub mod vmm;
36pub mod volume;
37
38// -- Optional modules (feature-gated) --
39#[cfg(feature = "compose")]
40pub mod compose;
41#[cfg(feature = "operator")]
42pub mod operator;
43#[cfg(feature = "pool")]
44pub mod pool;
45#[cfg(feature = "scale")]
46pub mod scale;
47
48// ── Core re-exports (used by CLI, CRI, SDK, shim) ──
49
50// Audit
51pub use audit::{read_audit_log, AuditLog, AuditQuery};
52
53// gRPC clients
54#[cfg(unix)]
55pub use grpc::{
56    AttestationClient, ExecClient, PtyClient, RaTlsAttestationClient, StreamingExec,
57    StreamingExecInput, StreamingPty, StreamingPtyInput,
58};
59#[cfg(unix)]
60pub use grpc::{SealClient, SecretEntry, SecretInjector};
61
62// Host checks
63pub use host_check::check_virtualization_support;
64
65// Network
66pub use network::NetworkStore;
67
68// OCI images
69pub use a3s_box_core::StoredImage;
70pub use oci::{CredentialStore, PushResult, RegistryPusher};
71pub use oci::{ImagePuller, ImageReference, ImageStore, RegistryAuth};
72pub use oci::{OciImage, SignResult, SignaturePolicy};
73
74// Metrics
75pub use prom::RuntimeMetrics;
76
77// Snapshot
78pub use snapshot::SnapshotStore;
79
80// TEE
81#[cfg(unix)]
82pub use tee::{seal, unseal};
83#[cfg(unix)]
84pub use tee::{
85    verify_attestation, verify_attestation_with_time, AmdKdsClient, AttestationPolicy,
86    MinTcbPolicy, PolicyResult, VerificationResult,
87};
88#[cfg(unix)]
89pub use tee::{AttestationReport, AttestationRequest, PlatformInfo};
90
91// VM
92#[cfg(feature = "vm")]
93pub use vm::{BoxState, VmManager};
94#[cfg(feature = "vm")]
95pub use vmm::{
96    Entrypoint, FsMount, InstanceSpec, NetworkInstanceConfig, ShimHandler, TeeInstanceConfig,
97    VmController, VmHandler, VmMetrics, VmmProvider,
98};
99
100// Resize
101pub use resize::{validate_update, ResizeResult, ResourceUpdate};
102
103// Volume
104pub use volume::VolumeStore;
105
106// ── Feature-gated re-exports ──
107
108#[cfg(feature = "build")]
109pub use oci::{BuildConfig, Dockerfile, Instruction};
110
111#[cfg(feature = "compose")]
112pub use compose::{ComposeProject, HealthCheckSpec};
113
114#[cfg(feature = "operator")]
115pub use operator::AutoscalerController;
116
117#[cfg(feature = "pool")]
118pub use pool::WarmPool;
119
120#[cfg(feature = "scale")]
121pub use scale::ScaleManager;
122
123// ── Constants ──
124
125/// A3S Box Runtime version.
126pub const VERSION: &str = env!("CARGO_PKG_VERSION");
127
128pub use a3s_box_core::{ATTEST_VSOCK_PORT, EXEC_VSOCK_PORT, PORT_FWD_VSOCK_PORT, PTY_VSOCK_PORT};
129
130/// Default maximum image cache size: 10 GB.
131pub const DEFAULT_IMAGE_CACHE_SIZE: u64 = 10 * 1024 * 1024 * 1024;