|
43 | 43 | ## C Library Vendoring Policy |
44 | 44 |
|
45 | 45 | - NEVER commit third-party C library source code directly into this repo |
46 | | -- **unmodified upstream libraries** (sqlite3, zlib, minizip, cJSON, etc.) must be downloaded at build time from their official release URLs — add a Makefile target in `wasmvm/c/Makefile` under `fetch-libs` |
| 46 | +- **unmodified upstream libraries** (sqlite3, zlib, minizip, cJSON, etc.) must be downloaded at build time from their official release URLs — add a Makefile target in `native/wasmvm/c/Makefile` under `fetch-libs` |
47 | 47 | - **modified libraries** (e.g., libcurl with WASI patches) must live in a fork under the `rivet-dev` GitHub org (e.g., `rivet-dev/secure-exec-curl`) — the Makefile downloads from the fork's archive URL |
48 | | -- all downloaded library sources go in `wasmvm/c/libs/` which is gitignored — they are fetched by `make fetch-libs` and cached in `wasmvm/c/.cache/` |
| 48 | +- all downloaded library sources go in `native/wasmvm/c/libs/` which is gitignored — they are fetched by `make fetch-libs` and cached in `native/wasmvm/c/.cache/` |
49 | 49 | - when adding a new C library dependency: (1) add its download URL and Makefile target to `fetch-libs`, (2) add `libs/<name>` to the appropriate `.gitignore`, (3) if WASI modifications are needed, create a `rivet-dev/secure-exec-<name>` fork first |
50 | 50 | - existing forks: `rivet-dev/secure-exec-curl` (libcurl with `wasi_tls.c` and `wasi_stubs.c`) |
51 | 51 |
|
|
54 | 54 | - the goal for WasmVM is full POSIX compliance 1:1 — every command, syscall, and shell behavior should match a real Linux system exactly |
55 | 55 | - WasmVM and Python are experimental surfaces in this repo |
56 | 56 | - all docs for WasmVM, Python, or other experimental runtime features must live under the `Experimental` section of the docs navigation, not the main getting-started/reference sections |
57 | | -- the WasmVM runtime requires standalone WASM binaries in `wasmvm/target/wasm32-wasip1/release/commands/` |
58 | | -- build them locally: `cd wasmvm && make wasm` (requires Rust nightly + wasm32-wasip1 target + rust-src component + wasm-opt/binaryen) |
59 | | -- the Rust toolchain is pinned in `wasmvm/rust-toolchain.toml` — rustup will auto-install it |
60 | | -- CI builds the binaries before tests; a CI-only guard test in `packages/runtime/wasmvm/test/driver.test.ts` fails if they're missing |
| 57 | +- the WasmVM runtime requires standalone WASM binaries in `native/wasmvm/target/wasm32-wasip1/release/commands/` |
| 58 | +- build them locally: `cd native/wasmvm && make wasm` (requires Rust nightly + wasm32-wasip1 target + rust-src component + wasm-opt/binaryen) |
| 59 | +- the Rust toolchain is pinned in `native/wasmvm/rust-toolchain.toml` — rustup will auto-install it |
| 60 | +- CI builds the binaries before tests; a CI-only guard test in `packages/secure-exec-wasmvm/test/driver.test.ts` fails if they're missing |
61 | 61 | - tests gated behind `skipIf(!hasWasmBinaries)` or `skipUnlessWasmBuilt()` will skip locally if binaries aren't built |
62 | | -- see `wasmvm/CLAUDE.md` for full build details and architecture |
| 62 | +- see `native/wasmvm/CLAUDE.md` for full build details and architecture |
63 | 63 |
|
64 | 64 | ## WasmVM Syscall Coverage |
65 | 65 |
|
66 | | -- every function in the `host_process` and `host_user` import modules (declared in `wasmvm/crates/wasi-ext/src/lib.rs`) must have at least one C parity test exercising it through libc |
67 | | -- when adding a new host import, add a matching test case to `wasmvm/c/programs/syscall_coverage.c` and its parity test in `packages/runtime/wasmvm/test/c-parity.test.ts` |
68 | | -- the canonical source of truth for import signatures is `wasmvm/crates/wasi-ext/src/lib.rs` — C patches and JS host implementations must match exactly |
69 | | -- C patches in `wasmvm/patches/wasi-libc/` must be kept in sync with wasi-ext — ABI drift between C, Rust, and JS is a P0 bug |
70 | | -- permission tier enforcement must cover ALL write/spawn/kill/pipe/dup operations — audit `packages/runtime/wasmvm/src/kernel-worker.ts` when adding new syscalls |
71 | | -- `PATCHED_PROGRAMS` in `wasmvm/c/Makefile` must include all programs that use `host_process` or `host_user` imports (programs linking the patched sysroot) |
| 66 | +- every function in the `host_process` and `host_user` import modules (declared in `native/wasmvm/crates/wasi-ext/src/lib.rs`) must have at least one C parity test exercising it through libc |
| 67 | +- when adding a new host import, add a matching test case to `native/wasmvm/c/programs/syscall_coverage.c` and its parity test in `packages/secure-exec-wasmvm/test/c-parity.test.ts` |
| 68 | +- the canonical source of truth for import signatures is `native/wasmvm/crates/wasi-ext/src/lib.rs` — C patches and JS host implementations must match exactly |
| 69 | +- C patches in `native/wasmvm/patches/wasi-libc/` must be kept in sync with wasi-ext — ABI drift between C, Rust, and JS is a P0 bug |
| 70 | +- permission tier enforcement must cover ALL write/spawn/kill/pipe/dup operations — audit `packages/secure-exec-wasmvm/src/kernel-worker.ts` when adding new syscalls |
| 71 | +- `PATCHED_PROGRAMS` in `native/wasmvm/c/Makefile` must include all programs that use `host_process` or `host_user` imports (programs linking the patched sysroot) |
72 | 72 |
|
73 | 73 | ## Terminology |
74 | 74 |
|
|
0 commit comments