repositories / smith

smith

There are many coding harnesses - but this one is fast

owned by bugabinga

docs(system): replace lua plugin law with wasm component runtime

c363c47eca45822bc3e4c7805a0065a7f7bb4ea4

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare 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)

+352 / −84 text lines

Diff layout

.system/MISSION.md

Modified

+2 / −2 text lines

99- JSON-RPC stdio mode,
1010- provider-independent agent loop,
1111- deterministic CBOR sessions and replay,
12- Lua plugin system,
12- wasm component plugin system,
1313- built-in coding tools exposed through the same plugin API as user tools.
15Core bet: Rust owns performance and safety; Lua owns user extension, layout, prompts, tools, themes, and keybindings.
15Core bet: Rust owns performance and safety; sandboxed wasm components own user extension, layout, prompts, tools, themes, and keybindings.

.system/RULES.md

Modified

+5 / −5 text lines

1313- Latest stable Rust, edition 2024.
1414- No numeric MSRV unless release policy creates one.
1515- Nightly only for pinned cargo-pup architecture gate.
16- mlua plus LuaJIT.
16- wasmtime plus WIT components for plugins.
1717- CBOR sessions.
1818- XDG dirs.
1919- jj VCS.
2020- Secret proxy, no keychain dependency.
2121- 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.
2525## Authority
5151## Architecture
5353```text
54smith/ shared types, StreamFn, AgentTool, config, Lua runtime, errors
54smith/ shared types, StreamFn, AgentTool, config, errors
5555smith-core/ agent loop, sessions, tools, hooks, compaction, cost, trace, replay
5656smith-ai/ providers, auth, model registry, provider streams, MuxProvider
5757smith-tui/ terminal events, widgets, layout primitives, render loop, themes
58smith-harness/ orchestration, plugin system, SDK, event bridge, built-ins, help
58smith-harness/ orchestration, wasm plugin host, plugin system, SDK, event bridge, built-ins, help
5959smith-cli/ binary entry point, CLI, session commands, eval/rpc/replay
6060xtask/ cargo-only automation
6161```

.system/phases/SMH-PHASE-LUAH0001-extensible-product/index.md

Modified

+1 / −1 text lines

1010## Operating posture
12Make Lua extension the normal product path across Smith.
12Make plugin extension the normal product path across Smith.
1313Prioritize one sandboxed loading model for built-in and user behavior, with Rust limited to safe primitives.
1515## Transition signal

.system/phases/SMH-PHASE-TUIR0001-interactive-product/index.md

Modified

+1 / −1 text lines

1010## Operating posture
1212Make terminal interaction and historical state first-class across Smith.
13Prioritize consistent live and replayed views, Lua-owned layout, and controlled VCS operations.
13Prioritize consistent live and replayed views, plugin-owned layout, and controlled VCS operations.
1515## Transition signal

.system/plans/SMH-PLAN-LUAH0001-lua-harness-and-plugins/index.md

Deleted
deleted file mode 100644

+0 / −55 text lines

1---
2id: SMH-PLAN-LUAH0001
3type: plan
4title: "Sandboxed Plugin Harness"
5spec: SMH-SPEC-SPEC0001
6status: draft
7depends_on: [SMH-PLAN-AIAG0001]
8---
9
10# Sandboxed Plugin Harness
12## Entry
14- Eval and RPC use the shared provider-independent runtime.
15- Agent, tool, provider, and session events are typed and ordered.
17## Order
191. Add project trust resolution before project executable configuration or package discovery.
202. Add the restricted Lua runtime and trusted source validation boundary.
213. Add convention-based package, module contract, and implementation discovery.
224. Add deterministic module binding, ambiguity diagnostics, and plugin precedence.
235. Add typed SDK namespaces for filesystem, search, tools, commands, providers, UI, VCS, logging, and lifecycle control.
246. Bridge runtime events and plugin results without exposing internal ownership.
257. Load each plugin into a transactional registration set so failure leaves no active residue.
268. Route built-in commands, presentation, themes, keybindings, prompts, and workflows through the same loader.
279. Add atomic reload with rollback and preserved session continuity.
2810. Wire trusted global, project, and explicit plugin sources into the harness.
30## Interfaces
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.
37## Verification
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.
47## Exit
49The harness operates through the public sandboxed plugin surface with explicit project trust and no privileged built-in path.
51## Stop conditions
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

