You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Phase H.5.1: close the safe arr_set bytecode-VM gap
examples/self_healing_h5.omc — `safe arr_set(VAR, idx, val)` now
works through the OMC bytecode VM, not just under tree-walk.
The gap: H.5 emitted `CALL_BUILTIN safe_arr_set` for safe-wrapped
array writes. The bytecode VM's CALL_BUILTIN handler routes
through a synthetic-scope shim (vm_call_builtin → __vm_arg_N
synthetic Variables) that copies the array argument, so the
mutation lived in a temp scope and never propagated back to the
caller's binding.
The fix is the exact pattern V.7c used for ARR_SET_NAMED: take
the variable name out of the value stack and put it on the opcode.
Encoder change:
- SAFE_EXPR branch's arr_set handler now detects bare-VAR first
arg and emits SAFE_ARR_SET_NAMED varname (after pushing idx
and val). Falls back to CALL_BUILTIN for non-VAR shapes
(e.g. nested-array writes), which is no-mutation by design.
Executor change:
- New SAFE_ARR_SET_NAMED handler: pop val, pop raw_idx, look up
arr in current scope by name. Compute healed index via
nearest_fib (already in the file) and Euclidean mod by
arr_len. arr_set on the local clone, scope_set writes back.
Leaves the (mutated) array on the value stack as result.
New demo 4b: `safe arr_set(buf, idx, val)` on a 5-element zero
buffer with idx ∈ {0, 100, -1, 6}. Result: [55, 13, 0, 0, 34] —
every write landed at the fold-and-mod position, every output
has φ=1.000.
Six demos, six convergences. The "known limit" note in the
observation block is replaced with a description of how the
gap was closed.
The Rust VM doesn't need this fix because it already has
ArrSetNamed; H.5's tree-walk path also already worked (it just
didn't reach the bytecode VM). H.5.1 specifically closes the
OMC-written-executor path.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
0 commit comments