README Source History Refs Reviews Compare Notes Search Review guide docs(system): replace lua plugin law with wasm component runtime c363c47eca45822bc3e4c7805a0065a7f7bb4ea4
Oliver Jan Krylow <oliver@bugabinga.net > · 25 Sep 2026
unsigned
Browse files Compare with HEAD
- research SMH-RESEARCH-WASM0001: candidate matrix, determinism knobs, zed precedent
- new spec SMH-SPEC-WASM0001: engine, capabilities, calls, lifecycle, concurrency, versioning, identity, diagnostics, guests, tooling
- SPEC0001 generalized to language-agnostic plugins, manifest discovery, KDL config
- MISSION/RULES: wasmtime + WIT law, wasm layout, wasm host in smith-harness
- plans: PLUG0001 replaces LUAH0001, TUIR/RELS wording
- Cargo.toml: drop unused mlua + mlua-pkg
Changed files (12) Diff layout Auto Unified Split
.system/MISSION.md Modified +2 / −2 text lines
9 9 - JSON-RPC stdio mode,- JSON-RPC stdio mode,10 10 - provider-independent agent loop,- provider-independent agent loop,11 11 - deterministic CBOR sessions and replay,- deterministic CBOR sessions and replay,12 + - wasm component plugin system,13 13 - built-in coding tools exposed through the same plugin API as user tools.- built-in coding tools exposed through the same plugin API as user tools.15 - Core bet: Rust owns performance and safety; Lua owns user extension, layout, prompts, tools, themes, and keybindings.15 + Core bet: Rust owns performance and safety; sandboxed wasm components own user extension, layout, prompts, tools, themes, and keybindings.+5 / −5 text lines
13 13 - Latest stable Rust, edition 2024.- Latest stable Rust, edition 2024.14 14 - No numeric MSRV unless release policy creates one.- No numeric MSRV unless release policy creates one.15 15 - Nightly only for pinned cargo-pup architecture gate.- Nightly only for pinned cargo-pup architecture gate.16 + - wasmtime plus WIT components for plugins.17 17 - CBOR sessions.- CBOR sessions.18 18 - XDG dirs.- XDG dirs.20 20 - Secret proxy, no keychain dependency.- Secret proxy, no keychain dependency.21 21 - StreamFn abstracts providers.- StreamFn abstracts providers.22 - - Lua plugins run sandboxed.23 - - Rust widgets, Lua layout.22 + - Plugin wasm runs sandboxed: no ambient WASI, host capabilities only, fuel metered.23 + - Rust widgets, wasm layout.25 25 ## Authority ## Authority 51 51 ## Architecture ## Architecture 54 - smith/ shared types, StreamFn, AgentTool, config, Lua runtime, errors54 + smith/ shared types, StreamFn, AgentTool, config, errors55 55 smith-core/ agent loop, sessions, tools, hooks, compaction, cost, trace, replaysmith-core/ agent loop, sessions, tools, hooks, compaction, cost, trace, replay56 56 smith-ai/ providers, auth, model registry, provider streams, MuxProvidersmith-ai/ providers, auth, model registry, provider streams, MuxProvider57 57 smith-tui/ terminal events, widgets, layout primitives, render loop, themessmith-tui/ terminal events, widgets, layout primitives, render loop, themes58 - smith-harness/ orchestration, plugin system, SDK, event bridge, built-ins, help58 + smith-harness/ orchestration, wasm plugin host, plugin system, SDK, event bridge, built-ins, help59 59 smith-cli/ binary entry point, CLI, session commands, eval/rpc/replaysmith-cli/ binary entry point, CLI, session commands, eval/rpc/replay60 60 xtask/ cargo-only automationxtask/ cargo-only automation.system/phases/SMH-PHASE-LUAH0001-extensible-product/index.md Modified +1 / −1 text lines
10 10 ## Operating posture ## Operating posture 12 - Make Lua extension the normal product path across Smith.12 + Make plugin extension the normal product path across Smith.13 13 Prioritize one sandboxed loading model for built-in and user behavior, with Rust limited to safe primitives.Prioritize one sandboxed loading model for built-in and user behavior, with Rust limited to safe primitives.15 15 ## Transition signal ## Transition signal .system/phases/SMH-PHASE-TUIR0001-interactive-product/index.md Modified +1 / −1 text lines
10 10 ## Operating posture ## Operating posture 12 12 Make terminal interaction and historical state first-class across Smith.Make terminal interaction and historical state first-class across Smith.13 - Prioritize consistent live and replayed views, Lua -owned layout, and controlled VCS operations.13 + Prioritize consistent live and replayed views, plugin -owned layout, and controlled VCS operations.15 15 ## Transition signal ## Transition signal .system/plans/SMH-PLAN-LUAH0001-lua-harness-and-plugins/index.md Deleted deleted file mode 100644+0 / −55 text lines
4 - title: "Sandboxed Plugin Harness"5 - spec: SMH-SPEC-SPEC00017 - depends_on: [SMH-PLAN-AIAG0001]10 - # Sandboxed Plugin Harness 14 - - Eval and RPC use the shared provider-independent runtime.15 - - Agent, tool, provider, and session events are typed and ordered.19 - 1. Add project trust resolution before project executable configuration or package discovery.20 - 2. Add the restricted Lua runtime and trusted source validation boundary.21 - 3. Add convention-based package, module contract, and implementation discovery.22 - 4. Add deterministic module binding, ambiguity diagnostics, and plugin precedence.23 - 5. Add typed SDK namespaces for filesystem, search, tools, commands, providers, UI, VCS, logging, and lifecycle control.24 - 6. Bridge runtime events and plugin results without exposing internal ownership.25 - 7. Load each plugin into a transactional registration set so failure leaves no active residue.26 - 8. Route built-in commands, presentation, themes, keybindings, prompts, and workflows through the same loader.27 - 9. Add atomic reload with rollback and preserved session continuity.28 - 10. Wire trusted global, project, and explicit plugin sources into the harness.32 - - `smith::lua`: source validation, sandbox, typed host calls, and cancellation.33 - - `smith-harness::trust`: persisted and one-run project decisions.34 - - `smith-harness::plugins`: discovery, binding, registration transactions, reload.35 - - Lua SDK: the only plugin path to host effects.39 - - Raw operating-system, filesystem, environment, and debug libraries are unavailable.40 - - Project plugins and executable configuration cannot run before trust resolution.41 - - Non-interactive untrusted project behavior is skipped with a visible diagnostic.42 - - Built-in and user plugins use the same sandbox and registration path.43 - - Zero, singleton, ambiguous, and explicit module bindings follow the specification.44 - - Failed load or reload leaves no subscriptions, tools, providers, or UI registrations behind.45 - - Successful reload preserves the active session and swaps one coherent plugin state.49 - The harness operates through the public sandboxed plugin surface with explicit project trust and no privileged built-in path.53 - - A built-in requires an effect absent from the public SDK.54 - - Trust must execute project code to determine trust.55 - - Reload cannot separate candidate registrations from active state.
.system/plans/SMH-PLAN-PLUG0001-plugin-harness/index.md Added new file mode 100644+60 / −0 text lines
4 + title: "Sandboxed Plugin Harness"5 + spec: SMH-SPEC-SPEC00017 + depends_on: [SMH-PLAN-AIAG0001]8 + research: [SMH-RESEARCH-WASM0001]11 + # Sandboxed Plugin Harness 15 + - Eval and RPC use the shared provider-independent runtime.16 + - Agent, tool, provider, and session events are typed and ordered.20 + 1. Add project trust resolution before project executable configuration or package discovery.21 + 2. Add the wasm host: engine config, artifact validation, determinism knobs, fuel and memory ceilings.22 + 3. Add manifest-based package discovery with contract version and capability requests.23 + 4. Add deterministic module binding, ambiguity diagnostics, and plugin precedence.24 + 5. Add the typed `smith:plugin` WIT world covering filesystem, search, tools, commands, providers, UI, VCS, logging, and lifecycle control.25 + 6. Bridge runtime events and plugin results without exposing internal ownership.26 + 7. Load each plugin into a transactional registration set so failure leaves no active residue.27 + 8. Route built-in commands, presentation, themes, keybindings, prompts, and workflows through the same loader.28 + 9. Add atomic reload with rollback and preserved session continuity.29 + 10. Wire trusted global, project, and explicit plugin sources into the harness.30 + 11. Add plugin tooling: init, build, check, dev watch with hot swap, test harness with mocked capabilities.34 + - `smith-harness::wasm`: engine config, instantiation, capabilities, fuel, ceilings.35 + - `smith-harness::trust`: persisted and one-run project decisions.36 + - `smith-harness::plugins`: discovery, binding, registration transactions, reload.37 + - `smith:plugin` WIT world: the only plugin path to host effects.41 + - Ambient WASI imports are unavailable; ungranted capabilities fail instantiation.42 + - Fuel exhaustion and memory ceilings surface as explicit plugin errors.43 + - Project plugins and executable configuration cannot run before trust resolution.44 + - Non-interactive untrusted project behavior is skipped with a visible diagnostic.45 + - Built-in and user plugins use the same sandbox and registration path.46 + - Zero, singleton, ambiguous, and explicit module bindings follow the specification.47 + - Failed load or reload leaves no subscriptions, tools, providers, or UI registrations behind.48 + - Successful reload preserves the active session and swaps one coherent plugin state.49 + - Repeated runs of one artifact with recorded host inputs produce identical outputs.53 + The harness operates through the public sandboxed plugin surface with explicit project trust and no privileged built-in path.57 + - A built-in requires an effect absent from the public WIT world.58 + - Trust must execute project code to determine trust.59 + - Reload cannot separate candidate registrations from active state.60 + - Deterministic knobs cannot be enforced without unacceptable layout latency..system/plans/SMH-PLAN-RELS0001-docs-release-and-hardening/index.md Modified +2 / −2 text lines
19 19 1. Complete provider catalog ingestion, provenance, conflict reporting, cached fallback, and human review flow.1. Complete provider catalog ingestion, provenance, conflict reporting, cached fallback, and human review flow.20 - 2. Generate Lua SDK help from the authoritative typed declarations and usage descriptions.21 - 3. Verify public Rust, Lua , event, command, and configuration documentation for completeness and drift.20 + 2. Generate plugin SDK help from the authoritative contract declarations and usage descriptions.21 + 3. Verify public Rust, plugin , event, command, and configuration documentation for completeness and drift.22 22 4. Complete architecture, lint, format, test, documentation, audit, coverage, mutation, and benchmark gates through Cargo automation.4. Complete architecture, lint, format, test, documentation, audit, coverage, mutation, and benchmark gates through Cargo automation.23 23 5. Harden provider streams, compaction, session recovery, plugin rollback, project trust, terminal restoration, RPC framing, and tool cancellation against recorded edge cases.5. Harden provider streams, compaction, session recovery, plugin rollback, project trust, terminal restoration, RPC framing, and tool cancellation against recorded edge cases.24 24 6. Build versioned release archives and SHA-256 checksums for required targets.6. Build versioned release archives and SHA-256 checksums for required targets..system/plans/SMH-PLAN-TUIR0001-tui-and-replay/index.md Modified +5 / −5 text lines
4 4 title: "Fullscreen TUI and Replay"title: "Fullscreen TUI and Replay"5 5 spec: SMH-SPEC-SPEC0001spec: SMH-SPEC-SPEC00016 6 status: draftstatus: draft7 - depends_on: [SMH-PLAN-LUAH0001 ]7 + depends_on: [SMH-PLAN-PLUG0001 ]10 10 # Fullscreen TUI and Replay # Fullscreen TUI and Replay 20 20 2. Add conservative capability detection, bounded probes, explicit overrides, and plain-terminal fallback.2. Add conservative capability detection, bounded probes, explicit overrides, and plain-terminal fallback.21 21 3. Add normalized keyboard, paste, mouse, resize, and focus events.3. Add normalized keyboard, paste, mouse, resize, and focus events.22 22 4. Add deterministic widget, overlay, theme, and layout primitives in `smith-tui`.4. Add deterministic widget, overlay, theme, and layout primitives in `smith-tui`.23 - 5. Add structured Lua render descriptions and the default fullscreen layout.23 + 5. Add structured plugin render descriptions and the default fullscreen layout.24 24 6. Add an independently scrollable transcript with sticky-bottom control and explicit jump to latest.6. Add an independently scrollable transcript with sticky-bottom control and explicit jump to latest.25 25 7. Add stable search, selection, link activation, viewport navigation, and focus routing.7. Add stable search, selection, link activation, viewport navigation, and focus routing.26 26 8. Add replay reconstruction, seek, speed, range, and comparison over session and trace inputs.8. Add replay reconstruction, seek, speed, range, and comparison over session and trace inputs.27 27 9. Add structured VCS snapshot, diff, restore, undo, redo, and time-travel primitives.9. Add structured VCS snapshot, diff, restore, undo, redo, and time-travel primitives.28 - 10. Expose replay and VCS workflows through built-in Lua plugins.28 + 10. Expose replay and VCS workflows through built-in plugins.30 30 ## Interfaces ## Interfaces 32 32 - `smith-tui::terminal`: fullscreen lifecycle and capabilities.- `smith-tui::terminal`: fullscreen lifecycle and capabilities.33 33 - `smith-tui::event`: normalized input independent of terminal quirks.- `smith-tui::event`: normalized input independent of terminal quirks.34 34 - `smith-tui::view`: deterministic widgets, viewport, overlays, and themes.- `smith-tui::view`: deterministic widgets, viewport, overlays, and themes.35 - - Lua UI SDK: product layout and structured presentation.35 + - Plugin UI SDK: product layout and structured presentation.36 36 - Replay: recorded state to deterministic render model.- Replay: recorded state to deterministic render model.37 37 - VCS SDK: validated history queries and mutations.- VCS SDK: validated history queries and mutations.55 55 ## Stop conditions ## Stop conditions 57 57 - Correct replay needs data absent from durable session or trace contracts.- Correct replay needs data absent from durable session or trace contracts.58 - - Lua render descriptions require arbitrary terminal writes.58 + - Plugin render descriptions require arbitrary terminal writes.59 59 - Terminal restoration cannot be guaranteed for an owned exit path.- Terminal restoration cannot be guaranteed for an owned exit path..system/research/SMH-RESEARCH-WASM0001-embedded-wasm/index.md Added new file mode 100644+162 / −0 text lines
2 + id: SMH-RESEARCH-WASM00014 + title: "Embedded language: wasm components"7 + # Embedded language: wasm components 11 + Replace the planned mlua + LuaJIT plugin runtime with wasmtime + WIT components?19 + - sandbox (RULES: plugins run sandboxed)20 + - determinism (MISSION: CBOR sessions, replay)24 + Scores 0-3, judgement, not measurement.26 + | candidate | perf | types | tooling | reuse | sandbox | determinism | migration cost |27 + | --- | --- | --- | --- | --- | --- | --- | --- |28 + | LuaJIT + LuaLS | 2 | 1 | 1 | 0 | 1 | 2 | 0 |29 + | Luau via mlua | 2 | 2 | 2 | 0 | 3 | 3 | 1 |30 + | wasm components | 2.5 | 3 | 3 | 2 | 3 | 3 | 3 |31 + | native Rust dylibs | 3 | 3 | 3 | 3 | 0 | 3 | 2 |32 + | V8 / TS | 2 | 2 | 3 | 2 | 2 | 1 | 3 |34 + Decision (human): wasm components, Rust guests v1.36 + ## Current state in repo 38 + - mlua + mlua-pkg removed from root Cargo.toml (2026 wasm decision).39 + - Zero `.rs` files ever referenced mlua or lua.40 + - Migration cost was dep swap + law text. No code migration.41 + - Migration cost = dep swap + law text. No code migration.43 + ## Runtime: wasmtime vs wasmi 47 + - wasmtime: Cranelift JIT, component model support, WIT bindgen host API in `wasmtime::component`.48 + - wasmi: pure interpreter, 1.0 stable 2025-12, wasmtime-compatible API direction.49 + - Interpreter vs JIT gap: JIT ~4x faster on ARM, ~8x on x86 (wasmi benchmark blog, 2024; wasmi 1.0 thread, 2025).50 + - Both pure Rust → build on aarch64 termux without luajit cross-compile pain.51 + - wasmi lacks full component model support → guest WIT bindings story weaker.55 + - wasmtime: primary. Components + determinism knobs + resource limiters.56 + - wasmi: fallback only if binary size or build time becomes blocking; loses component model.58 + To measure on target device (aarch64 termux):60 + - release build time delta, mlua/luajit out vs wasmtime in62 + - layout callback batch latency64 + ## Determinism knobs (wasmtime) 66 + From wasmtime docs (Deterministic Wasm Execution):68 + - All imports must be deterministic → smith host API only, no ambient WASI.69 + - `Config::cranelift_nan_canonicalization` → canonical NaN.70 + - `Config::relaxed_simd_deterministic` (slower) or disable relaxed SIMD.71 + - Memory/table growth nondeterminism → `Store::limiter` rejects growth, or require max == min at validation via wasmparser.72 + - Interruption: fuel = deterministic, epoch = non-deterministic → use fuel.73 + - WASI clocks/fs are nondeterministic → if WASI ever needed, virtualize via wasi-virt. Not needed: plugins get explicit host capabilities only.77 + - fuel metering everywhere (interactive + replay use same mechanism).78 + - NaN canonicalization on, relaxed SIMD off.79 + - modules validated: memories/tables max == min.80 + - time injected as explicit argument by host, never ambient.81 + - host↔guest calls recorded in CBOR session → replay verifiable.85 + - wasm isolation: no fs/net/proc unless host grants.86 + - capability grants per plugin: declared in manifest, checked at instantiation, host fns gated per grant.87 + - resource limits: `ResourceLimiter` for memory/tables; fuel for cpu.88 + - zed precedent: extensions run in stricter sandbox with limited capabilities, allowlist discussion in zed#12358.90 + ## Host API sketch (WIT) 92 + Not binding. Spec phase decides.95 + package smith:plugin@0.1.0;98 + import host; // log, granted caps: fs-scope, net-scope, secret-proxy99 + export init; // manifest-driven100 + export tools; // list, describe, invoke (recorded io)101 + export layout; // frame batch in, layout batch out104 + export keymap; // predicates + bindings110 + - JIT'd wasm call ≈ ns-scale for entry; cost driver is marshalling.111 + - Layout: batch per frame (one call, dirty regions in, constraints + widgets out) → avoids per-widget calls.112 + - Tools: invoke per tool call, io already event-driven → negligible.113 + - Keymap predicates: called per input event → keep signature tiny.114 + - Perf-critical widget rendering stays Rust (RULES: Rust widgets).118 + - cargo-component (bytecodealliance): cargo subcommand, Rust guests, wit-bindgen generated stubs.119 + - wasm-tools: component tooling, validation.120 + - jco: JS/TS guests later → npm ecosystem.121 + - smith ships thin wrappers only: `smith plugin init/build/check` → wrap cargo + wasm-tools. No own-language tooling.125 + - Zed extensions = Rust compiled to wasm component, WIT-defined host API, sandboxed, extension trait guest-side.126 + - Same shape as smith needs: editor callbacks, themes, languages as plugins.127 + - Lesson: keep host API small + versioned; async boundary complexity is real → prefer batched sync calls for v1.131 + - Component API stability: pin wasmtime minor version; WIT world versioning policy.132 + - Hot reload cost: reinstantiate module per change → expected ms-scale, to measure.133 + - Prompt-template heavy plugins: pure compute in wasm → fine; string-heavy marshalling cost to measure.134 + - User config format: decided KDL (human decision, wasm transition). Recorded in SPEC0001.135 + - Data-only theme/keymap packages: rejected by human. All extensions are compiled plugins.137 + ## Candidate conclusions 139 + 1. wasmtime + WIT, Rust-only guests v1. → spec SMH-SPEC-WASM0001.140 + 2. No ambient WASI. Host capabilities via WIT imports only.141 + 3. Fuel metering, NaN canonicalization, no relaxed SIMD, max==min memories.142 + 4. Layout API = batched frame interface.143 + 5. Drop mlua, mlua-pkg from root Cargo.toml (needs human approval: root Cargo.toml is human-owned). → applied 2026.144 + 6. Concurrency: defer implementation, pin model now. One instance = single-threaded actor; parallelism = host-orchestrated lanes; intra-guest threads rejected.145 + 7. Versioning: additive-only minors; optional new exports; versioned worlds with deprecation window; manifest declares world version; catch-all unknown case in shared types from v1.146 + 8. Additional guest languages cost a scaffold template + bindgen only; host unchanged. js/ts via jco, go, python are first candidates.147 + 9. Plugin identity = artifact + KDL manifest; artifact content hash pinned in session traces. Runtime never sees source; provenance optional.148 + 10. No recompilation at load time. Old artifacts keep running across additive world updates; EOL artifacts fail with explicit rebuild path.149 + 11. Diagnostics contract: every lifecycle stage names stage, cause, fix. No heuristic errors.150 + 12. Registration is explicit-only: init/build never register; dev, link, install do. Dev links load by reference, override installed plugins, pin artifact hash per load.151 + 13. TypeScript via jco = compatibility canary in CI from v1. Prevents rust coupling: WIT ergonomics, promise interop, fuel ceilings, memory preallocation, language-pluggable tooling.152 + 14. To measure on jco canary: artifact size, quickjs fuel burn ratio, componentize-js memory preallocation vs max==min.156 + - wasmtime deterministic execution: https://docs.wasmtime.dev/examples-deterministic-wasm-execution.html157 + - wasmtime security: https://docs.wasmtime.dev/security.html158 + - wasmi new engine: https://wasmi-labs.github.io/blog/posts/wasmi-v0.32/159 + - wasmi 1.0: https://www.reddit.com/r/rust/comments/1pd61oi/160 + - cargo-component: https://github.com/bytecodealliance/cargo-component161 + - zed extensions: https://zed.dev/blog/zed-decoded-extensions162 + - zed sandbox allowlist: https://github.com/zed-industries/zed/issues/12358.system/specs/SMH-SPEC-SPEC0001-smith-specification/index.md Modified +15 / −11 text lines
2 2 id: SMH-SPEC-SPEC0001id: SMH-SPEC-SPEC00014 4 title: "Smith Specification"title: "Smith Specification"5 - research: [SMH-RESEARCH-FNY87IGJ]5 + research: [SMH-RESEARCH-FNY87IGJ, SMH-RESEARCH-WASM0001 ]8 8 # Smith Specification # Smith Specification 12 - Smith is a fast Rust coding-agent TUI with Lua -owned customization.12 + Smith is a fast Rust coding-agent TUI with plugin -owned customization.13 13 It provides one provider-independent agent runtime across interactive, eval, JSON-RPC, and replay modes.It provides one provider-independent agent runtime across interactive, eval, JSON-RPC, and replay modes.22 22 - deterministic CBOR sessions and replay,- deterministic CBOR sessions and replay,23 23 - provider and model selection,- provider and model selection,24 24 - built-in coding tools,- built-in coding tools,25 - - sandboxed Lua plugins,26 26 - VCS-backed history and recovery,- VCS-backed history and recovery,27 27 - generated SDK help.- generated SDK help.31 31 ## Product boundaries ## Product boundaries 33 33 - Rust owns safety, persistence, concurrency, terminal primitives, provider adapters, and bounded tool effects.- Rust owns safety, persistence, concurrency, terminal primitives, provider adapters, and bounded tool effects.34 - - Lua owns user extension, product layout, prompts, themes, keybindings, commands, and tool presentation.34 + - Sandboxed plugins own user extension, product layout, prompts, themes, keybindings, commands, and tool presentation.35 35 - Built-in and user-visible extension behavior use the same plugin contracts.- Built-in and user-visible extension behavior use the same plugin contracts.36 36 - Provider details do not enter the agent, session, tool, plugin, or interface contracts.- Provider details do not enter the agent, session, tool, plugin, or interface contracts.37 37 - Interface modes share one runtime behavior rather than reimplementing the agent loop.- Interface modes share one runtime behavior rather than reimplementing the agent loop.205 205 ## Plugins and configuration ## Plugins and configuration 207 - Lua plugins run in a restricted runtime without direct operating-system, filesystem, environment, or debug libraries .207 + Plugins run in a restricted runtime without direct operating-system, filesystem, environment, network, or clock access .208 + Plugin execution is resource-bounded.208 209 Host effects are available only through typed Smith SDK functions.Host effects are available only through typed Smith SDK functions.209 210 Built-in plugins have no privileged effect path.Built-in plugins have no privileged effect path.227 228 ### Discovery and modules ### Discovery and modules 229 - Version 1 discovers plugin packages and module contracts by path convention without requiring manifests .230 - Package and module identities are deterministic and validated before execution.230 + Version 1 discovers plugin packages by path convention.231 + Each package carries a manifest declaring its plugin artifact, contract version, and requested capabilities.232 + Package and artifact identities are deterministic and validated before execution.233 + Artifacts failing validation never execute.232 235 A module can have zero, one, or multiple implementations.A module can have zero, one, or multiple implementations.233 236 One implementation binds automatically.One implementation binds automatically.244 247 Non-interactive modes require an explicit or previously persisted decision to load project-local executable behavior.Non-interactive modes require an explicit or previously persisted decision to load project-local executable behavior.245 248 Ignoring untrusted project behavior produces a visible diagnostic.Ignoring untrusted project behavior produces a visible diagnostic.247 - Trust does not remove the Lua sandbox or tool boundaries.250 + Trust does not remove the plugin sandbox or tool boundaries.249 252 ### Configuration ### Configuration
254 + Configuration is expressed in KDL.251 255 Configuration has deterministic precedence:Configuration has deterministic precedence:253 257 1. product defaults,1. product defaults,277 281 - shutdown restores terminal state after normal exit, error, abort, or signal.- shutdown restores terminal state after normal exit, error, abort, or signal.279 283 Rust supplies deterministic widgets and layout primitives.Rust supplies deterministic widgets and layout primitives.280 - Lua selects product layout and presentation.284 + Plugins select product layout and presentation.281 285 Structured render descriptions cannot emit arbitrary terminal control sequences.Structured render descriptions cannot emit arbitrary terminal control sequences.283 287 Terminal capabilities are detected conservatively and can be overridden explicitly.Terminal capabilities are detected conservatively and can be overridden explicitly.315 319 ## Documentation and help ## Documentation and help 317 - Public Rust and Lua APIs are documented.318 - Lua SDK declarations are the source for generated plugin help.321 + Public Rust and plugin SDK APIs are documented.322 + Plugin SDK declarations are the source for generated plugin help.319 323 Every public event and function has one discoverable usage description.Every public event and function has one discoverable usage description.320 324 Generated help is checked against the exposed SDK so neither can silently drift.Generated help is checked against the exposed SDK so neither can silently drift..system/specs/SMH-SPEC-WASM0001-wasm-plugin-runtime/index.md Added new file mode 100644+99 / −0 text lines
4 + title: "Wasm Plugin Runtime"5 + research: [SMH-RESEARCH-WASM0001]12 + SPEC0001 plugin contracts implemented with wasm components on an embedded wasmtime host.16 + - Engine enables NaN canonicalization.17 + - Engine disables relaxed SIMD.18 + - Fuel metering is on; fuel exhaustion is an explicit plugin error and leaves the runtime usable.19 + - No ambient WASI: no clocks, randomness, filesystem, network, or environment reach the guest.20 + - Time enters the guest only as explicit host-provided arguments.21 + - Components are validated before instantiation: typecheck against the pinned smith world, memories and tables declared with max equal to min, runtime limiter rejects growth.25 + - The manifest declares requested capabilities.26 + - Grants resolve at trust time for project plugins and install time for user plugins.27 + - Host imports are capability-scoped: fs-scope, net-scope, secret-proxy, log.28 + - An import without a matching grant fails instantiation before guest execution.32 + - All host and guest interactions are recorded into the session trace.33 + - Layout uses one batched frame call per render pass.34 + - Tool invocation uses one call per execution with recorded input and output.35 + - Keymap predicates receive fixed-size input descriptors.36 + - Provider plugins pull stream chunks by explicit request.40 + - Load, validate, instantiate, and register run as one transaction.41 + - Failure at any step leaves no registrations or subscriptions.42 + - Reload swaps to a fully instantiated replacement or keeps the previous state.43 + - Fuel and memory ceilings per plugin are explicit configuration.45 + ## Identity and installation 47 + - A plugin is a component artifact plus a KDL manifest.48 + - The manifest declares id, version, world version, requested capabilities, and optional source provenance.49 + - The artifact content hash is recorded at install; session traces record hashes of loaded plugins.50 + - Smith never recompiles at load time; rebuilding happens only through explicit plugin commands with a toolchain present.51 + - Unsupported world versions fail load with a diagnostic naming the supported range and the rebuild path.52 + - Registration is explicit: init and build never mutate the plugin registry.53 + - Dev links register a source directory by reference; the artifact is loaded from the linked path and its hash recorded per load.54 + - Dev links are explicit overrides and take precedence over installed plugins.58 + - Rust is the primary guest language.59 + - TypeScript via jco is a maintained compatibility target: continuous integration builds and loads a TypeScript example plugin against the current world and applies the same lints.63 + - Every lifecycle stage produces a diagnostic naming stage, cause, and fix.64 + - Instantiation failures name the missing grant or the world version mismatch.65 + - Runtime failures distinguish typed guest errors, traps with backtraces, and resource exhaustion with ceilings.66 + - `smith plugin check` explains every rejected lint with a concrete fix.70 + - One plugin instance is single-threaded; the host never calls one instance concurrently.71 + - Parallelism is host-orchestrated across plugins and instances.72 + - Intra-guest threads and shared memories are not supported.73 + - Version 1 executes plugin calls sequentially per instance.74 + - Concurrent plugin activity records into one ordered session trace with explicit ordering edges.78 + - The smith plugin world is versioned; additive-only changes preserve compatibility.79 + - New host requirements on guests are optional; missing exports mean the feature is not provided.80 + - Breaking changes create a new world version; the host embeds the previous version during a deprecation window.81 + - The manifest declares the world version; the host adapts data to the declared version.82 + - Shared data types include a catch-all unknown case for forward tolerance.86 + - `smith plugin init`: cargo project scaffold with a pinned WIT copy.87 + - `smith plugin build`: cargo build plus component wrapping; emits artifact and manifest.88 + - `smith plugin check`: artifact validation, world match, capability-versus-grant lint, determinism lint.89 + - `smith plugin dev`: watch, rebuild, atomic hot swap into a running runtime.90 + - `smith plugin test`: same host with mocked capabilities and golden determinism fixtures.91 + - Plugin tooling dispatches on language adapters; no command assumes the Rust toolchain.93 + ## Acceptance criteria 95 + - Same artifact and same recorded host inputs produce identical outputs across repeated runs.96 + - An ungranted capability import fails instantiation with diagnostics.97 + - Fuel exhaustion and memory ceilings surface as explicit plugin errors.98 + - Reload is atomic; failed reload preserves previous plugin state.99 + - `smith plugin check` rejects artifacts with ambient imports or growable memories.+0 / −2 text lines
16 16 license = "Apache-2.0" license = "Apache-2.0" 18 18 [workspace .dependencies ][workspace .dependencies ]19 - mlua = { version = "0.10" , features = ["luajit" , "vendored" , "serialize" ] }
21 19 serde = { version = "1" , features = ["derive" ] }serde = { version = "1" , features = ["derive" ] }22 20 serde_json = { version = "1" , features = ["preserve_order" ] }serde_json = { version = "1" , features = ["preserve_order" ] }23 21 tokio = { version = "1" , features = ["full" ] }tokio = { version = "1" , features = ["full" ] }