From f12bbae6c96fbdede14c05df24ece76b62ed79fa Mon Sep 17 00:00:00 2001 From: giles Date: Thu, 19 Mar 2026 20:57:59 +0000 Subject: [PATCH] 40/40 VM tests pass, auto-compile disabled until full aser compilation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All VM tests green: closures with shared mutable upvalues, map/filter/ for-each via CALL_PRIM, recursive functions, nested closures. Auto-compile disabled: replacing individual Lambdas with NativeFn VM wrappers changes how the CEK dispatches calls, causing scope errors when mixed CEK+VM execution hits aser-expand-component. The fix is compiling the ENTIRE aser render path to run on the VM — no mixing. The VM infrastructure is complete and tested. Next step: compile adapter-sx.sx as a whole module, run the aser on the VM. Co-Authored-By: Claude Opus 4.6 (1M context) --- hosts/ocaml/bin/sx_server.ml | 10 +++++++--- shared/sx/ocaml_bridge.py | 9 ++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/hosts/ocaml/bin/sx_server.ml b/hosts/ocaml/bin/sx_server.ml index c5c55c3..c65b40f 100644 --- a/hosts/ocaml/bin/sx_server.ml +++ b/hosts/ocaml/bin/sx_server.ml @@ -831,7 +831,8 @@ let dispatch env cmd = let names = Hashtbl.fold (fun k _ acc -> k :: acc) env.bindings [] in List.iter (fun name -> match Hashtbl.find_opt env.bindings name with - | Some (Lambda lam) when lam.l_name <> None -> + | Some (Lambda lam) when lam.l_name <> None + && lam.l_closure.parent = None -> (try let quoted = List [Symbol "quote"; lam.l_body] in let result = Sx_ref.eval_expr (List [compile_fn; quoted]) (Env env) in @@ -857,8 +858,11 @@ let dispatch env cmd = incr count | _ -> incr failed with e -> - if !failed < 5 then - Printf.eprintf "[vm] FAIL %s: %s\n%!" name (Printexc.to_string e); + if !failed < 3 then + Printf.eprintf "[vm] FAIL %s: %s\n body: %s\n%!" + name (Printexc.to_string e) + (String.sub (inspect lam.l_body) 0 + (min 200 (String.length (inspect lam.l_body)))); incr failed) | _ -> () ) names; diff --git a/shared/sx/ocaml_bridge.py b/shared/sx/ocaml_bridge.py index 3f80c24..d281b06 100644 --- a/shared/sx/ocaml_bridge.py +++ b/shared/sx/ocaml_bridge.py @@ -265,9 +265,12 @@ class OcamlBridge: _logger.info("Loaded %d definitions from .sx files into OCaml kernel (%d skipped)", count, skipped) - # VM auto-compile: ready when compiler handles all SX features. - # Currently 6/117 compile; fallback fails on closure scope vars. - # await self._send('(vm-compile)') + # VM bytecode infrastructure ready. Auto-compile disabled: + # compiled NativeFn wrappers change CEK dispatch behavior + # causing scope errors in aser-expand-component. The VM + # tests (40/40) verify correctness in isolation. + # Enable after: full aser adapter compilation so the ENTIRE + # render path runs on the VM, not mixed CEK+VM. except Exception as e: _logger.error("Failed to load .sx files into OCaml kernel: %s", e) self._components_loaded = False # retry next time