Execution Manifest
Reference for lema.exec-source/v2, lema.exec/v2, VM resource limits, and static VM guarantee profiles.
An execution manifest defines how a verified Lema declaration is compiled to LemaIR, checked against static VM guarantee profiles, and executed by lema-vm-runner (crates/lema-http/src/vm_exec.rs, crates/lema-cli/src/exec_records.rs).
Lema v0.2 uses two paired schemas:
lema.exec-source/v2: The human-authored manifest checked into a repository (for example inapps/collector-vm.jsonor synthesized bylema.json), referencing declarations by symbolic alias name.lema.exec/v2: The immutable, content-addressed store record (hashed with prefixLEMA-EXEC-v1\0) produced whenlema exec importresolves every alias inlema.exec-source/v2to a 64-hexlema.core/v4object ID.
lema.exec-source/v2 and lema.exec/v2 schema
{
"doc": "HTTPS-to-S3 observation collector over BlockStore and SecretExchange",
"entry": {
"families": [
"block",
"clock",
"exchange"
],
"kind": "app",
"root": "Lema.Cap.Collector.Fixture.app"
},
"guarantees": [
"NoCopySliceCall",
"NoBigIntPrimitives",
"ConstantTime",
"SecretFlow.SigV4",
"SecretFlow.BearerHeader"
],
"limits": {
"allocation_bytes": 67108864,
"bigint_bits": 4096,
"call_depth": 1024,
"steps": 100000000
},
"roots": [
"Lema.Cap.Collector.Fixture.app"
],
"schema": "lema.exec-source/v2",
"seconds": 60
}When imported into the store via lema exec import, the store verifies that every alias in entry.root and roots resolves to an accepted lema.core/v4 declaration, replaces the alias strings with their 64-hex object IDs, sets "schema": "lema.exec/v2", and hashes the canonical JSON under LEMA-EXEC-v1\0.
Top-level fields
| Field | Type | Required | Description |
|---|---|---|---|
schema | "lema.exec-source/v2" or "lema.exec/v2" | Yes | Schema version identifier. |
doc | String (1..=512 chars) | Yes | Human-readable summary of the executable’s purpose. |
entry | Object | Yes | Entrypoint descriptor (kind, root, families). |
roots | Array of strings / IDs | Yes | Root declarations to include in the LemaIR compilation closure (must contain entry.root). |
guarantees | Array of strings | Optional | Static VM guarantee profiles required before the artifact can be built or released. |
limits | Object | Yes | Per-invocation VM execution budgets (steps, allocation_bytes, bigint_bits, call_depth). |
seconds | Integer (1..=600) | Yes | Wall-clock timeout in seconds for a single VM run. |
Entrypoint signature and capability families
entry.kind: "app"
An application entrypoint ("kind": "app") must elaborate to a declaration with the canonical runner type signature:
Nat -> ByteArray -> Prog (AppCmd families) AppResult ByteArraywhere:
- The
Natparameter receives the run’s fuel or epoch argument from the host runner. - The
ByteArrayparameter receives the initial request or configuration payload bytes. - The return value is an interaction tree
Progover the declaredfamiliesproducing a finalByteArrayoutput.
For pure batch computation and test runners, lema test and vm.test also support pure ByteArray -> ByteArray roots and lema.exec-source/v1 "vectors" descriptors (such as apps/sha256-vectors.json and apps/sha256-unboxed-vectors.json).
Canonical entry.families ordering
The entry.families array must be a non-empty, strictly duplicate-free subset of the 11 runner families listed in exact canonical order:
| Order | Family name | Kind | Description |
|---|---|---|---|
| 1 | "tasks" | Concurrency | Structured parallel task groups (Parallel.Par). |
| 2 | "actors" | Concurrency | Stateful message-passing actors (Actor / ActorJournal). |
| 3 | "sessions" | Concurrency | Binary session-typed channels (Sessions). |
| 4 | "tcp" | Layer 1 (0x01) | Raw TCP client connections and server listeners. |
| 5 | "udp" | Layer 1 (0x02) | Connected UDP datagram sockets. |
| 6 | "block" | Layer 1 (0x03) | Fixed-size 4096-byte sector storage devices (BlockStore). |
| 7 | "random" | Layer 1 (0x04) | OS CSPRNG entropy (1..=4096 bytes per read). |
| 8 | "clock" | Layer 1 (0x05) | Monotonic, realtime, and bounded timer operations. |
| 9 | "secret" | Layer 1 (0x06) | Direct handle-indexed secret access (requires a matching SecretFlow.* guarantee). |
| 10 | "exchange" | Composite sub-run | Pinned TLS 1.3 + HTTP/1.1 + SecretPolicy client sub-run (SecretExchange). |
| 11 | "serve" | Composite sub-run | Verified TLS 1.3 + HTTP/1.1 + SecretPolicy server sub-run (ServeVerified). |
Any manifest that lists families out of canonical order or repeats a family name is rejected during lema exec import.
Resource limits (limits)
Every VM execution enforces deterministic resource accounting inside crates/lema-vm in addition to the host sandbox limits:
| Field | Minimum | Maximum | Enforced by |
|---|---|---|---|
steps | 1 | 1,099,511,627,775 (2^40 - 1) | Register VM instruction counter per invocation. |
allocation_bytes | 1,024 | 1,073,741,824 (1 GiB) | Cumulative VM heap allocation counter across the run. |
bigint_bits | 64 | 1,048,576 bits | Maximum bit width of any arbitrary-precision Nat or Int value allocated on the VM heap. |
call_depth | 16 | 8,192 frames | Maximum LemaIR call stack depth. |
seconds | 1 | 600 seconds | Host wall-clock watchdog timer in lema-vm-runner. |
If an invocation exceeds any limit, the VM halts deterministically and returns a structured resource-exhausted error without corrupting store or block state.
Static VM guarantee profiles (guarantees)
The guarantees array names static analysis passes in crates/lema-vm-runner/src/guarantee/mod.rs that inspect the compiled LemaIR call graph before a lema.vm-app/v1 artifact can be emitted. When all listed profiles pass, the store records a lema.vm-guarantee/v1 receipt (LEMA-GUARANTEE-v1\0).
| Profile name | What the analyser proves over compiled LemaIR |
|---|---|
NoCopySliceCall | Byte-slice arguments (Std.Bytes.ByteSlice) are passed across call boundaries by reference/offset without allocating intermediate ByteArray copies. |
NoBigIntPrimitives | No reachable basic block invokes arbitrary-precision Nat or Int heap primitives; all arithmetic stays in unboxed machine registers (UInt8..UInt64, Int64). |
NoBoxOrCtorInCycles | Every loop cycle in the LemaIR control-flow graph is allocation-free (no heap boxing or constructor allocation inside loop bodies). |
FlatMessage | Every value sent across an actor mailbox (actors) or session channel (sessions) has a flat, closure-free representation that can be copied without sharing mutable heap pointers. |
ExclusiveActorLoop | Every actor’s state loop processes one message to completion before reading the next mailbox message, matching the sequential Actor.Step model. |
ConstantTime | Functions marked as secret-bearing execute with secret-independent control flow (no branches or jump targets derived from secret registers), secret-independent memory indices, and no variable-time division Instructions (LEMA-355). |
SecretFlow.SigV4 | Secret bytes obtained from secret (0x06) flow exclusively into SecretPolicy.deriveSigV4SigningKey and signSigV4Request; raw secret bytes never escape into return values, logs, or outbound network buffers (LEMA-384). |
SecretFlow.SigV4VerifyServer | Inbound server secret bytes flow exclusively into SecretPolicy.verifyInboundSigV4Request and constant-time tag comparison (ctEq32). |
SecretFlow.BearerHeader | Secret bytes flow exclusively into SecretPolicy.formatBearerHeader for a TLS-pinned origin. |
SecretFlow.X25519Static | Static 32-byte X25519 secret keys flow exclusively into X25519.dh / Noise static key agreement without leaking the clamped scalar. |
SecretFlow.Ed25519Sign | 32-byte Ed25519 secret seeds flow exclusively into Ed25519.sign and Ed25519.publicKey. |
Artifact packaging (lema.vm-app/v1) and reference manifests
Running lema build or lema release compiles the lema.exec/v2 closure into a self-contained lema.vm-app/v1 JSON artifact containing:
- The resolved
lema.exec/v2record and itslema.vm-guarantee/v1receipt IDs. - The canonical
lema.ir/v1bytecode module for all reachable declarations. - The artifact’s SHA-256 digest, registered under
<output>/vm-workers/<sha256>.jsonfor execution bylema-vm-runner.
The Lema repository includes reference manifests under apps/:
| File | Schema | Entrypoint and families |
|---|---|---|
apps/collector-vm.json | lema.exec-source/v2 | Lema.Cap.Collector.Fixture.app over ["block", "clock", "exchange"]. |
apps/escrow-ledger-vm.json | lema.exec-source/v2 | Two-shard escrow coordinator and ledger (Lema.EscrowLedger.app) over ["block", "clock", "exchange"]. |
apps/stream-hub-vm.json | lema.exec-source/v2 | Lema.Cap.StreamHubApp.table over ["actors", "clock", "stream"]. |
apps/sha256-vectors.json | lema.exec-source/v1 | Pure FIPS 180-4 SHA-256 test vector suite (Lema.Std.Sha256Spec.digest). |
apps/sha256-unboxed-vectors.json | lema.exec-source/v1 | Unboxed ByteSlice SHA-256 test vector suite (Lema.Std.Sha256Unboxed.digestSlice). |
Lema v0.3.2 · Updated 29 October 2026 · Version and compatibility