Skip to content

Commit 8277f7a

Browse files
committed
feat: US-016 - Update all path references for native/ restructure
1 parent 596eeac commit 8277f7a

17 files changed

Lines changed: 151 additions & 80 deletions

File tree

.github/workflows/ci.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ jobs:
3030
uses: actions/cache@v4
3131
with:
3232
path: |
33-
wasmvm/target
34-
wasmvm/vendor
35-
key: wasm-${{ runner.os }}-${{ hashFiles('wasmvm/Cargo.lock', 'wasmvm/rust-toolchain.toml') }}
33+
native/wasmvm/target
34+
native/wasmvm/vendor
35+
key: wasm-${{ runner.os }}-${{ hashFiles('native/wasmvm/Cargo.lock', 'native/wasmvm/rust-toolchain.toml') }}
3636

3737
- name: Build WASM binary
3838
run: cd wasmvm && make wasm
@@ -42,28 +42,28 @@ jobs:
4242
id: cache-wasi-sdk
4343
uses: actions/cache@v4
4444
with:
45-
path: wasmvm/c/vendor/wasi-sdk
45+
path: native/wasmvm/c/vendor/wasi-sdk
4646
key: wasi-sdk-25-${{ runner.os }}-${{ runner.arch }}
4747

4848
- name: Download wasi-sdk
4949
if: steps.cache-wasi-sdk.outputs.cache-hit != 'true'
50-
run: make -C wasmvm/c wasi-sdk
50+
run: make -C native/wasmvm/c wasi-sdk
5151

5252
- name: Cache patched wasi-libc sysroot
5353
id: cache-sysroot
5454
uses: actions/cache@v4
5555
with:
5656
path: |
57-
wasmvm/c/sysroot
58-
wasmvm/c/vendor/wasi-libc
59-
key: wasi-libc-sysroot-${{ runner.os }}-${{ hashFiles('wasmvm/patches/wasi-libc/*.patch', 'wasmvm/scripts/patch-wasi-libc.sh') }}
57+
native/wasmvm/c/sysroot
58+
native/wasmvm/c/vendor/wasi-libc
59+
key: wasi-libc-sysroot-${{ runner.os }}-${{ hashFiles('native/wasmvm/patches/wasi-libc/*.patch', 'native/wasmvm/scripts/patch-wasi-libc.sh') }}
6060

6161
- name: Build patched wasi-libc sysroot
6262
if: steps.cache-sysroot.outputs.cache-hit != 'true'
63-
run: make -C wasmvm/c sysroot
63+
run: make -C native/wasmvm/c sysroot
6464

6565
- name: Build C test fixtures (WASM + native)
66-
run: make -C wasmvm/c programs native
66+
run: make -C native/wasmvm/c programs native
6767

6868
# --- Node.js / TypeScript ---
6969
- name: Set up pnpm

.github/workflows/pkg-pr-new.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050

5151
- name: Build linux-x64 binary via Docker
5252
run: |
53-
cd crates/v8-runtime
53+
cd native/v8-runtime
5454
docker build -f docker/Dockerfile.linux-x64-gnu -o type=local,dest=npm/linux-x64-gnu .
5555
5656
- name: Publish to pkg.pr.new

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454

5555
- name: Build linux-x64 binary via Docker
5656
run: |
57-
cd crates/v8-runtime
57+
cd native/v8-runtime
5858
docker build -f docker/Dockerfile.linux-x64-gnu -o type=local,dest=npm/linux-x64-gnu .
5959
6060
- name: Publish to npm
@@ -80,7 +80,7 @@ jobs:
8080
done
8181
8282
# Publish v8 platform packages (not in pnpm workspace)
83-
for dir in crates/v8-runtime/npm/*/; do
83+
for dir in native/v8-runtime/npm/*/; do
8484
if [ ! -f "$dir/package.json" ]; then
8585
continue
8686
fi

.github/workflows/rust.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ on:
55
branches:
66
- main
77
paths:
8-
- "crates/v8-runtime/**"
8+
- "native/v8-runtime/**"
99
- ".github/workflows/rust.yml"
1010
pull_request:
1111
branches:
1212
- main
1313
paths:
14-
- "crates/v8-runtime/**"
14+
- "native/v8-runtime/**"
1515
- ".github/workflows/rust.yml"
1616

