ReviewOS

zig-utils/zig-js

ABI: implement the pinned TextCodec boundary

#327
Closed chris opened this 9 days ago ·
9 days ago

Parent: #140 Tracked by: #134 Profiles: #163, #164 Pinned consumers: Home 7ed99c02, Bun 4982b91e

Problem

Both declared private profiles require the same six TextCodec exports. This is Bun's fallback codec registry: native UTF-8, UTF-16, and Latin-1 are intentionally handled outside this boundary. The opaque codec must preserve exact label canonicalization, incremental state, BOM policy where applicable, error reporting, and owned BunString results.

Scope

  • Implement Bun__createTextCodec, Bun__deleteTextCodec, and Bun__decodeWithTextCodec with stable opaque ownership and streaming state.
  • Implement Bun__stripBOMFromTextCodec with the pinned codec-specific behavior.
  • Implement Bun__isEncodingSupported and Bun__getCanonicalEncodingName from one immutable, case-insensitive alias registry with stable canonical-name storage.
  • Match the pinned registry: x-user-defined; replacement aliases; Big5, EUC-JP, Shift_JIS, EUC-KR, ISO-2022-JP, GBK, gb18030; and the eleven pinned single-byte codecs. Preserve the deliberate absence of native UTF-8/UTF-16/Latin-1 and blocklisted UTF-7/BOCU-1/SCSU names.
  • Preserve the pinned Home/Bun signatures and owned BunString return contract.
  • Regenerate both inventories and extend the compile-link-runtime fixture.

Acceptance

  • Every pinned alias/canonical label is covered, including ASCII case folding, non-ASCII/empty/over-63-byte rejection, unsupported aliases, and process-lifetime canonical-name pointers.
  • Representative and boundary vectors cover each canonical codec, incremental split sequences, flush, BOM handling, replacement, and stop-on-error state reset.
  • Decode results are independently owned and release cleanly; null codec/output pointers and invalid non-empty data pointers fail safely.
  • Home and Bun audits are green, the Home fixture executes all six signatures, and one descendant full CI matrix is accepted.
9 days ago

Implemented on main in two reviewable slices:

  • c5b44ff8 adds the pure-Zig registry and decoders: every pinned alias, replacement/x-user-defined, ten single-byte profiles, seven stateful CJK codecs, and a 215,362-byte embedded index generated only from SHA-256-pinned WebKit inputs.
  • eed1a550 adds all six Home/Bun exports, owned BunString results, the independent consumer fixture, regenerated inventories, and ABI documentation.

The earlier iconv prototype was discarded: the landed implementation is cross-platform, deterministic, and adds no external runtime dependency.

Focused acceptance is green:

  • 8/8 TextCodec unit tests, 0 leaks
  • generator digest verification and byte-for-byte regeneration
  • Home audit: 329/431 private implemented, 102 pending
  • Bun audit: 320/421 private implemented, 101 pending
  • Home consumer: 333/333 linked and runtime matrix passed

Full descendant CI: https://github.com/zig-utils/zig-js/actions/runs/29703497726

Keeping this open until that matrix is accepted.

9 days ago

Accepted by descendant CI run 29703497726: 39 jobs passed, with only the intentional nightly skip. The pinned pure-Zig TextCodec registry/decoders, independent Home fixture, inventories, and full matrix are green.

Sign in to comment on this issue.