Skip to content

Rust Runtime

The Rust runtime turns generated component artifacts into HTTP behavior. It loads route metadata, prepares typed inputs, exposes controlled sigMAX primitives and renders structured results. Business behavior stays in contracts and generated WebAssembly modules.

sigMAX has two proprietary editions. Core places Host and Config on the same machine under Docker Compose, with WASM execution inside the containerized runtime. Pro uses Kubernetes and a separate COS2000 executor in a KubeVirt VM.

This page documents the Rust/Wasmtime implementation present in sigMAX_runtime. Its Wasmtime instance management describes the container execution path; it does not describe the implementation inside COS2000.

InputRuntime responsibility
Generated routesMatch HTTP methods and paths to a declared handler and module.
Type definitionsEncode typed request data using the declared c_repr layout.
WASM modulesValidate linking and handler exports before serving requests.
Capabilities and bindingsControl access to named host operations and services.
Route limitsBound memory, execution time, fuel and request/response sizes.

The Rust host owns infrastructure access. Generated handlers use explicit imports; they do not open database connections, host files or raw sockets.

Container runtime request flowThe Rust host validates a request, borrows a prepared WASM instance and resets host request context. The handler invokes permitted primitives during execution. ObjectIR or DocIR is then rendered as the HTTP response.HTTP requestRoute andinput checksBorrowinstancereset hostcontextRun handlerand host callsObjectIR orDocIRRenderedHTTPresponse

At startup, one Wasmtime engine compiles each canonical module path once. Routes sharing a module and memory limit share a pool of preinitialized instances. Invalid modules, imports or handler exports fail startup. Changed module files require a runtime restart.

The amber gate checks the request, the violet double border marks the borrowed execution instance, and the green end shape is the returned response. Borrowing an instance does not mean creating one for that request. Primitive calls occur during handler execution, under the active request context; they are not a separate stage after the handler has finished.

For each request, the host checks the HTTP envelope and configured identity boundary, prepares typed input, attaches route capabilities and bindings, then executes the handler within its budget. ObjectIR becomes JSON; DocIR can be rendered as escaped HTML, Markdown or bounded PDF according to the route configuration.

SettingBehavior
SIGMAX_WASM_MODE=performanceDefault. Reuse a healthy instance; guest memory and globals persist.
SIGMAX_WASM_MODE=saferUse a fresh preinitialized instance for each executed request, then discard it.
SIGMAX_WASM_INSTANCES=NSimultaneous requests per pool, from 1 to 64. Default follows CPU parallelism, capped at 32.
SIGMAX_WASM_RESERVE=RAdditional warmed instances, from 1 to 64. Default is the smaller of N and 4.

Each instance serves one request at a time. A bounded background refill worker replaces discarded instances from the cached compiled module. Request context, fuel and deadlines are reset in both modes. Traps, timeouts and panics discard the affected instance.

Performance-mode handlers must reset their temporary guest state. Guest globals are not shared application storage, because concurrent requests can use different instances.

The sigmax import namespace provides bounded operations for inputs, responses, ObjectIR, DocIR, identity, schema validation, logging, metrics, traces, HTTP, signatures, secrets, events, object storage and cache.

Capabilities and route bindings select permitted operations. Pointer ranges, lengths and output buffers are checked when bytes cross the WASM boundary. Secrets remain host-managed; HMAC and signature operations work through logical references.

See Primitives, Dapr and Storage service.

VariableDefault or purpose
SIGMAX_ROUTES../generated/routes.yaml; generated route metadata.
SIGMAX_BIND0.0.0.0:8080; runtime HTTP listener.
SIGMAX_DOCS_INDEX_PATH/app/generated/docs/index.html.
SIGMAX_OPENAPI_PATH/app/generated/openapi.yaml.
DAPR_HTTP_ENDPOINTSidecar endpoint when a binding uses Dapr.
SIGMAX_CACHE_URLRedis cache endpoint; otherwise the bounded cache is process-local.
SIGMAX_TRUST_IDENTITY_HEADERSExplicitly trust identity supplied by the deployment’s authenticated front proxy.
SIGMAX_REQUIRE_IDENTITYRequire that trusted identity for routed calls.

The operational endpoints include /healthz, /docs/, /openapi.yaml and /.well-known/component. These endpoints describe the running component; they do not replace agreement validation.

ResourceCurrent behavior
JSON request body1 MiB maximum, checked before and after supported decompression.
Request headers32 KiB aggregate maximum.
Path and query8 KiB maximum.
Fuel10,000,000 per request by default; configured through limits.fuel.
Execution deadlineRoute deadline enforced through Wasmtime epoch interruption.
Guest memoryRoute limits.memory_max_mb, including memory growth.
Structured outputObjectIR/DocIR size limits, including the rendered DocIR result.

Routes can lower the HTTP envelope limits but cannot raise their hard caps. HTTP and Dapr operations use the remaining request deadline. Epoch interruption stops guest execution; it cannot forcibly cancel every native host operation. In particular, system DNS resolution and Redis connection setup can delay completion.

The implementation references are runtime/src/main.rs, runtime/src/wasm.rs, runtime/src/primitives.rs and runtime/README.md in sigMAX_runtime.