feat(runtime): add resident Wasmtime actor runtime

- define versioned service and clock WIT contracts
- enforce import allowlists, fuel, epoch, memory, I/O, and mailbox limits
- keep one Store and Component Instance resident per serial Actor
- add echo, counter, fault, spin, and capability probe components
- cover lifecycle, concurrency, sandbox, and fault recovery behavior
This commit is contained in:
Maofeng
2026-07-27 04:59:33 +08:00
parent 893895a76c
commit cfac7d85f0
41 changed files with 3240 additions and 18 deletions
+16
View File
@@ -0,0 +1,16 @@
[package]
name = "counter-component"
version = "0.1.0"
edition.workspace = true
rust-version.workspace = true
license.workspace = true
[package.metadata.wasmeld]
id = "counter"
world = "component:counter/counter-component@0.1.0"
[lib]
crate-type = ["cdylib"]
[dependencies]
wit-bindgen.workspace = true
+28
View File
@@ -0,0 +1,28 @@
use core::sync::atomic::{AtomicU64, Ordering};
mod bindings {
wit_bindgen::generate!({
path: "wit",
world: "counter-component",
});
}
static COUNTER: AtomicU64 = AtomicU64::new(0);
struct Counter;
impl bindings::Guest for Counter {
fn init(_config: Vec<u8>) -> Result<(), bindings::ServiceError> {
// Calls are serialized by the host Actor, so this component intentionally
// uses one mutable global to make resident memory observable in tests.
COUNTER.store(0, Ordering::Relaxed);
Ok(())
}
fn invoke(_input: Vec<u8>) -> Result<Vec<u8>, bindings::ServiceError> {
let next = COUNTER.fetch_add(1, Ordering::Relaxed).wrapping_add(1);
Ok(next.to_le_bytes().to_vec())
}
}
bindings::export!(Counter with_types_in bindings);
+7
View File
@@ -0,0 +1,7 @@
schema_version = 1
[dependencies]
"wasmeld:service" = "0.1.0"
[replace."wasmeld:service"]
path = "../../wit/service"
+8
View File
@@ -0,0 +1,8 @@
schema_version = 1
[[package]]
name = "wasmeld:service"
version = "0.1.0"
source = "path+../../wit/service"
sha256 = "d5497307bbcd1e159f7707f385b488a6f2e26362d5256d5bc1080ac603a51305"
replaced = true
+5
View File
@@ -0,0 +1,5 @@
package component:counter@0.1.0;
world counter-component {
include wasmeld:service/service-component@0.1.0;
}