Files
sausage/spikes/s7-preview1-adapter/README.md
T
surma 5ce2a2f2bd vfs: host-side WASI preview1 over sausage-vfs (T11)
Preview1 state lives in the host, so Go modules (esbuild) work. esbuild bundles
byte-identical to native; uutils and QuickJS-ng file tests pass. The failed
guest-side adapter attempt (T7) moves to spikes/s7-preview1-adapter/.
2026-11-06 16:34:33 +00:00

54 lines
2.4 KiB
Markdown

# Preview1 command adapter experiment
This directory tests D39 with Go esbuild, uutils, and QuickJS.
The patch reserves the adapter state before the guest calls `_start`.
It retains both state sentinels and all WASI semantics.
## Build
From the repository root:
```sh
nix develop -c nu spikes/s7-preview1-adapter/build.nu
nix develop -c nu spikes/s7-preview1-adapter/test.nu
```
The build pins Wasmtime v49.0.2 to commit
`3c8a3e79aa3188a1a12b3aebbaa097abccceac92` and uses its Cargo.lock with `--locked`.
The repository flake pins the Rust toolchain through flake.lock.
The build requires the `wasm32-unknown-unknown` standard library.
T11 removed this target from the production flake after T7 disproved the patch.
To repeat this historical experiment, supply that target in a separate Rust toolchain.
It places sources, a persistent target directory, and the adapter under `/tmp/p1-adapter/`.
The test uses the S6 esbuild v0.27.7 module at `/tmp/s6-esbuild/esbuild.wasm`.
The S6 build recipe can create this input.
The test copies the S6 fixture into its own scratch directory and installs its locked dependencies.
It compares module and component bundles byte-for-byte and checks rendered elements with LinkeDOM.
It also adapts the lab's preview1 uutils and QuickJS modules.
These smoke tests check command arguments and stdout.
They do not check every utility or JavaScript feature.
The test requires these existing lab inputs:
- `/tmp/wasi-userland-lab/uu/coreutils-0.12.0-wasm32-wasip1/coreutils.wasm`
- `/tmp/wasi-userland-lab/qjs-wasi.wasm`
## Result
The eager-state patch does not fix esbuild.
The component traps during `--version` after Go overwrites the adapter state sentinels.
The uutils and QuickJS smoke tests pass.
The task report records the sentinel addresses and values.
`diagnostic.patch` is an alternative patch against the same pristine Wasmtime revision.
It includes the eager-state change and prints state sentinels before `_start` and upon corruption.
It does not disable assertions.
Do not apply both patches to one source tree.
The diagnostic build uses the same Cargo command as the normal build.
Use `wasm-tools component new` with its resulting adapter to reproduce the trace.
The eager-state change does not reserve its memory from Go's allocator.
Go starts its allocation cursor at the end of its static data, not at the current memory size.
The host-side adapter is the next planned approach under D39.