Follow-up to #66, discovered during #510 validation. Implemented and verified on Darwin in fde7b7ebc64a2d327a1665578d4b396f8a5e93a1, pushed to codex/runtime-port as Chris Breuer without coauthors. Branch integration and other platforms remain unverified.
Corrected diagnosis
The original request to combine all queued byte chunks for an unsized Readable.read() was incorrect for our target. The exact Bun pin 4982b91e3702094330f3be3883354c52b8c01323, internal/streams/readable.ts::howMuchToRead, deliberately returns the first queued byte chunk. Home already matches that pin. Installed Bun/Node controls differ, but do not override the pinned source. No full-VM concatenation override was added.
The actual reduced-realm JSEvaluateReturnedNull concealed a module-resolution error: earlier router fixtures changed cwd without restoring it, so the stream unit could not find the upstream common module. Fixture construction now restores cwd on success/error and closes directory/file handles. The existing route test explicitly verifies cwd preservation. Node probe helpers now report the actual JavaScript exception.
The old unit’s Uint8Array identity expectation was also invalid. The reduced C-API stream implementation now wraps byte views as Buffers sharing the original backing storage/offset, as specified by pinned internal/stream.ts::_uint8ArrayToBuffer, while object mode retains value identity and Readable.from defaults to object mode. The corrected unit still imports the real unchanged upstream common; it checks normalization, Buffer identity, byte order, sized/unsized and decoded reads, and object-mode identity. The native CLI regression additionally covers DataView offsets, iterable identity and split UTF-8 decoding. The reduced stream implementation is not claimed to be fully ported.
Verification
- Complete runtime unit suite: 1,819 pass / 19 skip / 0 fail, 1,838 total; one fuzz test discovered, not a full fuzz campaign.
- Final native build: 17/17 steps.
- All 54 native regression commands pass, including all 23 native regression files, full spawn (126 pass / 5 skip / 5,484 assertions) and full child-process (32 pass / 1 skip / 1 TODO / 72 assertions).
- The corrected unit’s exact JavaScript body also returns true in the full native VM.
- All 252 unchanged Node
test-stream*fixtures were checked byte-for-byte against the pin and executed directly. Both the published parent and final binary pass 246/252, with the same six failures and no new failing filenames/statuses. All 63 focused readable/byte/object/decoder files pass.
Remaining native stream failures are separated into #513 (pinned Rust Brotli decoder-code mapping) and #514 (two pipeline timeouts and three missing internal-wrapper modules). Native stream builtins still partly use configured external builtin literals; runtime passes do not establish complete source ownership. #66 remains incomplete.
Evidence: zig-out/stream-unit-{diagnostic,fixed}.log, stream-source-integrity.json, stream-final-{binary,regressions,comparison}.json, stream-final-all-results.json, stream-exact-unit-native.json, and stream-failure-controls.json. Final executable SHA-256: efcec014d5d802ebe551d6a78549fa8b5a38d5958a89f1f39cdf630f8d056c12.