ReviewOS

home-lang/home

Native Brotli: port pinned decoder error-code mapping

#513
Open chris opened this 9 days ago ·
9 days ago

Follow-up to #66 and #512, found by running all 252 byte-identical js/node/test/parallel/test-stream* files from Bun pin 4982b91e3702094330f3be3883354c52b8c01323 directly in native Home.

test-stream-iter-transform-errors.js failed because corrupt Brotli input produced ERR_BROTLI_DECODER_ERROR_FORMAT_PADDING_2 rather than ERR__ERROR_FORMAT_PADDING_2. The exact pinned src/runtime/node/zlib/NativeBrotli.rs::code_for_error maps the complete decoder enum to ERR__... codes; installed runtimes are controls, not the target.

Implemented on codex/runtime-port in dc6231ea44034b5ec8a52193623b67a8516e5f07. Home now ports all 30 mappings. Six corrupt-input classes plus the truncated-input control are checked through sync, promisified callback and stream-pipeline surfaces, followed by a successful round trip. Seven unchanged pinned Brotli Node fixtures, test-stream-iter-transform-errors.js, the native regression and error-reentrancy suite pass.

The separate async-buffer detachment/write-result lifetime gap in #516 is now implemented in 095f90396. The complete unchanged zlib.test.js now passes 378 tests / 434 assertions, with 2 skips and 0 failures; bounds and reentrancy files pass 9/9 and 3/3. This supersedes the previous 377 pass / 1 fail checkpoint. Both fixes are now integrated in main; other-platform and broader compression parity remain unverified. This issue stays open for platform verification.

Evidence: zig-out/stream-codec-h2-zlib-results.json, per-case output, brotli-error-contract.mjs, and stream-codec-h2-source-integrity.json.

Related remaining stream work: #514. Full port: #66.

9 days ago

Reverified unchanged on the final binary from fde7b7ebc64a2d327a1665578d4b396f8a5e93a1 (#512): the full 252-file stream scan still passes 246/252, with the same six failing filenames/statuses as the parent. This issue’s failure remains open; making the reduced-realm unit suite green did not count it as fixed. See #66 and the related #514 for the other remaining stream failures. Evidence: zig-out/stream-final-all-results.json, stream-final-comparison.json.

9 days ago

Implemented and verified on codex/runtime-port at dc6231e.

Home now follows exact pin 4982b91e3702094330f3be3883354c52b8c01323 for all 30 Brotli decoder enum codes: the error prefix is ERR__, preserving the enum suffix's leading underscore. The regression checks six distinct corrupt-input classes (plus the truncated-input Z_BUF_ERROR control) through sync, promisified callback and stream-pipeline APIs, then confirms a successful round trip after the errors.

Verification on Darwin arm64:

  • 7 unchanged pinned Brotli Node fixtures pass, including the bounded 16 GB high-water-mark fixture;
  • unchanged test-stream-iter-transform-errors.js now passes;
  • native-error-codes.test.mjs and the 3-test error-reentrancy suite pass;
  • the complete unchanged zlib.test.js is 377 pass / 2 skip / 1 fail / 429 assertions. Its sole failure is the separate async buffer detachment defect tracked in #516, so this is not a full compression-parity claim.

Evidence: zig-out/stream-codec-h2-zlib-results.json, per-case output, brotli-error-contract.mjs, and stream-codec-h2-source-integrity.json. The full port remains open under #66.

9 days ago

Integration status corrected on 2026-09-21: both dc6231ea44034b5ec8a52193623b67a8516e5f07 and 095f9039692e547b5fc07f6c6fe6080d01e827b4 are ancestors of current main (58a2f2b427e6038bd8b103133cbec042551c9865). The unchanged full js/node/zlib/zlib.test.js passes on the current ReleaseFast Home binary at 378 pass / 2 upstream zstd skips / 0 fail / 434 assertions. Integration is complete; this issue remains open only for its stated broader/platform verification boundary.

9 days ago

Source d1843551a now owns ten additional registry modules: crypto, zlib, zlib/iter, promisification and six legacy stream entry points. The explicit ownership list is 90 modules plus the internal test adapter. Home compiles the StringDecoder implementation and factory with an exact linked class-header ABI. Generation rejects duplicate/missing factory includes and source ownership before output.

The original corpus exposed real missing behavior: the generator's keepNames option was in the wrong object; SHAKE's capability export was a false-returning stub; streaming signature requests needed one-shot/key-agreement capability validation. These are fixed. Forced-drain callbacks enter an event-loop scope and nested Debug scopes restore parent state correctly. Pinned zlib getter values survive close/allocation paths. Valid cryptographic operations still execute through the backend.

The complete 193 unchanged original entries validate 1,357 registered passes + 147 process checks, zero failures. 24 registered skips, one TODO, three skipped files and 16 comment-only entries receive no passing credit. All ten native groups pass, including compression buffer lifetime and crypto/compression worker shutdown. ABI 74 tests / 1,220 assertions; Debug 34/34, peak 5,658 MB under 8,192 MB; complete tests 2,383 MB under 3,840 MB. Pickier and scoped formatting/whitespace checks pass.

All 3,785 committed archives verify; all 193 completed reports restore and validate. Initial four-file failures and the repair's remaining key-agreement failure are retained. A direct zlib diagnostic passed before the callback-scope fix; the initial panic is not claimed to reproduce in every context. Every selected test matches the pin. Four pre-existing URL/ICU fixture differences outside this selection are recorded. Unsupported/unapplied Node/V8 metadata flags receive no feature-parity credit. Source bytes remain unchanged across main integration.

This advances #66, #513, #516 and #587. Remaining registry/native dependencies, original pending outcomes, whole-suite and Release/ASAN/all-platform verification stay open.

The Linux/Windows and remaining broader verification requirements on this issue remain open.

Sign in to comment on this issue.