Skip to content

Commit 4fc3e21

Browse files
committed
chore: update progress for US-196
1 parent 976ff2d commit 4fc3e21

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

progress.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ Started: 2026-03-17
33
PRD: ralph/kernel-hardening (46 stories)
44

55
## Codebase Patterns
6+
- NodeRuntimeDriver must emit result.errorMessage as stderr — V8 isolate errors (ReferenceError, SyntaxError) are returned in ExecResult, not thrown
7+
- isolated-vm preserves err.name but err.message excludes the class name — format as `${err.name}: ${err.message}` for Node.js-compatible error output
68
- Stream polyfill prototype chain is patched in _patchPolyfill (require-setup.ts) — esbuild's circular-dep bundling breaks Readable→Stream inheritance; without patch, `instanceof Stream` fails (breaks node-fetch, undici, etc.)
79
- Timing mitigation Date.now/performance.now use getter/setter (not writable:false) — setter is no-op for Node.js compat; configurable:false blocks re-definition
810
- Claude binary at ~/.claude/local/claude — not on PATH by default; skip helpers must check this fallback location
@@ -2465,3 +2467,17 @@ PRD: ralph/kernel-hardening (46 stories)
24652467
- Date formatting in mysql2.escape/format is timezone-dependent — avoid comparing date string values in project-matrix fixtures
24662468
- createPoolCluster.of("REPLICA*") returns a namespace selector object — exercises pattern matching without TCP
24672469
---
2470+
2471+
## 2026-03-19 - US-196
2472+
- What was implemented: Fixed node -e stderr/errors not appearing in interactive shell and kernel.exec. Two bugs: (1) NodeRuntimeDriver didn't emit result.errorMessage as stderr — V8 isolate errors (ReferenceError, SyntaxError, throw) were captured in ExecResult.errorMessage but never forwarded to ctx.onStderr/proc.onStderr. (2) execution.ts error formatting didn't include error class name — isolated-vm preserves err.name but execution.ts only used err.message, so "lskdjf is not defined" appeared instead of "ReferenceError: lskdjf is not defined".
2473+
- Files changed:
2474+
- packages/runtime/node/src/driver.ts — emit result.errorMessage as stderr via ctx.onStderr/proc.onStderr after exec returns
2475+
- packages/secure-exec-node/src/execution.ts — include err.name prefix in errorMessage for non-generic errors (SyntaxError, ReferenceError, etc.)
2476+
- packages/secure-exec/tests/kernel/cross-runtime-terminal.test.ts — added 8 new tests: 4 kernel.exec stderr tests (ReferenceError, throw Error, SyntaxError, console.error) + 4 interactive shell PTY stderr tests (ReferenceError, throw Error, SyntaxError, stderr callback chain)
2477+
- **Learnings for future iterations:**
2478+
- isolated-vm preserves err.name (ReferenceError, SyntaxError) but err.message does NOT include the class name prefix — must format as `${err.name}: ${err.message}` explicitly
2479+
- ExecResult.errorMessage is set when V8 isolate code throws, but NodeRuntimeDriver only emitted stderr in the catch block (for driver-level errors) — result.errorMessage needed separate emission
2480+
- process.exit errors use a generic Error (name === "Error") so the name prefix logic correctly skips them
2481+
- Changing execution.ts requires `pnpm run build` (or turbo build) before tests pick up the change — vitest resolves the compiled output, not TypeScript source
2482+
- The WARN "could not retrieve pid for child process" appears on stderr for all node -e invocations — tests must tolerate it
2483+
---

scripts/ralph/prd.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3387,8 +3387,8 @@
33873387
"Tests pass"
33883388
],
33893389
"priority": 196,
3390-
"passes": false,
3391-
"notes": "Same root cause as US-195 (stdout/stderr callback wiring) but stderr path. Existing test in error-propagation.test.ts line 39 tests stderr through kernel.exec() — verify it still passes and add interactive shell (PTY) equivalent. NodeRuntimeDriver.ts line 481-496 wraps caught errors as stderr."
3390+
"passes": true,
3391+
"notes": "Two bugs fixed: (1) NodeRuntimeDriver didn't emit result.errorMessage as stderr — errors from V8 isolate (ReferenceError, SyntaxError, throw) were returned in ExecResult.errorMessage but never emitted via ctx.onStderr. (2) execution.ts error message didn't include error class name — isolated-vm preserves err.name (ReferenceError, SyntaxError) but execution.ts only used err.message. Fixed by prefixing non-generic error names. Tests added: 4 kernel.exec stderr tests + 4 interactive shell PTY stderr tests."
33923392
},
33933393
{
33943394
"id": "US-197",

0 commit comments

Comments
 (0)