1717
jobs:
@@ -33,17 +33,17 @@ jobs:
3333
path: |
3434
~/.cargo/registry
3535
~/.cargo/git
36-
crates/v8-runtime/target
37-
key: rust-lint-${{ hashFiles('crates/v8-runtime/Cargo.lock') }}
36+
native/v8-runtime/target
37+
key: rust-lint-${{ hashFiles('native/v8-runtime/Cargo.lock') }}
3838
restore-keys: |
3939
rust-lint-
4040
4141
- name: Check formatting
42-
working-directory: crates/v8-runtime
42+
working-directory: native/v8-runtime
4343
run: cargo fmt --all -- --check
4444

4545
- name: Run clippy
46-
working-directory: crates/v8-runtime
46+
working-directory: native/v8-runtime
4747
run: cargo clippy --all-targets -- -D warnings
4848

4949
build:
@@ -94,8 +94,8 @@ jobs:
9494
path: |
9595
~/.cargo/registry
9696
~/.cargo/git
97-
crates/v8-runtime/target
98-
key: rust-${{ matrix.target }}-${{ hashFiles('crates/v8-runtime/Cargo.lock') }}
97+
native/v8-runtime/target
98+
key: rust-${{ matrix.target }}-${{ hashFiles('native/v8-runtime/Cargo.lock') }}
9999
restore-keys: |
100100
rust-${{ matrix.target }}-
101101
@@ -108,7 +108,7 @@ jobs:
108108
109109
- name: Configure cross-compilation linker
110110
if: matrix.cross
111-
working-directory: crates/v8-runtime
111+
working-directory: native/v8-runtime
112112
run: |
113113
mkdir -p .cargo
114114
cat > .cargo/config.toml <<'EOF'
@@ -117,16 +117,16 @@ jobs:
117117
EOF
118118
119119
- name: Build
120-
working-directory: crates/v8-runtime
120+
working-directory: native/v8-runtime
121121
run: cargo build --release --target ${{ matrix.target }}
122122

123123
- name: Run tests
124124
if: matrix.test
125-
working-directory: crates/v8-runtime
125+
working-directory: native/v8-runtime
126126
run: cargo test --release --target ${{ matrix.target }}
127127

128128
- name: Upload binary artifact
129129
uses: actions/upload-artifact@v4
130130
with:
131131
name: v8-${{ matrix.npm-dir }}
132-
path: crates/v8-runtime/target/${{ matrix.target }}/release/${{ matrix.binary }}
132+
path: native/v8-runtime/target/${{ matrix.target }}/release/${{ matrix.binary }}

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ dist
55
target/
66
scratch/
77
.ralph/
8-
wasmvm/target/
9-
wasmvm/vendor/
8+
native/wasmvm/target/
9+
native/wasmvm/vendor/
1010
packages/secure-exec/src/generated/
1111
packages/playground/secure-exec-worker.js
1212
packages/playground/vendor/

CLAUDE.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@
4343
## C Library Vendoring Policy
4444

4545
- 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`
4747
- **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/`
4949
- 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
5050
- existing forks: `rivet-dev/secure-exec-curl` (libcurl with `wasi_tls.c` and `wasi_stubs.c`)
5151

@@ -54,21 +54,21 @@
5454
- the goal for WasmVM is full POSIX compliance 1:1 — every command, syscall, and shell behavior should match a real Linux system exactly
5555
- WasmVM and Python are experimental surfaces in this repo
5656
- 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
6161
- 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
6363

6464
## WasmVM Syscall Coverage
6565

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)
7272

7373
## Terminology
7474

docs-internal/arch/overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ Manages the Rust V8 child process and provides the session API.
132132
- IPC uses length-prefixed MessagePack (64 MB max); binary data uses msgpack `bin` format (no base64)
133133
- Bridge args/results are double-encoded: inner msgpack blobs inside outer msgpack IPC messages
134134

135-
### Rust binary (`crates/v8-runtime/`)
135+
### Rust binary (`native/v8-runtime/`)
136136

137137
The Rust V8 runtime process. One OS thread per session, each owning a `v8::Isolate`.
138138

@@ -222,4 +222,4 @@ Wraps each adapter with allow/deny checks before calls reach the host.
222222

223223
---
224224

225-
> **Kernel packages** (`packages/kernel/`, `packages/runtime/`, `packages/os/`) are experimental and not part of the public API. See `wasmvm/CLAUDE.md` for kernel and WasmVM architecture details.
225+
> **Kernel packages** (`packages/kernel/`, `packages/runtime/`, `packages/os/`) are experimental and not part of the public API. See `native/wasmvm/CLAUDE.md` for kernel and WasmVM architecture details.

docs-internal/spec-hardening.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Addresses bugs, test quality gaps, missing coverage, and documentation debt iden
2525

2626
### 2. SharedArrayBuffer 1MB Truncation (WasmVM)
2727

