Skip to content

Commit c3401ee

Browse files
NathanFlurryclaude
andcommitted
feat: US-018 - Update turbo, CI, contracts, and architecture docs for final state
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 53f832a commit c3401ee

8 files changed

Lines changed: 145 additions & 49 deletions

File tree

.agent/contracts/compatibility-governance.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,25 @@ Changes that add, remove, or materially alter TypeScript compile/typecheck behav
88

99
#### Scenario: Core runtime TypeScript handling changes
1010
- **WHEN** the core runtime adds or removes implicit TypeScript preprocessing behavior
11-
- **THEN** `docs/quickstart.mdx`, `docs/api-reference.mdx`, `docs/runtimes/node.mdx`, `docs/node-compatability.mdx`, `docs-internal/arch/overview.md`, and `docs-internal/friction.md` MUST be updated in the same change
11+
- **THEN** `docs/quickstart.mdx`, `docs/api-reference.mdx`, `docs/runtimes/node.mdx`, `docs/nodejs-compatibility.mdx`, `docs-internal/arch/overview.md`, and `docs-internal/friction.md` MUST be updated in the same change
1212

1313
#### Scenario: Companion TypeScript tooling API changes
1414
- **WHEN** the public API of the companion TypeScript tooling package changes
1515
- **THEN** `docs/quickstart.mdx` and `docs/api-reference.mdx` MUST be updated in the same change so project/source helper semantics remain accurate
1616

1717
### Requirement: Maintain Node Stdlib Compatibility Matrix
18-
Changes affecting bridged or polyfilled Node APIs MUST keep `docs/node-compatability.mdx` synchronized with the actual runtime surface, including supported, limited, and unsupported modules/APIs. Every module entry in the matrix MUST include an explicit support-tier classification (Bridge, Polyfill, Stub, Deferred, or Unsupported) as defined by the `node-stdlib` spec. The page MUST include a top-of-page target Node version statement.
18+
Changes affecting bridged or polyfilled Node APIs MUST keep `docs/nodejs-compatibility.mdx` synchronized with the actual runtime surface, including supported, limited, and unsupported modules/APIs. Every module entry in the matrix MUST include an explicit support-tier classification (Bridge, Polyfill, Stub, Deferred, or Unsupported) as defined by the `node-stdlib` spec. The page MUST include a top-of-page target Node version statement.
1919

2020
#### Scenario: Bridge API surface changes
2121
- **WHEN** a change adds, removes, or materially alters bridged Node API behavior
22-
- **THEN** the compatibility matrix page at `docs/node-compatability.mdx` MUST be updated in the same change to reflect the new runtime contract
22+
- **THEN** the compatibility matrix page at `docs/nodejs-compatibility.mdx` MUST be updated in the same change to reflect the new runtime contract
2323

2424
#### Scenario: Legacy internal matrix path appears anywhere in repository docs/spec sources
2525
- **WHEN** a repository document or spec source references the legacy internal stdlib compatibility document
26-
- **THEN** the reference MUST be replaced with `docs/node-compatability.mdx` before the change is considered complete
26+
- **THEN** the reference MUST be replaced with `docs/nodejs-compatibility.mdx` before the change is considered complete
2727

2828
#### Scenario: Target Node version callout is missing
29-
- **WHEN** `docs/node-compatability.mdx` is updated
29+
- **WHEN** `docs/nodejs-compatibility.mdx` is updated
3030
- **THEN** the page MUST retain an explicit target Node version statement at the top
3131

3232
### Requirement: Node Compatibility Target Version Tracks Test Type Baseline
@@ -38,7 +38,7 @@ The runtime compatibility target MUST align with the `@types/node` package major
3838

3939
#### Scenario: `@types/node` target major is upgraded
4040
- **WHEN** the workspace intentionally upgrades `@types/node` to a new major version used by secure-exec validation
41-
- **THEN** the same change MUST update `docs/node-compatability.mdx` and related compatibility-governance references to the new target Node major line
41+
- **THEN** the same change MUST update `docs/nodejs-compatibility.mdx` and related compatibility-governance references to the new target Node major line
4242

4343
#### Scenario: Compatibility target is documented
4444
- **WHEN** compatibility requirements or docs declare a target Node version
@@ -67,10 +67,10 @@ Unexpected issues, workarounds, and integration friction encountered during secu
6767
- **THEN** its log entry MUST be updated to indicate resolution and summarize the fix
6868

