repositories / smith

smith

There are many coding harnesses - but this one is fast

owned by bugabinga

docs(system): research plugin api standard library lessons

ce1aa6a6f3aa8f57d73c99c3464af81f8a8001f6

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (1)

+57 / −0 text lines

Diff layout

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

Added
new file mode 100644

+57 / −0 text lines

1---
2id: SMH-RESEARCH-TBKDJHVX
3type: research
4title: "Plugin API Standard Library Lessons"
5---
6
7# Plugin API Standard Library Lessons
8
9Grounding for the `smith:plugin` world: extract the core of wisdom from respected standard libraries, adapted to a wasm component guest surface.
10Facts and conclusions are candidates, not mandates.
12## Per-library lessons
14| library | extract | reject or guard |
15|---|---|---|
16| [Lua 5.4](https://www.lua.org/manual/5.4/) | minimal surface, pragmatic verbs, one obvious way | thin mirror of Unix/C; no host OS vocabulary leaks into guests |
17| [Java stdlib](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/module-summary.html) | completeness through orthogonal primitives, documented contracts | irre removable mistakes: deprecate-and-delete discipline from day one; additive-only worlds (already WASM0001 law) |
18| [Go stdlib](https://pkg.go.dev/io) | scope discipline: each package answers one question; io.Reader/Writer as tiny universal contracts | inhomogeneous conventions between packages; one naming and error grammar across the whole world |
19| [Zig std.io](https://zig.guide/standard-library/io) | composable Reader/Writer, explicit buffers, performance as a design constraint | young and messy: no feature enters the world without two real consumers |
20| [Elm core](https://package.elm-lang.org/packages/elm/core/latest/) and the [style guide](https://elm-lang.org/docs/style-guide) | naming, organization, intuitiveness: `List.map` over `List.applyMappingFn`; small total surface; impossible-to-misuse functions; whole-ecosystem coherence | paradigm: no typeclasses in WIT; emulate composability with plain functions over records, not generics |
21| [Rust std](https://doc.rust-lang.org/std/) | vocabulary types (Option/Result shapes → explicit result variants in WIT), coherence, [API guidelines](https://rust-lang.github.io/api-guidelines/) checklist discipline | allocator and OS assumptions: guests get linear memory and host-provided effects only; no ambient std assumptions in world design |
22| [OCaml modules](https://ocaml.org/manual/modules.html) | published interfaces, many implementations, explicit binding | not an API-shape lesson: it is the plugin ecosystem model — already spec'd as module contracts with zero/one/many implementations and major-version binding |
24## Synthesis: rules for the smith:plugin world
261. Minimal total surface; every interface must justify itself against two real consumers before entering the world.
272. One naming grammar, one error grammar, one documentation shape across all interfaces — homogeneity is a feature.
283. Tiny universal contracts (Reader/Writer shapes) over wide interfaces; compose in guests, not in the host world.
294. Explicit over implicit: buffers, bounds, cancellation, and provenance are parameters, never ambient state.
305. Vocabulary types with impossible-to-misuse constructors; result variants name failure precisely.
316. Additive-only evolution; deprecations need a replacement and a removal path from the first release.
327. Performance is part of the contract: batched calls, explicit budgets, no hidden allocation or copying requirements.
338. Ecosystem over API: interfaces are publishable module contracts; implementations are swappable and bound explicitly.
35## Mapping notes
37- WIT has no generics: Zig/Go composability becomes plain functions over shared record types and resource handles.
38- Elm intuitiveness transfers directly to naming and organization review.
39- Rust API guidelines become the review checklist for every world change.
40- The OCaml lesson is already law in SPEC0001 (Discovery and modules); this research reinforces it, does not replace it.
42## Sources
44- Lua 5.4 reference manual — <https://www.lua.org/manual/5.4/>
45- Java SE API — <https://docs.oracle.com/en/java/javase/21/docs/api/java.base/module-summary.html>
46- Go io package — <https://pkg.go.dev/io>
47- Zig io guide — <https://zig.guide/standard-library/io>
48- Elm core and style guide — <https://package.elm-lang.org/packages/elm/core/latest/>, <https://elm-lang.org/docs/style-guide>
49- Rust std and API guidelines — <https://doc.rust-lang.org/std/>, <https://rust-lang.github.io/api-guidelines/>
50- OCaml modules — <https://ocaml.org/manual/modules.html>
51- Component model and WIT — <https://component-model.design/>
53## Unresolved questions
55- Do Reader/Writer-style byte contracts belong in the world at all, or only in the HTTP and stream interfaces where chunks already flow?
56- Which failure vocabulary granularity survives WIT result variants before becoming Java-style exception taxonomies?
57- How do module contracts compose with world versioning: are plugin-published interfaces worlds of their own?