Skip to content

Commit 65d54a9

Browse files
NathanFlurryclaude
andcommitted
docs: add virtual kernel architecture rules to CLAUDE.md
All I/O must route through the virtual kernel. Network loopback is kernel-mediated. VFS is not the host filesystem. New I/O features must go through the kernel, never bypass to host directly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ac1f659 commit 65d54a9

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@
107107
- read `docs-internal/arch/overview.md` for the component map (NodeRuntime, RuntimeDriver, NodeDriver, NodeExecutionDriver, ModuleAccessFileSystem, Permissions)
108108
- keep it up to date when adding, removing, or significantly changing components
109109

110+
## Virtual Kernel Architecture
111+
112+
- **all sandbox I/O routes through the virtual kernel** — user code never touches the host OS directly
113+
- the kernel provides: VFS (virtual file system), process table (spawn/signals/exit), network stack (TCP/HTTP/DNS/UDP), and a deny-by-default permissions engine
114+
- **network calls are kernel-mediated**: `http.createServer()` registers a virtual listener in the kernel's network stack; `http.request()` to localhost routes through the kernel without real TCP — the kernel connects virtual server to virtual client directly; external requests go through the host adapter after permission checks
115+
- **the VFS is not the host file system** — files written by sandbox code live in the VFS (in-memory by default); host filesystem is accessible only through explicit read-only overlays (e.g., `node_modules`) configured by the embedder
116+
- **embedders provide host adapters** that implement actual I/O — a Node.js embedder provides real `fs` and `net`; a browser embedder provides `fetch`-based networking and no file system; sandbox code doesn't know which adapter backs the kernel
117+
- when implementing new I/O features (e.g., UDP, TCP servers, fs.watch), they MUST route through the kernel — never bypass it to hit the host directly
118+
- see `docs/nodejs-compatibility.mdx` for the architecture diagram
119+
110120
## Code Transformation Policy
111121

112122
- NEVER use regex-based source code transformation for JavaScript/TypeScript (e.g., converting ESM to CJS, rewriting imports, extracting exports)

0 commit comments

Comments
 (0)