6969
### Requirement: Run Bridge Type Conformance Tests After Bridge Changes
70-
Any change to files under `packages/secure-exec-core/src/bridge` MUST run bridge type conformance checks via `pnpm run check-types:test` in `packages/secure-exec` before completion.
70+
Any change to files under `packages/secure-exec-nodejs/src/bridge` MUST run bridge type conformance checks via `pnpm run check-types:test` in `packages/secure-exec` before completion.
7171

7272
#### Scenario: Bridge source file is modified
73-
- **WHEN** a commit modifies one or more files in `packages/secure-exec-core/src/bridge`
73+
- **WHEN** a commit modifies one or more files in `packages/secure-exec-nodejs/src/bridge`
7474
- **THEN** `pnpm run check-types:test` MUST be executed and failures MUST be addressed before the change is considered complete
7575

7676
### Requirement: Compatibility Project Matrix Uses Black-Box Node Fixtures
@@ -251,7 +251,7 @@ Any change that introduces or modifies runtime log-capture defaults or hook-base
251251

252252
#### Scenario: Runtime introduces or changes log-stream hook behavior
253253
- **WHEN** runtime log-stream hook contract changes (event shape, ordering semantics, or failure behavior)
254-
- **THEN** `docs/security-model.mdx` MUST describe trust-boundary and resource-consumption implications and `docs/node-compatability.mdx` MUST reflect user-visible behavior changes where applicable
254+
- **THEN** `docs/security-model.mdx` MUST describe trust-boundary and resource-consumption implications and `docs/nodejs-compatibility.mdx` MUST reflect user-visible behavior changes where applicable
255255

256256
#### Scenario: Logging changes include exploit regression coverage
257257
- **WHEN** logging/output behavior is changed in runtime or bridge paths

.agent/contracts/documentation-site.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ The documentation site SHALL expose a core navigation set that includes Quicksta
88

99
#### Scenario: Docs configuration defines required core pages
1010
- **WHEN** the docs configuration is loaded
11-
- **THEN** navigation MUST include `quickstart`, `security-model`, and `node-compatability` as available documentation pages
11+
- **THEN** navigation MUST include `quickstart`, `security-model`, and `nodejs-compatibility` as available documentation pages
1212

1313
#### Scenario: Node compatibility page path is resolvable
1414
- **WHEN** a user selects the Node Compatibility page from navigation
15-
- **THEN** the docs site MUST resolve and render `node-compatability.mdx` successfully
15+
- **THEN** the docs site MUST resolve and render `nodejs-compatibility.mdx` successfully
1616

1717
### Requirement: Quickstart Uses Steps With Runnable Example
1818
The Quickstart page SHALL present onboarding steps using Mintlify `<Steps>` and SHALL include at least one basic runnable example that verifies setup success using the current runtime logging contract.
@@ -30,17 +30,17 @@ The Quickstart page SHALL present onboarding steps using Mintlify `<Steps>` and
3030
- **THEN** it MUST use hook-based log streaming examples and MUST NOT instruct users to read `result.stdout` or `result.stderr`
3131

3232
### Requirement: Node Compatibility Page Declares Target Version and Matrix
33-
The docs site MUST provide `docs/node-compatability.mdx` with an explicit target Node version statement near the top of the page and a clean compatibility matrix table that summarizes module support tier and runtime notes.
33+
The docs site MUST provide `docs/nodejs-compatibility.mdx` with an explicit target Node version statement near the top of the page and a clean compatibility matrix table that summarizes module support tier and runtime notes.
3434

3535
#### Scenario: Target Node version is visible at top of page
36-
- **WHEN** `node-compatability.mdx` is rendered
36+
- **WHEN** `nodejs-compatibility.mdx` is rendered
3737
- **THEN** users MUST see the targeted Node version before the compatibility matrix content
3838

3939
#### Scenario: Compatibility matrix uses concise tabular format
40-
- **WHEN** `node-compatability.mdx` is rendered
40+
- **WHEN** `nodejs-compatibility.mdx` is rendered
4141
- **THEN** it MUST include a simple table with module/support-tier/status details migrated from the internal compatibility source
4242

