Skip to content

Commit 2b08441

Browse files
committed
chore: update progress for US-191
1 parent b97d4a9 commit 2b08441

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

progress.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ PRD: ralph/kernel-hardening (46 stories)
128128
- NodeExecutionDriver split into 5 modules in src/node/: isolate-bootstrap.ts (types+utilities), module-resolver.ts, esm-compiler.ts, bridge-setup.ts, execution-lifecycle.ts; facade is execution-driver.ts (<300 lines)
129129
- Source policy tests (isolate-runtime-injection-policy, bridge-registry-policy) read specific source files by path — update them when moving code between files
130130
- esmModuleCache has a sibling esmModuleReverseCache (Map<ivm.Module, string>) for O(1) module→path lookup — both must be updated together and cleared together in execution.ts
131+
- wrapNetworkAdapter creates a new object — any new NetworkAdapter methods MUST be explicitly forwarded through wrapNetworkAdapter or they'll be undefined at bridge-setup
132+
- UpgradeSocket.emit must use .call(this) — libraries like ws use `this[Symbol(...)]` in event callbacks requiring proper `this` binding
133+
- Server-side HTTP upgrade relay: driver.ts adds server.on('upgrade') → applySync dispatches to sandbox → sandbox Server._emit('upgrade') → ws handles handshake → UpgradeSocket relays data bidirectionally through bridge
131134

132135
---
133136

@@ -2394,3 +2397,27 @@ PRD: ralph/kernel-hardening (46 stories)
23942397
- All output is deterministic since server sends fixed events and closes — no randomness or timing issues
23952398
- The fixture exercises: http.createServer, chunked transfer-encoding, Connection: keep-alive, streaming reads
23962399
---
2400+
2401+
## 2026-03-19 - US-191
2402+
- What was implemented: Rewrote ws-pass fixture with full WebSocket server-client communication (text + binary echo). Implemented server-side HTTP upgrade support in the bridge (UpgradeSocket class, bidirectional data relay through host bridge references).
2403+
- Files changed:
2404+
- packages/secure-exec/tests/projects/ws-pass/src/index.js — full rewrite: WebSocketServer on port 0, client connects, text + binary echo, event verification
2405+
- packages/secure-exec-core/src/bridge/network.ts — added UpgradeSocket class for bidirectional data relay, server upgrade dispatch, data/end push functions
2406+
- packages/secure-exec-core/src/shared/bridge-contract.ts — added upgrade socket host/runtime bridge keys
2407+
- packages/secure-exec-core/src/shared/global-exposure.ts — added upgrade socket globals to inventory
2408+
- packages/secure-exec-core/src/shared/permissions.ts — forwarded upgradeSocketWrite/End/Destroy/setUpgradeSocketCallbacks through wrapNetworkAdapter
2409+
- packages/secure-exec-core/src/types.ts — added onUpgrade/onUpgradeSocketData/onUpgradeSocketEnd to NetworkServerListenOptions; upgradeSocketWrite/End/Destroy/setUpgradeSocketCallbacks to NetworkAdapter
2410+
- packages/secure-exec-core/isolate-runtime/src/common/runtime-globals.d.ts — added upgrade socket bridge ref types
2411+
- packages/secure-exec-core/src/index.ts — re-exported new bridge ref types
2412+
- packages/secure-exec/src/shared/bridge-contract.ts — re-exported new bridge ref types
2413+
- packages/secure-exec-node/src/bridge-setup.ts — added lazy upgrade dispatch/data/end refs; registered onUpgrade/onUpgradeSocketData/onUpgradeSocketEnd callbacks; added host write/end/destroy refs; called setUpgradeSocketCallbacks
2414+
- packages/secure-exec-node/src/driver.ts — added server.on('upgrade') handler in httpServerListen; kept client-side upgrade socket alive for data relay; added upgradeSocketWrite/End/Destroy/setUpgradeSocketCallbacks adapter methods
2415+
- **Learnings for future iterations:**
2416+
- wrapNetworkAdapter in permissions.ts creates a NEW object — any new adapter methods MUST be forwarded through it or they'll be undefined at bridge-setup time
2417+
- Server-side HTTP upgrade: host server.on('upgrade') → applySync to sandbox → sandbox Server._emit('upgrade') → ws handles it
2418+
- Client-side HTTP upgrade: host req.on('upgrade') → keep socket alive → include upgradeSocketId in response JSON → sandbox creates UpgradeSocket
2419+
- UpgradeSocket.emit must call listeners with .call(this) — ws library's socketOnData uses `this[Symbol('websocket')]` which requires proper `this` binding
2420+
- UpgradeSocket needs _readableState.endEmitted and _writableState.finished stubs — ws checks these in socketOnClose
2421+
- UpgradeSocket.destroy/close must emit 'close' with false argument (hadError=false) for ws compatibility
2422+
- applySync from within applySync (host→sandbox→host reentrance) works in isolated-vm — the host Reference callback runs synchronously
2423+
---

scripts/ralph/prd.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3294,7 +3294,7 @@
32943294
"Tests pass (project-matrix)"
32953295
],
32963296
"priority": 191,
3297-
"passes": false,
3297+
"passes": true,
32983298
"notes": "ws is the most popular WebSocket library. Exercises HTTP upgrade, net.Socket, crypto (for Sec-WebSocket-Accept), Buffer, EventEmitter, streams. Depends on US-043 HTTP upgrade support."
32993299
},
33003300
{

0 commit comments

Comments
 (0)