ReviewOS

zig-utils/zig-js

NaN-box proof: make ValueNB StringData representation-aware

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

Parents: #470, #473 Related: #697

Problem

The standalone ValueNB compatibility/proof type claims semantic equivalence with the live NaN-boxed Value, but exposes only physical StringCell bytes and hard-codes canonical storage when parsing a string number. Its existing string proof compares canonical input directly with asStr(). With flat Latin-1 enabled, that proof fails on ünïcödé because raw fc/f6/e9 storage is interpreted as UTF-8, and the model has no representation-aware semantic-byte API matching production Value.

ValueNB is not wired into production dispatch; this issue repairs the proof contract so future representation work cannot validate against a stale model. Every Promise, stack, queue, job, Worker, and shared Map/Set iterator surface is explicitly excluded and remains user-owned.

Scope

  • Add StringCell access/classification and canonical WTF-8 projection to ValueNB, matching production Value semantics.
  • Pass the actual flat-Latin-1 representation to numeric string parsing.
  • Compare ValueNB physical storage against live Value physical storage, and compare semantic output against canonical source text.
  • Preserve the one-word layout, allocator-free literal/runtime interning contract, and all existing kind/object/number behavior.
  • Cover conversion allocation failure when flat storage requires a transcode.

No-workaround rules

  • No flat-storage disablement, lossy decoding, canonical-copy storage in ValueNB, weakened non-ASCII witness, test-only branch, or second compatibility representation.
  • No Promise, stack, queue, job, Worker, or shared Map/Set iterator changes.

Acceptance

  • ValueNB remains exactly one machine word and exposes the same physical-versus-semantic StringData distinction as production Value.
  • Canonical and forced-flat ValueNB string proofs pass for ASCII and non-ASCII inputs.
  • Numeric parsing uses the real representation flag and conversion OOM is explicit.
  • Focused Debug, forced-flat Debug, ReleaseSafe, TSan, and full units pass.
  • This internal proof has 0 applicable Test262 cases and makes no conformance claim.
9 days ago

Landed in fix(nanbox): align ValueNB StringData semantics (#702).

Validation:

  • Stale forced-flat proof: non-ASCII semantic comparison fails on physical fc/f6/e9 bytes.
  • Repaired proof: 3/3 in Debug, forced-flat Debug, ReleaseSafe, and TSan.
  • String checks now cover live-Value physical parity, canonical semantic output, Latin-1 NBSP numeric whitespace, explicit flat-transcode OOM, and allocation-free canonical borrowing.
  • Full units: 1,795 passed, 1 skipped, 0 failed, 0 leaked.
  • Internal proof only: 0 applicable Test262 cases; flips 0 cases.

ValueNB remains one machine word and production dispatch is unchanged.

Sign in to comment on this issue.