@@ -119,6 +119,43 @@ Function-style array `any` and `all` evaluation still clone each visited array
119119element into a temporary envelope. That boundary is intentionally left for a
120120later measured refactor.
121121
122+ # ## Optional WebAssembly UDF runtime
123+
124+ ` src/wasm/` implements the opt-in, stateless UDF extension point. It does not
125+ replace the native DSL and is not initialized when the top-level `wasm`
126+ registry is absent.
127+
128+ Startup canonicalizes the configured artifact root, reads each component once
129+ through bounded I/O, verifies its pinned SHA-256 digest, compiles it with
130+ Wasmtime, links it against an empty host linker, checks its declared WIT world,
131+ and probes instantiation before any Kafka client is created. No WASI or other
132+ ambient host interface is linked.
133+
134+ The versioned `streamforge:udf@1.0.0` WIT package defines separate filter,
135+ JSON-value-transform, and mutable-envelope-transform worlds. Source
136+ topic/partition/offset are input-only. Native and UDF stages compose in this
137+ order :
138+
139+ 1. native filter, then UDF filter;
140+ 2. native value transform, then UDF value transform;
141+ 3. native key/header/timestamp envelope mutations, then UDF envelope mutation.
142+
143+ This ordering implements the `PROJECT_SPEC.md` contract : envelope mutations
144+ observe the final destination payload. It changes the earlier runtime behavior,
145+ which applied native envelope mutations before the value transform. Pipelines
146+ that derive envelope fields from values removed by their value transform must
147+ retain those inputs in the transformed payload or update the envelope rule.
148+
149+ Each invocation uses a fresh store and component instance backed by Wasmtime's
150+ pooling allocator. A dedicated epoch thread enforces execution deadlines.
151+ Configured bounds cover artifact, input, output, linear memory, tables, stack,
152+ and concurrent instances. Guest state is never a persistence contract.
153+
154+ UDF failures are deterministic destination-stage failures and are not retried.
155+ The destination `error_policy` selects fail-fast, one contextual DLQ record,
156+ destination skip, or unchanged-envelope continuation. See `docs/WASM_UDFS.md`
157+ for the ABI, deployment, security, and performance contract.
158+
122159# ## Destination processing
123160
124161` src/processor.rs` builds a runtime for each configured destination.
@@ -301,4 +338,4 @@ and are not inferred from unit or microbenchmark success.
301338- ` docs/PERFORMANCE.md` — tuning and benchmark method
302339- ` docs/DELIVERY_GUARANTEES.md` — commit and failure semantics
303340
304- **Last updated:** 2026-07-24
341+ **Last updated:** 2026-07-25
0 commit comments