Skip to content

feat(ast): minimal WASI env for native plugins#45

Merged
Houseofmvps merged 1 commit into
Houseofmvps:mainfrom
the-wondersmith:feat/wasi-plugin-host
Jun 27, 2026
Merged

feat(ast): minimal WASI env for native plugins#45
Houseofmvps merged 1 commit into
Houseofmvps:mainfrom
the-wondersmith:feat/wasi-plugin-host

Conversation

@the-wondersmith

Copy link
Copy Markdown
Contributor

PR builds from #44, correcting a too-narrow contract for native plugin imports.

Under the initial ABI defined in the base machinery PR, plugins written in languages like Go would be a major pain to write or build. Using Node's built-in WASI support ameliorates that issue while still maintaining the existing zero-dependency standard.

Always instantiate WASM plugins with a node:wasi import object on a single
path: no-imports modules (Rust/AssemblyScript) ignore the extras, while
runtimes that need WASI (e.g. Go //go:wasmexport reactors) get a minimal,
capability-restricted environment — no filesystem, no network, no args/env —
and are initialized via _initialize when present. node:wasi is built in, so
this preserves the zero-dependency constraint; it's loaded lazily (so it
isn't pulled in when native AST is off) and its one-time ExperimentalWarning
is filtered out. Unblocks full-stdlib-language plugins (Go's go/parser)
without changing the per-kind ABI.
@the-wondersmith

Copy link
Copy Markdown
Contributor Author

@Houseofmvps AI Context update failed, but I don't think it's anything to do with the branch/PR specifically

@the-wondersmith

Copy link
Copy Markdown
Contributor Author

Just to keep track of the remaining follow-ups:

Each branch builds directly on the previous -

  1. feat/wasi-plugin-host (this PR)

  2. feat/native-ast-generalization (+4 commits) — makes dispatch language-driven rather than hardcoded. Plugins self-describe via a describe() export (languageId + file extensions); a registry routes files by extension; the built-in detectors fold into a single generic pass with additive-vs-authoritative merge and --native-ast=all|none|<ids>. Net result: any user-declared language works, not just the existing built-ins.

  3. wip/initial-wasm-ast-plugins (+4 commits) — actual working plugins for Rust, Python, and Go (under plugins/ast/), plus a CI workflow that builds them, shrinks them with wasm-opt, smoke-tests each against the host ABI, and publishes the .wasm + checksums as release assets on plugins-v* tags. The npm package neither builds nor ships them.

Intended merge order: this PRfeat/native-ast-generalizationwip/initial-wasm-ast-plugins.

And again, the last one (wip/initial-wasm-ast-plugins) completes the "picture" of the whole chain of PRs/branches, but details will need to be worked out about where/how plugins live, are built, and delivered and so will require the most scrutiny/conversation.

@Houseofmvps
Houseofmvps merged commit 6c50119 into Houseofmvps:main Jun 27, 2026
2 of 3 checks passed
Houseofmvps added a commit that referenced this pull request Jun 27, 2026
Ships PR #45 (minimal WASI env for native plugins) to npm.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Houseofmvps

Copy link
Copy Markdown
Owner

Merged and shipped in codesight@1.17.0 on npm. 🚀

Genuinely top-tier contribution, thank you. A few things that stood out on review:

  • Right diagnosis, minimal fix. Widening the ABI from "no imports" to "minimal WASI" is exactly the smallest change that unblocks full-runtime languages (Go //go:wasmexport reactors) without touching the per-kind contract. No over-reach.
  • Security-conscious by construction. new WASI({ version: "preview1" }) with no preopens means no filesystem, preview1 has no socket-create so no outbound network, and args/env stay empty. The sandbox stays as tight as the empty-imports version for everything that matters — verified that here before merging.
  • Constraint-aware. Reaching for the built-in node:wasi to keep the zero-dependency guarantee intact, lazy-loading it so it's never pulled in when native AST is off, and scoping the emitWarning filter to only the WASI ExperimentalWarning (every other warning passes through) — that's the kind of detail most PRs miss.
  • Single instantiation path that both no-import (Rust/AS) and reactor (Go) modules flow through, with _initialize handled correctly. Clean.
  • The roadmap comment laying out the stacked chain, intended merge order, and an honest "the last one needs the most scrutiny" call-out is excellent maintainer communication.

Looking forward to feat/native-ast-generalization next — open it whenever you're ready and I'll review on the same terms.

@the-wondersmith
the-wondersmith deleted the feat/wasi-plugin-host branch June 27, 2026 22:22
@the-wondersmith

Copy link
Copy Markdown
Contributor Author

@Houseofmvps

Merged and shipped in codesight@1.17.0 on npm. 🚀

Genuinely top-tier contribution, { ... }

{ ... } Looking forward to feat/native-ast-generalization next — open it whenever you're ready and I'll review on the same terms.

Opened 🎉

Houseofmvps pushed a commit that referenced this pull request Jun 28, 2026
Final PR in the #44#45#46 native-AST stack. Adds canonical Rust (syn), Python (ruff), and Go (go/parser) WASM plugins under plugins/ast/, plus the ast-plugins CI workflow that builds, smoke-tests against the host ABI, and publishes them on plugins-v* tags.

Reviewed safe: strictly additive (0 deletions), no TS/src/dist/package.json changes, npm tarball still excludes plugins/ (verified via npm pack), plugins do no I/O/network/process/fs (pure AST parsers in sandboxed WASM), deps reputably pinned (syn, ruff@SHA, Go stdlib), CI least-privilege with release gated to maintainer tags. All functional checks pass; only failure is the known fork-PR read-only-token artifact.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants