feat(runtime): add resident Wasmtime actor runtime

- define versioned service and clock WIT contracts\n- enforce import allowlists, fuel, epoch, memory, I/O, and mailbox limits\n- keep one Store and Component Instance resident per serial Actor\n- add echo, counter, fault, spin, and capability probe components\n- cover lifecycle, concurrency, sandbox, and fault recovery behavior
This commit is contained in:
Maofeng
2026-07-27 04:59:33 +08:00
parent 892fc96f71
commit b63cf8c9eb
41 changed files with 3240 additions and 18 deletions
+81
View File
@@ -0,0 +1,81 @@
//! Runtime error taxonomy exposed to management layers.
use std::time::Duration;
use thiserror::Error;
use crate::manifest::ServiceKey;
/// Failures from Runtime configuration, sandbox validation, or Actor execution.
#[derive(Debug, Error)]
pub enum RuntimeError {
#[error("service id and revision must not be empty")]
InvalidServiceKey,
#[error("invalid manifest: {0}")]
InvalidManifest(String),
#[error("manifest parse failed: {0}")]
ManifestParse(#[from] toml::de::Error),
#[error("service revision {0} is not registered")]
ServiceNotRegistered(ServiceKey),
#[error("service revision {0} is already registered")]
ServiceAlreadyRegistered(ServiceKey),
#[error("component compilation failed: {0}")]
ComponentCompilation(#[source] wasmtime::Error),
#[error("component imports unsupported capability {0}")]
UnsupportedImport(String),
#[error("runtime creation failed: {0}")]
RuntimeCreation(#[source] wasmtime::Error),
#[error("failed to read component artifact {path}: {source}")]
ArtifactRead {
path: String,
#[source]
source: std::io::Error,
},
#[error("failed to spawn actor thread: {0}")]
ActorThread(#[source] std::io::Error),
#[error("actor initialization failed: {0}")]
ActorInitialization(String),
#[error("actor for {0} is unavailable")]
ActorUnavailable(ServiceKey),
#[error("actor mailbox for {0} is full")]
ActorOverloaded(ServiceKey),
#[error("actor for {0} stopped before returning a result")]
ActorStopped(ServiceKey),
#[error("input for {service} exceeds the {limit}-byte limit")]
InputTooLarge { service: ServiceKey, limit: usize },
#[error("output for {service} exceeds the {limit}-byte limit")]
OutputTooLarge { service: ServiceKey, limit: usize },
#[error("actor for {service} exceeded its {deadline:?} execution deadline")]
DeadlineExceeded {
service: ServiceKey,
deadline: Duration,
},
#[error("actor for {service} faulted: {message}")]
ActorFault {
service: ServiceKey,
message: String,
},
#[error("component returned {kind}: {message}")]
ComponentError { kind: &'static str, message: String },
#[error("runtime lock was poisoned")]
LockPoisoned,
}