4343
#### Scenario: Permission model scope stays at runtime and bridge contract
44-
- **WHEN** `node-compatability.mdx` documents permission behavior
44+
- **WHEN** `nodejs-compatibility.mdx` documents permission behavior
4545
- **THEN** it MUST describe core runtime/bridge permission enforcement and MUST NOT present driver-construction convenience defaults as the canonical security contract
4646

.agent/contracts/node-bridge.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ Bridge-exposed filesystem metadata calls (`exists`, `stat`, and typed directory
117117
- **THEN** bridge handling MUST return entry type information without a repeated `readDir` probe for each entry
118118

119119
### Requirement: Bridge Boundary Contracts SHALL Be Defined In A Canonical Shared Type Module
120-
Bridge global keys and host/isolate boundary type contracts SHALL be defined in one canonical shared type module under `packages/secure-exec-core/src/shared/` and reused across host runtime setup and bridge modules.
120+
Bridge global keys and host/isolate boundary type contracts SHALL be defined in canonical shared type modules — bridge-contract types in `packages/secure-exec-nodejs/src/bridge-contract.ts` and global-exposure helpers in `packages/secure-exec-core/src/shared/global-exposure.ts` and reused across host runtime setup and bridge modules.
121121

122122
#### Scenario: Host runtime injects bridge globals
123123
- **WHEN** host runtime code wires bridge globals into the isolate

.agent/contracts/runtime-driver-test-suite-structure.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Secure-exec runtime-driver integration coverage MUST use the canonical filesyste
1010
- `packages/secure-exec/tests/test-suite/{name}.ts`
1111
- `packages/secure-exec/tests/exec-driver/{name}.test.ts`
1212
- `packages/secure-exec/tests/runtime-driver/{name}.test.ts`
13-
- `packages/kernel/test/{name}.test.ts` (kernel unit tests)
13+
- `packages/secure-exec-core/test/kernel/{name}.test.ts` (kernel unit tests)
1414
- `packages/secure-exec/tests/kernel/{name}.test.ts` (kernel cross-runtime integration tests)
1515

1616
#### Scenario: Shared matrix entrypoint exists at canonical path
@@ -48,15 +48,15 @@ Shared suite registration order in the matrix entrypoint MUST be explicit and st
4848
- **THEN** they MUST be imported and invoked in deterministic source order rather than filesystem discovery
4949

5050
### Requirement: Kernel Unit Tests SHALL Use MockRuntimeDriver In Kernel Package
51-
Kernel unit tests that validate kernel subsystem behavior (VFS, FD table, process table, device layer, pipe manager, command registry, permissions) SHALL reside under `packages/kernel/test/` and use MockRuntimeDriver for driver interactions.
51+
Kernel unit tests that validate kernel subsystem behavior (VFS, FD table, process table, device layer, pipe manager, command registry, permissions) SHALL reside under `packages/secure-exec-core/test/kernel/` and use MockRuntimeDriver for driver interactions.
5252

5353
#### Scenario: Kernel unit tests live in kernel package
5454
- **WHEN** contributors add or update tests for kernel subsystem behavior
55-
- **THEN** those tests MUST reside under `packages/kernel/test/` as `*.test.ts` files
55+
- **THEN** those tests MUST reside under `packages/secure-exec-core/test/kernel/` as `*.test.ts` files
5656

5757
#### Scenario: Kernel unit tests use MockRuntimeDriver
5858
- **WHEN** kernel unit tests need to validate spawn/exec orchestration or command registration
59-
- **THEN** they MUST use a MockRuntimeDriver (from `packages/kernel/test/helpers.ts`) that implements the RuntimeDriver interface with controllable behavior, rather than requiring real runtime drivers
59+
- **THEN** they MUST use a MockRuntimeDriver (from `packages/secure-exec-core/test/kernel/helpers.ts`) that implements the RuntimeDriver interface with controllable behavior, rather than requiring real runtime drivers
6060

6161
#### Scenario: Kernel unit tests validate subsystem invariants independently
6262
- **WHEN** kernel unit tests validate FD table, process table, pipe manager, or device layer behavior

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
key: wasm-${{ runner.os }}-${{ hashFiles('native/wasmvm/Cargo.lock', 'native/wasmvm/rust-toolchain.toml') }}
3636

3737
- name: Build WASM binary
38-
run: cd wasmvm && make wasm
38+
run: cd native/wasmvm && make wasm
3939

4040
# --- C toolchain (wasi-sdk + patched sysroot + C test fixtures) ---
4141
- name: Cache wasi-sdk

docs-internal/arch/overview.md

Lines changed: 73 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,77 @@
11
# Architecture Overview
22

33
```
4-
NodeRuntime / PythonRuntime
4+
Kernel-first API (createKernel + mount + exec)
55
packages/secure-exec-core/
6+
7+
Legacy facade: NodeRuntime (packages/secure-exec/src/runtime.ts)
68
7-
┌────┴─────┬──────────┐
8-
│ │ │
9-
Node Browser Python
10-
packages/ packages/ packages/
11-
secure- secure- secure-
12-
exec- exec- exec-
13-
node/ browser/ python/
9+
┌────┴─────┬──────────┬──────────
10+
│ │ │
11+
Node Browser Python WasmVM
12+
packages/ packages/ packages/ packages/
13+
secure- secure- secure- secure-
14+
exec- exec- exec- exec-
15+
nodejs/ browser/ python/ wasmvm/
1416
1517
Package index:
1618
1719
@secure-exec/core packages/secure-exec-core/
18-
Shared types, utilities, bridge, NodeRuntime/PythonRuntime classes,
19-
isolate-runtime source, build scripts
20+
Kernel (VFS, FD table, process table, device layer, pipes, PTY,
21+
command registry, permissions), shared types, utilities,
22+
isolate-runtime source, in-memory filesystem
2023
2124
@secure-exec/v8 packages/secure-exec-v8/
2225
V8 runtime process manager (spawns Rust binary, IPC client,
2326
session abstraction). MessagePack framing over UDS.
2427
2528
@secure-exec/nodejs packages/secure-exec-nodejs/
26-
Execution driver, bridge-handlers, bridge-loader, module-access overlay,
27-
createNodeDriver, createNodeRuntimeDriverFactory
29+
Node execution driver, bridge polyfills, bridge-handlers,
30+
bridge-loader, module-access overlay, ESM compiler,
31+
module resolver, package bundler, kernel runtime driver
32+
(createNodeRuntime), createNodeDriver, createNodeRuntimeDriverFactory
2833
2934
@secure-exec/browser packages/secure-exec-browser/
30-
Web Worker execution driver, createBrowserDriver,
35+
Web Worker execution driver, browser VFS (InMemoryFileSystem),
36+
browser worker adapter, createBrowserDriver,
3137
createBrowserRuntimeDriverFactory
3238
3339
@secure-exec/python packages/secure-exec-python/
34-
Pyodide execution driver, createPyodideRuntimeDriverFactory
40+
Pyodide execution driver, kernel runtime driver
41+
(createPythonRuntime), createPyodideRuntimeDriverFactory
42+
43+
@secure-exec/wasmvm packages/secure-exec-wasmvm/
44+
WasmVM runtime driver (createWasmVmRuntime), WASI polyfill,
45+
kernel worker management. WASM binaries in native/wasmvm/target/
3546
3647
@secure-exec/typescript packages/secure-exec-typescript/
3748
Optional TypeScript compiler tools (type-checking, compilation)
3849
3950
secure-exec packages/secure-exec/
40-
Barrel re-export layer (re-exports core, node, browser, python)
51+
Barrel re-export layer (re-exports core, nodejs).
52+
Contains legacy NodeRuntime facade class.
4153
```
4254

43-
## NodeRuntime / PythonRuntime
55+
## Kernel (createKernel)
56+
57+
`packages/secure-exec-core/src/kernel/kernel.ts`
58+
59+
Primary API. Creates a kernel with shared VFS, FD table, process table, device layer, pipes, PTY, and command registry.
60+
61+
- `kernel.mount(driver)` — register a RuntimeDriver and its commands
62+
- `kernel.exec(command)` — high-level execute-and-collect (spawn via shell, capture stdout/stderr)
63+
- `kernel.spawn(command, args, options)` — low-level process spawn with PID allocation and FD table setup
64+
- `kernel.openShell(options)` — open an interactive PTY shell
65+
- `kernel.dispose()` — terminate all processes and release resources
4466

45-
`packages/secure-exec-core/src/runtime.ts`, `packages/secure-exec-core/src/python-runtime.ts`
67+
## NodeRuntime (legacy facade)
4668

47-
Public APIs. Thin facades that delegate orchestration to execution drivers.
69+
`packages/secure-exec/src/runtime.ts`
70+
71+
Legacy facade for direct code execution. Delegates to execution drivers.
4872

4973
- `NodeRuntime.run(code)` — execute JS module, get exports back
50-
- `PythonRuntime.run(code)` — execute Python and return structured value/global wrapper
51-
- `exec(code)` — execute as script, get exit code/error contract
74+
- `NodeRuntime.exec(code)` — execute as script, get exit code/error contract
5275
- `dispose()` / `terminate()`
5376
- Requires both:
5477
- `systemDriver` for runtime capabilities/config
@@ -58,7 +81,7 @@ Public APIs. Thin facades that delegate orchestration to execution drivers.
5881

5982
`packages/secure-exec-core/src/types.ts`
6083

61-
Config object that bundles what the isolate can access. Deny-by-default.
84+
Config object that bundles what the isolate can access. Deny-by-default. Used by the legacy NodeRuntime facade.
6285

6386
- `filesystem` — VFS adapter
6487
- `network` — fetch, DNS, HTTP
@@ -91,6 +114,16 @@ Factory that builds a Node-backed execution driver factory.
91114
- Constructs `NodeExecutionDriver` instances
92115
- Owns optional Node-specific isolate creation hook
93116

117+
### createNodeRuntime()
118+
119+
`packages/secure-exec-nodejs/src/kernel-runtime.ts`
120+
121+
Factory that creates a kernel-compatible Node RuntimeDriver for use with `kernel.mount()`.
122+
123+
- Returns a `KernelRuntimeDriver` with commands like `node`, `npx`, `npm`
124+
- Manages V8 session lifecycle for kernel-spawned processes
125+
- Bridges kernel VFS/FD table into Node execution context
126+
94127
### createBrowserDriver()
95128

96129
`packages/secure-exec-browser/src/driver.ts`
@@ -120,6 +153,25 @@ Factory that builds a Python-backed execution driver factory.
120153
- Constructs `PyodideRuntimeDriver` instances
121154
- Owns Pyodide worker bootstrap and execution-driver creation options
122155

156+
### createPythonRuntime()
157+
158+
`packages/secure-exec-python/src/kernel-runtime.ts`
159+
160+
Factory that creates a kernel-compatible Python RuntimeDriver for use with `kernel.mount()`.
161+
162+
- Returns a `KernelRuntimeDriver` with `python` command
163+
- Manages Pyodide worker lifecycle for kernel-spawned processes
164+
165+
### createWasmVmRuntime()
166+
167+
`packages/secure-exec-wasmvm/src/runtime.ts`
168+
169+
Factory that creates a kernel-compatible WasmVM RuntimeDriver for use with `kernel.mount()`.
170+
171+
- Returns a `KernelRuntimeDriver` with POSIX commands (`sh`, `ls`, `cat`, `grep`, etc.)
172+
- Loads WASM binaries from `native/wasmvm/target/`
173+
- Manages WASI polyfill and kernel worker threads
174+
123175
## @secure-exec/v8 (V8 Runtime)
124176

125177
`packages/secure-exec-v8/`
@@ -219,7 +271,3 @@ Wraps each adapter with allow/deny checks before calls reach the host.
219271

220272
- `wrapFileSystem()`, `wrapNetworkAdapter()`, `wrapCommandExecutor()`
221273
- Missing adapters get deny-all stubs
222-
223-
---
224-
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.

scripts/ralph/prd.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@
265265
"Typecheck passes"
266266
],
267267
"priority": 17,
268-
"passes": false,
268+
"passes": true,
269269
"notes": "Phase 7 step 1. Only delete after all merges are complete."
270270
},
271271
{
@@ -283,7 +283,7 @@
283283
"Typecheck passes"
284284
],
285285
"priority": 18,
286-
"passes": false,
286+
"passes": true,
287287
"notes": "Phase 7 step 2. Final verification of the full consolidation."
288288
},
289289
{

0 commit comments

Comments
 (0)