You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs-internal/proposal-kernel-consolidation.md
+82-3Lines changed: 82 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,8 @@
8
8
9
9
Consolidate the two parallel architectures (published SDK layer and kernel/OS layer) into a single kernel-first architecture. The kernel becomes the default for all usage. The non-kernel `NodeRuntime` / `SystemDriver` API is removed. Runtime packages (`@secure-exec/nodejs`, `@secure-exec/python`, `@secure-exec/wasmvm`) become kernel drivers that users mount. The user experience is progressive: start with sandboxed Node, add WasmVM for shell/POSIX, add Python for Python — all via `kernel.mount()`.
10
10
11
+
Additionally, restructure the repository layout to cleanly separate TypeScript packages (`packages/`) from native Rust code (`native/`), eliminating the current split where Rust code is scattered across `crates/` and `wasmvm/` at the repo root.
12
+
11
13
## Motivation
12
14
13
15
### Two architectures, one product
@@ -34,6 +36,15 @@ The kernel path wraps the SDK path — `runtime-node` creates a `SystemDriver` a
34
36
35
37
6.**Naming confusion.**`@secure-exec/node` (published V8 driver) vs `@secure-exec/runtime-node` (kernel runtime driver) vs `@secure-exec/os-node` (kernel platform adapter) — three packages with "node" in the name at different abstraction levels.
36
38
39
+
### Scattered native code
40
+
41
+
Rust code lives in two disconnected locations at the repo root:
42
+
43
+
-**`crates/v8-runtime/`** — a single Rust crate that compiles to a host binary (x86/arm). It's the V8 runtime process that `@secure-exec/v8` spawns. Sits alone in `crates/` with no siblings.
44
+
-**`wasmvm/`** — an entire separate Rust workspace with its own `Cargo.toml`, `Cargo.lock`, `Makefile`, `vendor/`, `scripts/`, `patches/`, and `CLAUDE.md`. Contains ~90 command crates compiled to `wasm32-wasip1`, plus C programs and wasi-libc patches.
45
+
46
+
These two Rust projects have completely different toolchains and targets (host native vs WASM), so they can't share a Cargo workspace. But having them at different nesting levels (`crates/X` vs `wasmvm/`) with different conventions makes the repo harder to navigate. Meanwhile, `packages/` mixes flat top-level packages (`secure-exec-core`) with nested groups (`runtime/node`, `os/browser`), and after the kernel consolidation those nested groups get merged away.
47
+
37
48
### Why the kernel is effectively free
38
49
39
50
The kernel constructor (`kernel.ts:88-121`) is synchronous, in-memory setup:
@@ -47,7 +58,52 @@ The expensive part — `NodeExecutionDriver` + V8 isolate + bridge — is identi
-`packages/` = TypeScript. `native/` = Rust/C. No mixing.
102
+
-`native/v8-runtime/` and `native/wasmvm/` remain separate Cargo workspaces (different toolchains, different targets). The `native/` grouping is organizational, not a shared workspace.
103
+
-`packages/` is flat — no nested `runtime/`, `os/`, or `kernel/` subdirectories after consolidation.
104
+
-`wasmvm/` internals (crates, patches, vendor, Makefile) are preserved as-is under `native/wasmvm/`.
3. Update `@secure-exec/v8` to reference `native/v8-runtime/` for the Rust binary (postinstall script, build paths).
399
+
4. Update `@secure-exec/wasmvm` to reference `native/wasmvm/target/` for WASM binaries.
400
+
5. Update `turbo.json``build:wasm` task inputs from `wasmvm/**` to `native/wasmvm/**`.
401
+
6. Update CLAUDE.md references to `wasmvm/` and `crates/`.
402
+
7. Update `native/wasmvm/CLAUDE.md` if path references change.
403
+
8. Delete empty top-level `crates/` and `wasmvm/` directories.
404
+
405
+
**Risk:** Low — these are pure file moves with no code changes. The two Rust workspaces remain independent. The main risk is stale path references in scripts, CI, and documentation.
406
+
407
+
**Verification:**`cd native/v8-runtime && cargo build` and `cd native/wasmvm && make wasm` must both work after the move.
| Stale native path references after layout move | Medium | Medium | Grep all references to `crates/`, `wasmvm/` in CI, scripts, docs, CLAUDE.md; verify `cargo build` and `make wasm` post-move |
482
+
| CI workflows break from path changes | Medium | Medium | Update `.github/workflows/` glob patterns and cache keys in same PR as moves |
407
483
408
484
## Success Criteria
409
485
@@ -415,3 +491,6 @@ This is straightforward but must be done in Phase 3 when the kernel merges into
415
491
6. Adding WasmVM/Python is one import + one `mount()` call — no API change.
416
492
7. No duplicate type definitions between packages.
417
493
8. All docs updated to reflect new API.
494
+
9. All Rust/C code lives under `native/`. All TypeScript packages live under `packages/`. No code at the repo root.
495
+
10.`cd native/v8-runtime && cargo build` and `cd native/wasmvm && make wasm` both succeed.
496
+
11. No remaining references to old paths (`crates/v8-runtime`, top-level `wasmvm/`) in CI, scripts, docs, or CLAUDE.md.
0 commit comments