1---
2id: SMH-PLAN-PLUG0001
3type: plan
4title: "Sandboxed Plugin Harness"
5spec: SMH-SPEC-SPEC0001
6status: draft
7depends_on: [SMH-PLAN-AIAG0001]
8research: [SMH-RESEARCH-WASM0001]
9---
11# Sandboxed Plugin Harness
13## Entry
15- Eval and RPC use the shared provider-independent runtime.
16- Agent, tool, provider, and session events are typed and ordered.
18## Order
201. Add project trust resolution before project executable configuration or package discovery.
212. Add the wasm host: engine config, artifact validation, determinism knobs, fuel and memory ceilings.
223. Add manifest-based package discovery with contract version and capability requests.
234. Add deterministic module binding, ambiguity diagnostics, and plugin precedence.
245. Add the typed `smith:plugin` WIT world covering filesystem, search, tools, commands, providers, UI, VCS, logging, and lifecycle control.
256. Bridge runtime events and plugin results without exposing internal ownership.
267. Load each plugin into a transactional registration set so failure leaves no active residue.
278. Route built-in commands, presentation, themes, keybindings, prompts, and workflows through the same loader.
289. Add atomic reload with rollback and preserved session continuity.
2910. Wire trusted global, project, and explicit plugin sources into the harness.
3011. Add plugin tooling: init, build, check, dev watch with hot swap, test harness with mocked capabilities.
32## Interfaces
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.
39## Verification
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.
51## Exit
53The harness operates through the public sandboxed plugin surface with explicit project trust and no privileged built-in path.
55## Stop conditions
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

1717## Order
19191. Complete provider catalog ingestion, provenance, conflict reporting, cached fallback, and human review flow.
202. Generate Lua SDK help from the authoritative typed declarations and usage descriptions.
213. Verify public Rust, Lua, event, command, and configuration documentation for completeness and drift.
202. Generate plugin SDK help from the authoritative contract declarations and usage descriptions.
213. Verify public Rust, plugin, event, command, and configuration documentation for completeness and drift.
22224. Complete architecture, lint, format, test, documentation, audit, coverage, mutation, and benchmark gates through Cargo automation.
23235. Harden provider streams, compaction, session recovery, plugin rollback, project trust, terminal restoration, RPC framing, and tool cancellation against recorded edge cases.
24246. 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

