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;
30mod store_io;
31#[cfg(unix)]
32pub mod tee;
33#[cfg(feature = "vm")]
34pub mod vm;
35#[cfg(feature = "vm")]
36pub mod vmm;
37pub mod volume;
38
39// -- Optional modules (feature-gated) --
40#[cfg(feature = "compose")]
41pub mod compose;
42#[cfg(feature = "operator")]
43pub mod operator;
44#[cfg(feature = "pool")]
45pub mod pool;
46#[cfg(feature = "scale")]
47pub mod scale;
48
49// ── Core re-exports (used by CLI, CRI, SDK, shim) ──
50
51// Audit
52pub use audit::{read_audit_log, AuditLog, AuditQuery};
53
54// gRPC clients
55#[cfg(unix)]
56pub use grpc::{
57    AttestationClient, ExecClient, PtyClient, RaTlsAttestationClient, StreamingExec,
58    StreamingExecInput, StreamingPty, StreamingPtyInput,
59};
60#[cfg(unix)]
61pub use grpc::{SealClient, SecretEntry, SecretInjector};
62
63// Host checks
64pub use host_check::check_virtualization_support;
65
66// Network
67pub use network::NetworkStore;
68
69// OCI images
70pub use a3s_box_core::StoredImage;
71pub use oci::{CredentialStore, PushResult, RegistryPusher};
72pub use oci::{ImagePuller, ImageReference, ImageStore, RegistryAuth};
73pub use oci::{OciImage, SignResult, SignaturePolicy};
74
75// Metrics
76pub use prom::RuntimeMetrics;
77
78// Snapshot
79pub use snapshot::SnapshotStore;
80
81// TEE
82#[cfg(unix)]
83pub use tee::{seal, unseal};
84#[cfg(unix)]
85pub use tee::{
86    verify_attestation, verify_attestation_with_time, AmdKdsClient, AttestationPolicy,
87    MinTcbPolicy, PolicyResult, VerificationResult,
88};
89#[cfg(unix)]
90pub use tee::{AttestationReport, AttestationRequest, PlatformInfo};
91
92// VM
93#[cfg(feature = "vm")]
94pub use vm::{BoxState, VmManager};
95#[cfg(feature = "vm")]
96pub use vmm::{
97    Entrypoint, FsMount, InstanceSpec, NetworkInstanceConfig, ShimHandler, TeeInstanceConfig,
98    VmController, VmHandler, VmMetrics, VmmProvider,
99};
100
101// Resize
102pub use resize::{validate_update, ResizeResult, ResourceUpdate};
103
104// Volume
105pub use volume::VolumeStore;
106
107// ── Feature-gated re-exports ──
108
109#[cfg(feature = "build")]
110pub use oci::{BuildConfig, Dockerfile, Instruction};
111
112#[cfg(feature = "compose")]
113pub use compose::{ComposeProject, HealthCheckSpec};
114
115#[cfg(feature = "operator")]
116pub use operator::AutoscalerController;
117
118#[cfg(feature = "pool")]
119pub use pool::WarmPool;
120
121#[cfg(feature = "scale")]
122pub use scale::ScaleManager;
123
124// ── Constants ──
125
126/// A3S Box Runtime version.
127pub const VERSION: &str = env!("CARGO_PKG_VERSION");
128
129pub use a3s_box_core::{ATTEST_VSOCK_PORT, EXEC_VSOCK_PORT, PORT_FWD_VSOCK_PORT, PTY_VSOCK_PORT};
130
131/// Default maximum image cache size: 10 GB.
132pub const DEFAULT_IMAGE_CACHE_SIZE: u64 = 10 * 1024 * 1024 * 1024;