docs(specs): sealed WASI, network transport, memory accounting
d045dc2acbbc8dd96bed33bc0f8754f27dae12e1
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
- Parent 1: f4af4acfbafb
There are many coding harnesses - but this one is fast
d045dc2acbbc8dd96bed33bc0f8754f27dae12e1
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
+47 / −0 text lines
+25 / −0 text lines
### Network transportOne host-owned HTTP engine serves provider traffic and granted plugin net effects.It is synchronous and pure Rust: no async runtime, no system TLS library.TLS validates against bundled Mozilla roots.Every exchange is bounded and observable:- request bodies above 16 MiB are rejected before send,- response bodies stop at 64 MiB; the stream closes at the bound,- the response head arrives within 120 s or the exchange fails,- a gap of 300 s between body chunks ends the stream,- body chunks are delivered as they arrive, never buffered to completion,- cancellation is observed at each chunk boundary; no chunk read after cancellation is delivered,- non-2xx statuses are delivered as responses, never as transport errors.### Memory accountingEvery allocation, including engine allocations, is attributed to the innermost active lifetime scope on its thread: process, session, turn, kernel call, frame, or io request.A scope is entered by a guard; a thread with no guard is in the process scope.A block is charged to the scope that allocated it for its whole life, so releasing it in another scope keeps live and peak accounting exact.Per scope Smith reports allocation count, allocated bytes, live bytes, and peak live bytes.Accounting never allocates, never locks, and never aborts; ceilings are recorded and reported.For a deterministic path with isolated state, counts are identical across runs; allocation-count tests assert exact counts and bounds only tighten.+22 / −0 text lines
- WASI interfaces that guest-language std runtimes import for standard functionality (environment, poll, and peers) are satisfied on demand by Smith implementations with smith-controlled semantics: sealed by default, manifest-granted values, recorded and replayable. Standard guest code stays painless — no smith-specific surface is required for ordinary std usage.- Components are validated before instantiation: typecheck against the pinned smith world, memories and tables declared with max equal to min, runtime limiter rejects growth.## Sealed WASIThe host links no WASI implementation crate; every `wasi:*` import a guest std runtime needs is a synchronous Smith implementation in the host world.The host world is the smith world plus exactly the sealed interfaces below; an import outside that set fails instantiation naming the interface.Guest imports at any `0.2.x` resolve against the host's pinned `0.2` definitions by semver.| interface | sealed semantics ||---|---|| `wasi:cli/environment` | environment, arguments, and initial cwd are empty || `wasi:cli/stdin` | closed stream || `wasi:cli/stdout`, `wasi:cli/stderr` | writes are accepted in bounded chunks and discarded; nothing reaches the host process streams || `wasi:cli/terminal-*` | no terminal || `wasi:cli/exit` | traps with a diagnostic; a guest cannot end the host || `wasi:clocks/monotonic-clock` | `now` returns the host-injected value for the current call; resolution 1; the value never advances inside a call || `wasi:io/poll` | every pollable is ready; `poll` returns all indices || `wasi:io/streams`, `wasi:io/error` | only the sealed stdio streams exist; splice and read report closed |Wall clock, randomness, filesystem, and sockets are not linked; a guest importing them fails instantiation until a granted Smith substitute exists for that interface.Sealed interactions carry no host state and need no recording; recorded substitutes (clock injection, seeded RNG) enter the trace as host inputs of the call.WIT sources for sealed interfaces are copied verbatim from the wasmtime WASI distribution under their license, minus worlds that reference unlinked packages; the file header names the origin and the modification.- A guest built from an unmodified `wasm32-wasip2` std target instantiates against the sealed host world without an async runtime in the host dependency graph.