Files
rose-ash/tests
giles f12c19eaa3
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 22s
HS: test runner — unwrap value handles before native interop
The new kernel ABI wraps atoms (number, string, boolean, nil) in opaque
handles {_type, __sx_handle}. When such handles flow through host-call
into native JS functions, value equality breaks: each integer literal
becomes a unique handle object, so JS Set.add(handle_for_1) does NOT
dedup against a prior set.add(handle_for_1). Same problem for any JS
API that uses identity or value equality on incoming arguments.

Fix: add _unwrapHandle that converts handles back to JS primitives via
K.stringify, and apply it to argument lists in host-call and host-new
(the two natives that pass user values into native JS constructors /
methods). Forward-compatible: no-op when called with already-unwrapped
plain values from the legacy kernel.

Root-cause analysis traced through:
  1. Test 27 'can append a value to a set' failed (Expected 3, got 4)
     on the new WASM only. Set was admitting duplicates.
  2. dbg-set.js minimal repro confirmed each `1` literal arriving at
     set.add as a different {_type, __sx_handle} object.
  3. JS Set.add uses SameValueZero — handle objects with the same
     underlying value are still distinct identity.
  4. Unwrapping in host-call/host-new resolves the equality issue.

This is preparation for the JIT Phase 1 WASM rollout (which still
needs more native-interop unwrap audits before it can replace the
pre-merge WASM that the test tree currently pins).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 21:04:30 +00:00
..