Files
scriptc/packages/runtime-pack-common/test
Malte UblandClaude Opus 5.5 e06f5fcc08 Brand fs read results as Buffers in programs that can observe it
Node answers a Buffer from fs.readFileSync (path and fd), fs.promises.readFile
and FileHandle#readFile, so Buffer.isBuffer, .constructor, inspect output and
Buffer's numeric search semantics apply to the bytes. scr_lib.c returned
unbranded bytes and diverged.

Branding inside the shared unit would change the executable of every typed
program that links it, so the brand lives in a SCR_FS_BUFFER_BRAND build of
scr_lib.c, selected per program the way SCR_FS_WATCH_FILE is: a runtime
feature (moduleUsesFsBufferBrand) selects it only when the module reads file
bytes through a typed read and can observe their Buffer-ness (Buffer.isBuffer,
inspect of a Uint8Array-typed bytes value, boxing to a dynamic value, or one
of the numeric searches). The default object stays byte-identical.

tests/corpus/fs-buffer-brand.ts covers the sync, fd, promise and callback
reads, unknown boxing, inspect and the searches; it matches Node byte for byte
plain and sanitized.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 06:43:51 -07:00
..