docs(system): research plugin api standard library lessons
ce1aa6a6f3aa8f57d73c99c3464af81f8a8001f6
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
- Parent 1: bdde5762996c
There are many coding harnesses - but this one is fast
ce1aa6a6f3aa8f57d73c99c3464af81f8a8001f6
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
+57 / −0 text lines
new file mode 100644+57 / −0 text lines
---id: SMH-RESEARCH-TBKDJHVXtype: researchtitle: "Plugin API Standard Library Lessons"---# Plugin API Standard Library LessonsGrounding for the `smith:plugin` world: extract the core of wisdom from respected standard libraries, adapted to a wasm component guest surface.Facts and conclusions are candidates, not mandates.## Per-library lessons| library | extract | reject or guard ||---|---|---|| [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 || [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) || [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 || [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 || [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 || [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 || [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 |## Synthesis: rules for the smith:plugin world1. Minimal total surface; every interface must justify itself against two real consumers before entering the world.2. One naming grammar, one error grammar, one documentation shape across all interfaces — homogeneity is a feature.3. Tiny universal contracts (Reader/Writer shapes) over wide interfaces; compose in guests, not in the host world.4. Explicit over implicit: buffers, bounds, cancellation, and provenance are parameters, never ambient state.5. Vocabulary types with impossible-to-misuse constructors; result variants name failure precisely.6. Additive-only evolution; deprecations need a replacement and a removal path from the first release.7. Performance is part of the contract: batched calls, explicit budgets, no hidden allocation or copying requirements.8. Ecosystem over API: interfaces are publishable module contracts; implementations are swappable and bound explicitly.## Mapping notes- WIT has no generics: Zig/Go composability becomes plain functions over shared record types and resource handles.- Elm intuitiveness transfers directly to naming and organization review.- Rust API guidelines become the review checklist for every world change.- The OCaml lesson is already law in SPEC0001 (Discovery and modules); this research reinforces it, does not replace it.## Sources- Lua 5.4 reference manual — <https://www.lua.org/manual/5.4/>- Java SE API — <https://docs.oracle.com/en/java/javase/21/docs/api/java.base/module-summary.html>- Go io package — <https://pkg.go.dev/io>- Zig io guide — <https://zig.guide/standard-library/io>- Elm core and style guide — <https://package.elm-lang.org/packages/elm/core/latest/>, <https://elm-lang.org/docs/style-guide>- Rust std and API guidelines — <https://doc.rust-lang.org/std/>, <https://rust-lang.github.io/api-guidelines/>- OCaml modules — <https://ocaml.org/manual/modules.html>- Component model and WIT — <https://component-model.design/>## Unresolved questions- Do Reader/Writer-style byte contracts belong in the world at all, or only in the HTTP and stream interfaces where chunks already flow?- Which failure vocabulary granularity survives WIT result variants before becoming Java-style exception taxonomies?- How do module contracts compose with world versioning: are plugin-published interfaces worlds of their own?