|
34 | 34 | - Docs compatibility link slug is nodejs-compatibility (not node-compatability) |
35 | 35 | - WasmVM native code (Rust, C, patches) canonical location is native/wasmvm/ (alongside native/v8-runtime/) |
36 | 36 | - Test files in packages/secure-exec-wasmvm/test/ use ../../../native/wasmvm/target/ for WASM binary paths (3 levels up from test/ to repo root) |
| 37 | +- Custom bindings types/validation/flattening live in secure-exec-nodejs/src/bindings.ts — flattened __bind.* keys merge into bridgeHandlers Record |
| 38 | +- BridgeHandler = (...args: unknown[]) => unknown | Promise<unknown> — both sync and async handlers work through the same V8 IPC bridge |
37 | 39 |
|
38 | 40 | # Ralph Progress Log |
39 | 41 | Started: Sat Mar 21 02:49:43 AM PDT 2026 |
@@ -525,3 +527,46 @@ Started: Sat Mar 21 02:49:43 AM PDT 2026 |
525 | 527 | - CI workflow had a stale `cd wasmvm` that was missed in US-016's path update sweep — always verify CI with `grep -r` after path moves |
526 | 528 | - packages/secure-exec-node/ (old name) still has a stale dist/ directory — harmless but cruft |
527 | 529 | --- |
| 530 | + |
| 531 | +## 2026-03-21 06:25 - US-019 |
| 532 | +- Implemented custom bindings core plumbing for host-to-sandbox function bridge |
| 533 | +- Created bindings.ts with BindingTree/BindingFunction types, validation, and flattenBindingTree() |
| 534 | +- Added bindings?: BindingTree to NodeRuntimeOptions (kernel-runtime.ts) |
| 535 | +- Added bindings?: BindingTree to NodeExecutionDriverOptions (isolate-bootstrap.ts) |
| 536 | +- Threaded bindings through NodeRuntimeDriver → NodeExecutionDriver constructor |
| 537 | +- Flattened bindings merged into bridgeHandlers with __bind. prefix in executeInternal() |
| 538 | +- Validation rejects: invalid JS identifiers, keys starting with _, nesting > 4, leaf count > 64 |
| 539 | +- Sync/async detection via AsyncFunction instanceof check |
| 540 | +- Exported BindingTree, BindingFunction, BINDING_PREFIX from @secure-exec/nodejs and secure-exec barrel |
| 541 | +- Files changed: |
| 542 | + - packages/secure-exec-nodejs/src/bindings.ts (new — types, validation, flattening) |
| 543 | + - packages/secure-exec-nodejs/src/kernel-runtime.ts (bindings option + threading) |
| 544 | + - packages/secure-exec-nodejs/src/isolate-bootstrap.ts (NodeExecutionDriverOptions.bindings) |
| 545 | + - packages/secure-exec-nodejs/src/execution-driver.ts (flattenedBindings field, merge into bridgeHandlers) |
| 546 | + - packages/secure-exec-nodejs/src/index.ts (re-exports) |
| 547 | + - packages/secure-exec/src/index.ts (barrel re-exports) |
| 548 | +- **Learnings for future iterations:** |
| 549 | + - bridgeHandlers is a simple Record<string, BridgeHandler> — any key added to this map becomes callable from sandbox via V8 IPC bridge (no Rust changes needed) |
| 550 | + - Internal bridge names all start with single _ (e.g., _fsReadFile, _log) — custom bindings use __bind. prefix to avoid collision |
| 551 | + - NodeExecutionDriverOptions extends RuntimeDriverOptions (from core), but bindings are Node-specific so extend at the node level only |
| 552 | + - AsyncFunction detection: `Object.getPrototypeOf(async function () {}).constructor` — instanceof check works for all async functions |
| 553 | + - Validation runs once at construction time, flattened result cached — merge into bridgeHandlers is per-execution |
| 554 | +--- |
| 555 | + |
| 556 | +## 2026-03-21 06:36 - US-020 |
| 557 | +- Implemented sandbox-side SecureExec.bindings injection in execution-driver.ts |
| 558 | +- Added buildBindingsInflationSnippet() function that generates the inflation JS snippet |
| 559 | +- Inflation snippet: builds nested object tree from __bind.* globals, deep-freezes it, sets as globalThis.SecureExec |
| 560 | +- SecureExec is non-writable, non-configurable via Object.defineProperty |
| 561 | +- Raw __bind.* globals deleted from globalThis after inflation |
| 562 | +- SecureExec.bindings is always present (empty frozen object when no bindings registered) |
| 563 | +- Binding keys extracted from flattenedBindings by stripping BINDING_PREFIX, passed as JSON literal to snippet |
| 564 | +- Files changed: |
| 565 | + - packages/secure-exec-nodejs/src/execution-driver.ts (30 LOC added — buildBindingsInflationSnippet function, binding keys extraction, parameter threading) |
| 566 | +- **Learnings for future iterations:** |
| 567 | + - buildPostRestoreScript() is the right injection point for per-execution sandbox setup code — it runs after bridge code snapshot phase so bridge calls work |
| 568 | + - Inflation snippet must use var (not const/let) for broader V8 compatibility in the injected context |
| 569 | + - BINDING_PREFIX ("__bind.") is the separator — binding keys stored without prefix in the inflation snippet, prefixed when looking up globals |
| 570 | + - Object.defineProperty with writable:false, configurable:false ensures sandbox code cannot delete or overwrite SecureExec |
| 571 | + - deepFreeze recursion only freezes objects, not functions — leaf binding functions remain callable but their container objects are frozen |
| 572 | +--- |
0 commit comments