28-
**Location:** `packages/runtime/wasmvm/src/syscall-rpc.ts`
28+
**Location:** `packages/secure-exec-wasmvm/src/syscall-rpc.ts`
2929

3030
**Problem:** The WasmVM RPC uses a 1MB SharedArrayBuffer for all response data. File reads >1MB silently truncate with no error. Large directory listings overflow.
3131

@@ -207,13 +207,13 @@ Addresses bugs, test quality gaps, missing coverage, and documentation debt iden
207207
**Problem:** WasmVM real execution tests are gated behind `skipIf(!hasWasmBinaries)`. If CI doesn't build the Rust crates, all real execution tests silently skip. The test suite reports green despite not running critical tests.
208208

209209
**Acceptance criteria:** (RESOLVED)
210-
- CI pipeline runs `make wasm` to build standalone binaries to `wasmvm/target/wasm32-wasip1/release/commands/`
210+
- CI pipeline runs `make wasm` to build standalone binaries to `native/wasmvm/target/wasm32-wasip1/release/commands/`
211211
- CI-only test asserts `hasWasmBinaries === true` so CI fails if binaries are missing
212212
- CLAUDE.md documents how to build locally
213213

214214
### 15. Error String Matching → Structured Errors (WasmVM)
215215

216-
**Location:** `packages/runtime/wasmvm/src/kernel-worker.ts`
216+
**Location:** `packages/secure-exec-wasmvm/src/kernel-worker.ts`
217217

218218
**Problem:** `mapErrorToErrno()` matches on `error.message` content (`msg.includes('EBADF')`). Brittle — if kernel error messages change, errno mapping silently breaks.
219219

@@ -593,7 +593,7 @@ process.exit(code);
593593

594594
### 27. fdPread / fdPwrite (Positional I/O) (was 26)
595595

596-
**Location:** `packages/kernel/src/fd-table.ts`, `packages/kernel/src/kernel.ts`, `packages/runtime/wasmvm/src/kernel-worker.ts`
596+
**Location:** `packages/kernel/src/fd-table.ts`, `packages/kernel/src/kernel.ts`, `packages/secure-exec-wasmvm/src/kernel-worker.ts`
597597

598598
**Problem:** WasmVM's kernel-worker RPC defines `fdPread` and `fdPwrite` handlers but they fall back to sequential `fdRead`/`fdWrite` without respecting the offset parameter. Positional I/O reads/writes at a specific offset without changing the FD's cursor position. This is used by databases (SQLite), memory-mapped file patterns, and concurrent readers of the same file.
599599

docs-internal/specs/v8-context-snapshot.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,15 +332,15 @@ Split `composeBridgeCode()` into:
332332
333333
### Phase 4: Add stub bridge context
334334
335-
**File: `crates/v8-runtime/src/bridge.rs`**
335+
**File: `native/v8-runtime/src/bridge.rs`**
336336
337337
Add `BridgeCallContext::stub()` — a no-op context that panics if `sync_call` or `async_send` is called. Used during snapshot creation.
338338
339339
Add `register_stub_bridge_fns(scope, sync_fns, async_fns)` — registers all 38 bridge functions with stub External data.
340340
341341
### Phase 5: Context snapshot creation
342342
343-
**File: `crates/v8-runtime/src/snapshot.rs`**
343+
**File: `native/v8-runtime/src/snapshot.rs`**
344344
345345
Update `create_snapshot()` to:
346346
1. Register stub bridge functions
@@ -351,7 +351,7 @@ Update `create_snapshot()` to:
351351
352352
### Phase 6: Context restore in session thread
353353
354-
**File: `crates/v8-runtime/src/session.rs`**
354+
**File: `native/v8-runtime/src/session.rs`**
355355
356356
On Execute, instead of:
357357
```

docs-internal/specs/v8-runtime.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ MessagePack handles binary data natively as `bin` format. No more base64 encodin
393393
## Rust Crate Structure
394394

395395
```
396-
crates/v8-runtime/
396+
native/v8-runtime/
397397
├── Cargo.toml
398398
├── src/
399399
│ ├── main.rs # Binary entry point, UDS listener
@@ -534,7 +534,7 @@ Expected binary size: ~40-60MB per platform (V8 is large).
534534
## Migration Plan
535535

536536
### Phase 1: Build the Rust binary
537-
- Implement `crates/v8-runtime/` with IPC protocol
537+
- Implement `native/v8-runtime/` with IPC protocol
538538
- Basic isolate lifecycle: create, execute script, destroy
539539
- Host function injection for sync bridge calls
540540

0 commit comments

Comments
 (0)