Fix CSSX colour rules: reset cssx-resolve JIT to force CEK

cssx-resolve has a complex cond with nested and conditions that the
JIT compiler miscompiles — the colour branch is skipped even when
all conditions are true. Reset to jit_failed_sentinel after loading
so it runs on CEK (which evaluates correctly).

Added vm-reset-fn kernel command for targeted JIT bypass.

All CSSX colour tokens now generate rules: text-violet-699,
text-stone-500, bg-stone-50, etc.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-23 16:49:49 +00:00
parent 364fbac9e1
commit b1de591e9e
2 changed files with 22 additions and 0 deletions

View File

@@ -1008,6 +1008,18 @@ let rec dispatch env cmd =
| Eval_error msg -> send_error msg
| exn -> send_error (Printexc.to_string exn))
| List [Symbol "vm-reset-fn"; String name] ->
(* Reset a function's JIT-compiled bytecode, forcing CEK interpretation.
Used to work around JIT compilation bugs in specific functions. *)
(match Hashtbl.find_opt env.bindings name with
| Some (Lambda l) ->
l.l_compiled <- Some Sx_vm.jit_failed_sentinel;
Printf.eprintf "[jit] reset %s (forced CEK)\n%!" name;
send_ok ()
| _ ->
Printf.eprintf "[jit] reset %s: not found or not lambda\n%!" name;
send_ok ())
| List [Symbol "aser-blob"] ->
(* Like aser but reads source as a binary blob. *)
let src = read_blob () in

View File

@@ -439,6 +439,16 @@ class OcamlBridge:
skipped += 1
_logger.warning("OCaml load skipped %s: %s",
filepath, e)
# JIT workaround: reset functions with known compilation bugs.
# cssx-resolve has a complex cond that the JIT miscompiles
# (colour branch skipped even when conditions are true).
# Resetting forces CEK interpretation.
try:
await self._send('(vm-reset-fn "cssx-resolve")')
await self._read_until_ok(ctx=None)
except OcamlBridgeError:
pass
# SSR overrides: effect is a no-op on the server (prevents
# reactive loops during island SSR — effects are DOM side-effects)
try: