Skip to content

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 in apps/collector-vm.json or synthesized by lema.json), referencing declarations by symbolic alias name.
  • lema.exec/v2: The immutable, content-addressed store record (hashed with prefix LEMA-EXEC-v1\0) produced when lema exec import resolves every alias in lema.exec-source/v2 to a 64-hex lema.core/v4 object ID.

lema.exec-source/v2 and lema.exec/v2 schema

JSON
{
  "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

FieldTypeRequiredDescription
schema"lema.exec-source/v2" or "lema.exec/v2"YesSchema version identifier.
docString (1..=512 chars)YesHuman-readable summary of the executable’s purpose.
entryObjectYesEntrypoint descriptor (kind, root, families).
rootsArray of strings / IDsYesRoot declarations to include in the LemaIR compilation closure (must contain entry.root).
guaranteesArray of stringsOptionalStatic VM guarantee profiles required before the artifact can be built or released.
limitsObjectYesPer-invocation VM execution budgets (steps, allocation_bytes, bigint_bits, call_depth).
secondsInteger (1..=600)YesWall-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:

Lean
Nat -> ByteArray -> Prog (AppCmd families) AppResult ByteArray

where:

  • The Nat parameter receives the run’s fuel or epoch argument from the host runner.
  • The ByteArray parameter receives the initial request or configuration payload bytes.
  • The return value is an interaction tree Prog over the declared families producing a final ByteArray output.

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:

OrderFamily nameKindDescription
1"tasks"ConcurrencyStructured parallel task groups (Parallel.Par).
2"actors"ConcurrencyStateful message-passing actors (Actor / ActorJournal).
3"sessions"ConcurrencyBinary 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-runPinned TLS 1.3 + HTTP/1.1 + SecretPolicy client sub-run (SecretExchange).
11"serve"Composite sub-runVerified 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:

FieldMinimumMaximumEnforced by
steps11,099,511,627,775 (2^40 - 1)Register VM instruction counter per invocation.
allocation_bytes1,0241,073,741,824 (1 GiB)Cumulative VM heap allocation counter across the run.
bigint_bits641,048,576 bitsMaximum bit width of any arbitrary-precision Nat or Int value allocated on the VM heap.
call_depth168,192 framesMaximum LemaIR call stack depth.
seconds1600 secondsHost 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 nameWhat the analyser proves over compiled LemaIR
NoCopySliceCallByte-slice arguments (Std.Bytes.ByteSlice) are passed across call boundaries by reference/offset without allocating intermediate ByteArray copies.
NoBigIntPrimitivesNo reachable basic block invokes arbitrary-precision Nat or Int heap primitives; all arithmetic stays in unboxed machine registers (UInt8..UInt64, Int64).
NoBoxOrCtorInCyclesEvery loop cycle in the LemaIR control-flow graph is allocation-free (no heap boxing or constructor allocation inside loop bodies).
FlatMessageEvery 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.
ExclusiveActorLoopEvery actor’s state loop processes one message to completion before reading the next mailbox message, matching the sequential Actor.Step model.
ConstantTimeFunctions 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.SigV4Secret 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.SigV4VerifyServerInbound server secret bytes flow exclusively into SecretPolicy.verifyInboundSigV4Request and constant-time tag comparison (ctEq32).
SecretFlow.BearerHeaderSecret bytes flow exclusively into SecretPolicy.formatBearerHeader for a TLS-pinned origin.
SecretFlow.X25519StaticStatic 32-byte X25519 secret keys flow exclusively into X25519.dh / Noise static key agreement without leaking the clamped scalar.
SecretFlow.Ed25519Sign32-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/v2 record and its lema.vm-guarantee/v1 receipt IDs.
  • The canonical lema.ir/v1 bytecode module for all reachable declarations.
  • The artifact’s SHA-256 digest, registered under <output>/vm-workers/<sha256>.json for execution by lema-vm-runner.

The Lema repository includes reference manifests under apps/:

FileSchemaEntrypoint and families
apps/collector-vm.jsonlema.exec-source/v2Lema.Cap.Collector.Fixture.app over ["block", "clock", "exchange"].
apps/escrow-ledger-vm.jsonlema.exec-source/v2Two-shard escrow coordinator and ledger (Lema.EscrowLedger.app) over ["block", "clock", "exchange"].
apps/stream-hub-vm.jsonlema.exec-source/v2Lema.Cap.StreamHubApp.table over ["actors", "clock", "stream"].
apps/sha256-vectors.jsonlema.exec-source/v1Pure FIPS 180-4 SHA-256 test vector suite (Lema.Std.Sha256Spec.digest).
apps/sha256-unboxed-vectors.jsonlema.exec-source/v1Unboxed ByteSlice SHA-256 test vector suite (Lema.Std.Sha256Unboxed.digestSlice).

Lema v0.3.2 · Updated 29 October 2026 · Version and compatibility