repositories / smith

smith

There are many coding harnesses - but this one is fast

owned by bugabinga

docs(specs): sealed WASI, network transport, memory accounting

d045dc2acbbc8dd96bed33bc0f8754f27dae12e1

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (2)

+47 / −0 text lines

Diff layout

.system/specs/SMH-SPEC-SPEC0001-smith-specification/index.md

Modified

+25 / −0 text lines

@@ -94,6 +94,22 @@ Network transport
9494- provider errors,
9595- cancellation.
97### Network transport
99One host-owned HTTP engine serves provider traffic and granted plugin net effects.
100It is synchronous and pure Rust: no async runtime, no system TLS library.
101TLS validates against bundled Mozilla roots.
103Every exchange is bounded and observable:
105- request bodies above 16 MiB are rejected before send,
106- response bodies stop at 64 MiB; the stream closes at the bound,
107- the response head arrives within 120 s or the exchange fails,
108- a gap of 300 s between body chunks ends the stream,
109- body chunks are delivered as they arrive, never buffered to completion,
110- cancellation is observed at each chunk boundary; no chunk read after cancellation is delivered,
111- non-2xx statuses are delivered as responses, never as transport errors.
97113### Model capabilities
99115Model metadata states supported behavior explicitly, including:
@@ -385,6 +401,15 @@ Memory accounting
385401- transcript work scales with visible content rather than complete history where practical,
386402- long-running network and filesystem work never blocks input rendering.
404### Memory accounting
406Every allocation, including engine allocations, is attributed to the innermost active lifetime scope on its thread: process, session, turn, kernel call, frame, or io request.
407A scope is entered by a guard; a thread with no guard is in the process scope.
408A 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.
409Per scope Smith reports allocation count, allocated bytes, live bytes, and peak live bytes.
410Accounting never allocates, never locks, and never aborts; ceilings are recorded and reported.
411For a deterministic path with isolated state, counts are identical across runs; allocation-count tests assert exact counts and bounds only tighten.
388413Smith supports current Windows, macOS, and Linux on x86_64 and ARM64 where Rust and required native dependencies support the target.
389414OpenBSD x86_64 is best effort.
390415Release archives include versioned binaries and SHA-256 checksums.

.system/specs/SMH-SPEC-WASM0001-wasm-plugin-runtime/index.md

Modified

+22 / −0 text lines

2121- 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.
2222- Components are validated before instantiation: typecheck against the pinned smith world, memories and tables declared with max equal to min, runtime limiter rejects growth.
24## Sealed WASI
26The host links no WASI implementation crate; every `wasi:*` import a guest std runtime needs is a synchronous Smith implementation in the host world.
27The host world is the smith world plus exactly the sealed interfaces below; an import outside that set fails instantiation naming the interface.
28Guest imports at any `0.2.x` resolve against the host's pinned `0.2` definitions by semver.
30| interface | sealed semantics |
31|---|---|
32| `wasi:cli/environment` | environment, arguments, and initial cwd are empty |
33| `wasi:cli/stdin` | closed stream |
34| `wasi:cli/stdout`, `wasi:cli/stderr` | writes are accepted in bounded chunks and discarded; nothing reaches the host process streams |
35| `wasi:cli/terminal-*` | no terminal |
36| `wasi:cli/exit` | traps with a diagnostic; a guest cannot end the host |
37| `wasi:clocks/monotonic-clock` | `now` returns the host-injected value for the current call; resolution 1; the value never advances inside a call |
38| `wasi:io/poll` | every pollable is ready; `poll` returns all indices |
39| `wasi:io/streams`, `wasi:io/error` | only the sealed stdio streams exist; splice and read report closed |
41Wall clock, randomness, filesystem, and sockets are not linked; a guest importing them fails instantiation until a granted Smith substitute exists for that interface.
42Sealed interactions carry no host state and need no recording; recorded substitutes (clock injection, seeded RNG) enter the trace as host inputs of the call.
43WIT 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.
2445## Capabilities
2647- The manifest declares requested capabilities.
98119- Fuel exhaustion and memory ceilings surface as explicit plugin errors.
99120- Reload is atomic; failed reload preserves previous plugin state.
100121- `smith plugin check` rejects artifacts with ambient imports or growable memories.
122- 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.