44title: "Fullscreen TUI and Replay"
55spec: SMH-SPEC-SPEC0001
66status: draft
7depends_on: [SMH-PLAN-LUAH0001]
7depends_on: [SMH-PLAN-PLUG0001]
88---
1010# Fullscreen TUI and Replay
20202. Add conservative capability detection, bounded probes, explicit overrides, and plain-terminal fallback.
21213. Add normalized keyboard, paste, mouse, resize, and focus events.
22224. Add deterministic widget, overlay, theme, and layout primitives in `smith-tui`.
235. Add structured Lua render descriptions and the default fullscreen layout.
235. Add structured plugin render descriptions and the default fullscreen layout.
24246. Add an independently scrollable transcript with sticky-bottom control and explicit jump to latest.
25257. Add stable search, selection, link activation, viewport navigation, and focus routing.
26268. Add replay reconstruction, seek, speed, range, and comparison over session and trace inputs.
27279. Add structured VCS snapshot, diff, restore, undo, redo, and time-travel primitives.
2810. Expose replay and VCS workflows through built-in Lua plugins.
2810. Expose replay and VCS workflows through built-in plugins.
3030## Interfaces
3232- `smith-tui::terminal`: fullscreen lifecycle and capabilities.
3333- `smith-tui::event`: normalized input independent of terminal quirks.
3434- `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.
3636- Replay: recorded state to deterministic render model.
3737- VCS SDK: validated history queries and mutations.
5555## Stop conditions
5757- 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.
5959- 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

1---
2id: SMH-RESEARCH-WASM0001
3type: research
4title: "Embedded language: wasm components"
5---
6
7# Embedded language: wasm components
8
9## Question
11Replace the planned mlua + LuaJIT plugin runtime with wasmtime + WIT components?
13Requirements:
15- perf
16- type safety
17- tooling
18- ecosystem reuse
19- sandbox (RULES: plugins run sandboxed)
20- determinism (MISSION: CBOR sessions, replay)
22## Candidate matrix
24Scores 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 |
34Decision (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
45Facts:
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.
53Candidates:
55- wasmtime: primary. Components + determinism knobs + resource limiters.
56- wasmi: fallback only if binary size or build time becomes blocking; loses component model.
58To measure on target device (aarch64 termux):
60- release build time delta, mlua/luajit out vs wasmtime in
61- binary size delta
62- layout callback batch latency
64## Determinism knobs (wasmtime)
66From 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.
75Candidate policy:
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.
83## Sandbox model
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)
92Not binding. Spec phase decides.
94```wit
95package smith:plugin@0.1.0;
97world smith-plugin {
98 import host; // log, granted caps: fs-scope, net-scope, secret-proxy
99 export init; // manifest-driven
100 export tools; // list, describe, invoke (recorded io)
101 export layout; // frame batch in, layout batch out
102 export themes;
103 export prompts;
104 export keymap; // predicates + bindings
105}
106```
108## Boundary cost
110- 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).
116## Guest toolchain
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.
123## Zed precedent
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.
129## Open questions
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
1391. wasmtime + WIT, Rust-only guests v1. → spec SMH-SPEC-WASM0001.
1402. No ambient WASI. Host capabilities via WIT imports only.
1413. Fuel metering, NaN canonicalization, no relaxed SIMD, max==min memories.
1424. Layout API = batched frame interface.
1435. Drop mlua, mlua-pkg from root Cargo.toml (needs human approval: root Cargo.toml is human-owned). → applied 2026.
1446. Concurrency: defer implementation, pin model now. One instance = single-threaded actor; parallelism = host-orchestrated lanes; intra-guest threads rejected.
1457. 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.
1468. Additional guest languages cost a scaffold template + bindgen only; host unchanged. js/ts via jco, go, python are first candidates.
1479. Plugin identity = artifact + KDL manifest; artifact content hash pinned in session traces. Runtime never sees source; provenance optional.
14810. No recompilation at load time. Old artifacts keep running across additive world updates; EOL artifacts fail with explicit rebuild path.
14911. Diagnostics contract: every lifecycle stage names stage, cause, fix. No heuristic errors.
15012. 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.
15113. TypeScript via jco = compatibility canary in CI from v1. Prevents rust coupling: WIT ergonomics, promise interop, fuel ceilings, memory preallocation, language-pluggable tooling.
15214. To measure on jco canary: artifact size, quickjs fuel burn ratio, componentize-js memory preallocation vs max==min.
154## Links
156- wasmtime deterministic execution: https://docs.wasmtime.dev/examples-deterministic-wasm-execution.html
157- wasmtime security: https://docs.wasmtime.dev/security.html
158- 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-component
161- zed extensions: https://zed.dev/blog/zed-decoded-extensions
162- 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

22id: SMH-SPEC-SPEC0001
33type: spec
44title: "Smith Specification"
5research: [SMH-RESEARCH-FNY87IGJ]
5research: [SMH-RESEARCH-FNY87IGJ, SMH-RESEARCH-WASM0001]
66---
88# Smith Specification
1010## Intent
12Smith is a fast Rust coding-agent TUI with Lua-owned customization.
12Smith is a fast Rust coding-agent TUI with plugin-owned customization.
1313It provides one provider-independent agent runtime across interactive, eval, JSON-RPC, and replay modes.
1515## Scope
2222- deterministic CBOR sessions and replay,
2323- provider and model selection,
2424- built-in coding tools,
25- sandboxed Lua plugins,
25- sandboxed plugins,
2626- VCS-backed history and recovery,
2727- generated SDK help.
3131## Product boundaries
3333- 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.
3535- Built-in and user-visible extension behavior use the same plugin contracts.
3636- Provider details do not enter the agent, session, tool, plugin, or interface contracts.
3737- Interface modes share one runtime behavior rather than reimplementing the agent loop.
205205## Plugins and configuration
207Lua plugins run in a restricted runtime without direct operating-system, filesystem, environment, or debug libraries.
207Plugins run in a restricted runtime without direct operating-system, filesystem, environment, network, or clock access.
208Plugin execution is resource-bounded.
208209Host effects are available only through typed Smith SDK functions.
209210Built-in plugins have no privileged effect path.
227228### Discovery and modules
229Version 1 discovers plugin packages and module contracts by path convention without requiring manifests.
230Package and module identities are deterministic and validated before execution.
230Version 1 discovers plugin packages by path convention.
231Each package carries a manifest declaring its plugin artifact, contract version, and requested capabilities.
232Package and artifact identities are deterministic and validated before execution.
233Artifacts failing validation never execute.
232235A module can have zero, one, or multiple implementations.
233236One implementation binds automatically.
244247Non-interactive modes require an explicit or previously persisted decision to load project-local executable behavior.
245248Ignoring untrusted project behavior produces a visible diagnostic.
247Trust does not remove the Lua sandbox or tool boundaries.
250Trust does not remove the plugin sandbox or tool boundaries.
249252### Configuration
254Configuration is expressed in KDL.
251255Configuration has deterministic precedence:
2532571. product defaults,
277281- shutdown restores terminal state after normal exit, error, abort, or signal.
279283Rust supplies deterministic widgets and layout primitives.
280Lua selects product layout and presentation.
284Plugins select product layout and presentation.
281285Structured render descriptions cannot emit arbitrary terminal control sequences.
283287Terminal capabilities are detected conservatively and can be overridden explicitly.
315319## Documentation and help
317Public Rust and Lua APIs are documented.
318Lua SDK declarations are the source for generated plugin help.
321Public Rust and plugin SDK APIs are documented.
322Plugin SDK declarations are the source for generated plugin help.
319323Every public event and function has one discoverable usage description.
320324Generated 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

1---
2id: SMH-SPEC-WASM0001
3type: spec
4title: "Wasm Plugin Runtime"
5research: [SMH-RESEARCH-WASM0001]
6---
7
8# Wasm Plugin Runtime
9
10## Intent
12SPEC0001 plugin contracts implemented with wasm components on an embedded wasmtime host.
14## Engine
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.
23## Capabilities
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.
30## Calls
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.
38## Lifecycle
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.
56## Guests
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.
61## Diagnostics
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.
68## Concurrency
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.
76## Versioning
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.
84## Tooling
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.

Cargo.toml

Modified

+0 / −2 text lines

1616license = "Apache-2.0"
1818[workspace.dependencies]
19mlua = { version = "0.10", features = ["luajit", "vendored", "serialize"] }
20mlua-pkg = "0.2"
2119serde = { version = "1", features = ["derive"] }
2220serde_json = { version = "1", features = ["preserve_order"] }
2321tokio = { version = "1", features = ["full"] }