|
33 | 33 | - check GitHub Actions test/typecheck status per commit to identify when a failure first appeared |
34 | 34 | - do not use `contract` in test filenames; use names like `suite`, `behavior`, `parity`, `integration`, or `policy` instead |
35 | 35 |
|
| 36 | +## Tool Integration Policy |
| 37 | + |
| 38 | +- NEVER implement a from-scratch reimplementation of a tool when the PRD specifies using an existing upstream project (e.g., codex, curl, git, make) |
| 39 | +- always fork, vendor, or depend on the real upstream source — do not build a "stub" or "demo" binary that fakes the tool's behavior |
| 40 | +- if the upstream cannot compile or link for the target, document the specific blockers and leave the story as failing — do not mark it passing with a placeholder |
| 41 | +- the PRD and story notes define which upstream project to use; follow them exactly unless explicitly told otherwise |
| 42 | + |
| 43 | +## C Library Vendoring Policy |
| 44 | + |
| 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` |
| 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/` |
| 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 | +- existing forks: `rivet-dev/secure-exec-curl` (libcurl with `wasi_tls.c` and `wasi_stubs.c`) |
| 51 | + |
36 | 52 | ## WASM Binary |
37 | 53 |
|
| 54 | +- the goal for WasmVM is full POSIX compliance 1:1 — every command, syscall, and shell behavior should match a real Linux system exactly |
38 | 55 | - WasmVM and Python are experimental surfaces in this repo |
39 | 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 |
40 | | -- the WasmVM runtime requires a WASM binary at `wasmvm/target/wasm32-wasip1/release/multicall.wasm` |
41 | | -- build it locally: `cd wasmvm && make wasm` (requires Rust nightly + wasm32-wasip1 target + rust-src component + wasm-opt/binaryen) |
| 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) |
42 | 59 | - the Rust toolchain is pinned in `wasmvm/rust-toolchain.toml` — rustup will auto-install it |
43 | | -- CI builds the binary before tests; a CI-only guard test in `packages/runtime/wasmvm/test/driver.test.ts` fails if it's missing |
44 | | -- tests gated behind `skipIf(!hasWasmBinary)` or `skipUnlessWasmBuilt()` will skip locally if the binary isn't built |
| 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 |
| 61 | +- tests gated behind `skipIf(!hasWasmBinaries)` or `skipUnlessWasmBuilt()` will skip locally if binaries aren't built |
45 | 62 | - see `wasmvm/CLAUDE.md` for full build details and architecture |
46 | 63 |
|
| 64 | +## WasmVM Syscall Coverage |
| 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) |
| 72 | + |
47 | 73 | ## Terminology |
48 | 74 |
|
49 | 75 | - use `docs-internal/glossary.md` for canonical definitions of isolate, runtime, bridge, and driver |
@@ -124,6 +150,8 @@ Follow the style in `packages/secure-exec/src/index.ts`. |
124 | 150 | - `docs/system-drivers/browser.mdx` — update when createBrowserDriver options change |
125 | 151 | - `docs/nodejs-compatibility.mdx` — update when bridge, polyfill, or stub implementations change; keep the Tested Packages section current when adding or removing project-matrix fixtures |
126 | 152 | - `docs/cloudflare-workers-comparison.mdx` — update when secure-exec capabilities change; bump "Last updated" date |
| 153 | + - `docs/posix-compatibility.md` — update when kernel, WasmVM, Node bridge, or Python bridge behavior changes for any POSIX-relevant feature (signals, pipes, FDs, process model, TTY, VFS) |
| 154 | + - `docs/wasmvm/supported-commands.md` — update when adding, removing, or changing status of WasmVM commands; keep summary counts current |
127 | 155 |
|
128 | 156 | ## Backlog Tracking |
129 | 157 |
|
|
0 commit comments