repositories / smith

smith

There are many coding harnesses - but this one is fast

owned by bugabinga

docs(system): complete plugin world surface, record wasm limitations, defer SDK

7a0a90d237c71949b882cbff3c47d2cd26d54fc3

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (3)

+48 / −2 text lines

Diff layout

.system/plans/SMH-PLAN-PLUG0001-plugin-harness/index.md

Modified

+2 / −1 text lines

32326. **Capability effects**: guests reach host effects only through granted imports — HTTP via net-scope, credential exchange via secret-proxy, logging; ungranted imports fail instantiation.
33337. **Registration surface**: plugins register provider streams, credential sources, and model contributions; the host pulls stream chunks by explicit request.
34348. **Generations and reload**: one complete generation publishes atomically; provider rounds pin one generation; reload keeps session continuity.
359. **Scaffolding**: `smith-plugin-sdk` crate pins the WIT and bindgen types; `plugins/` workspace members build components under the same gates; dev-links load fresh artifacts from the target directory.
359. **Scaffolding**: a workspace-pinned WIT copy is the single contract; `plugins/` members bind with raw `wit-bindgen` and build components under the same gates; dev-links load fresh artifacts from the target directory; no smith-authored SDK ships before 1.0.
363610. **Embedded built-ins**: release binaries embed system plugin artifacts and load them through the same loader, sandbox, and effect grants as user plugins.
373711. **Tooling**: `smith plugin init|build|check|dev|test` scaffold, produce artifacts, lint worlds and grants, hot-swap via dev-links, and run hosted tests with mocked capabilities.
6969- Failed load or reload leaves no registrations; reload preserves session continuity.
7070- One generation serves a provider round end to end.
7171- `plugins/` members pass the same fmt, clippy, test, and arch gates as core crates.
72- Raw `wit-bindgen` guests build and load with no smith-authored SDK in the tree.
7273- `cargo x dev` loads a freshly built component through a dev-link without manual steps.
7374- Embedded built-in artifacts pass the same validation as installed plugins.
7475- Repeated runs of one artifact with recorded host inputs produce identical outputs.

.system/research/SMH-RESEARCH-TBKDJHVX-plugin-api-standard-library-lessons/index.md

Modified

+28 / −0 text lines

143143- Interface-first authoring: a plugin's manifest and world exports are authored like an `.mli` — the contract is the product, the implementation is replaceable.
144144- This is already SPEC0001 law (module contracts, zero/one/many implementations, major-version binding); the research reinforces it: the binding model is the ecosystem's load-bearing wall, not a convenience.
146## Wasm boundary limitations
148Verified constraints and design consequences for the world:
150| limitation | consequence | mitigation |
151|---|---|---|
152| no generic signatures | contracts name concrete types | SDK-layer generics deferred past 1.0; world stays concrete |
153| no closures or function values | callbacks impossible | named imports; host pulls chunks and re-invokes renewal |
154| no trait objects | no boundary polymorphism | resources with methods are the polymorphism unit; module contracts are resources |
155| values cross by copy | chatty APIs cost | batched calls, explicit buffers |
156| no shared memory | no host–guest aliasing | generation law; copies only |
157| fuel cannot interrupt host calls | guest fuel ≠ host timeout | host effects carry own deadlines and cancellation |
158| 32-bit memories | 4 GiB per instance | ceilings law |
159| traps poison the instance | guest panic unrecoverable | typed results for ordinary failures; generation reload for traps |
160| `result<T, E>` only | no exception propagation | precise variant error sets |
161| no variadics or defaults | rigid signatures | none needed if world stays small; SDK optional later |
162| no structural subtyping | version tolerance must be designed | additive-only worlds plus unknown catch-all |
163| guest threads experimental | no intra-guest parallelism | host-orchestrated concurrency law |
164| async types stabilizing | unstable to depend on | explicit pull model; never await guest futures |
165| component-to-component linking complicates ownership | plugin-to-plugin design choice | route through host effects; keep grants, fuel, generations coherent |
166| instantiation cost | per-call spin-up is real | instantiate at registration; pool instances |
168Rust guests keep full generics internally through monomorphization; only signatures crossing the boundary are concrete.
169Bindgen maps WIT types to idiomatic guest types per language; unknown future data travels as a tagged `list<u8>` inside the catch-all variant.
171SDK stance: no smith-authored SDK before 1.0; the world must be complete and comfortable through raw bindgen guests alone, and an SDK stays optional forever after.
146173## Synthesis: rules for the smith:plugin world
1481751. Minimal total surface; every interface needs two real consumers before entering the world (Zig, Lua).
15718410. World version bumps are computed from API diffs, not asserted by authors (Elm mechanical semver).
15818511. Interfaces are the ecosystem unit: contracts publish, implementations swap, binding is explicit (OCaml, Java Collections).
15918612. Mechanisms, not policies: no world interface encodes a workflow (Lua).
18713. World-first: the WIT world is the only API; no smith-authored SDK ships before 1.0, and an SDK stays optional forever — comfort through raw bindgen is a design requirement.
161189## Sources

.system/specs/SMH-SPEC-PLUG0001-plugin-system/index.md

Modified

+18 / −1 text lines

@@ -125,7 +125,24 @@ World surface
126126## World surface
128Incomplete: the `smith:plugin` world's interface design follows the wasm-limitation review and the research synthesis rules (minimal surface, one grammar, tiny contracts, explicit parameters, two-layer core-plus-grants, mechanical versioning).
128The `smith:plugin` world is the entire plugin API.
129No non-WIT construct is required to build or consume a plugin; raw `wit-bindgen` guests are first-class before and after any SDK exists.
131Design laws:
133- Two layers: a core world every plugin sees, plus granted capability interfaces — HTTP via net-scope, credential exchange via secret-proxy, logging — imported only with matching grants.
134- One naming grammar, one error grammar, one documentation shape across all interfaces.
135- One-purpose interfaces; an interface needs two real consumers before entering the world.
136- Explicit parameters: buffers, bounds, cancellation, and provenance are arguments, never ambient state.
137- Precise failure sets: typed result variants per operation family; no single generic error case.
138- Resources are the polymorphism unit: module contracts are resource types, implementations export constructors, the host mediates binding.
139- Pull, never callback: the host pulls chunks and re-invokes renewal; function values never cross the boundary.
140- Plugin-to-plugin calls route through host effects; guests never link each other directly.
141- Values cross by copy: calls are batched; chatty interfaces fail review.
142- Evolution is additive-only with an unknown catch-all; world versions are computed from interface diffs, not asserted by authors.
143- No SDK requirement: a smith-authored SDK may add ergonomics after 1.0; the world alone stays complete and comfortable without it.
145Guest languages: Rust first, TypeScript via jco as maintained compatibility target, per `SMH-SPEC-WASM0001`.
130147## Acceptance criteria