From b8f389ac9b6637aef2ad9dc89f474877dbe93898 Mon Sep 17 00:00:00 2001 From: giles Date: Sun, 5 Apr 2026 01:16:03 +0000 Subject: [PATCH] Import hook: verify library registered, re-entry guard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - _import_hook verifies library_loaded_p AFTER load_library_file to catch cases where the file loads but define-library doesn't register - Re-entry guard (_loading_libs) prevents infinite retry loops - cek_run import patch deferred — retry approach infinite-loops because cek_step_loop re-enters deeply nested eval contexts. Root cause: eval_expr → cek_run → cek_step_loop processes the ENTIRE remaining kont chain after import resolution, which includes rendering code that triggers MORE eval_expr calls. Needs architectural solution (step-level suspension handling, not run-level). Server runs with 4 harmless IO suspension errors. These don't affect functionality — symbols load via the global env. Co-Authored-By: Claude Opus 4.6 (1M context) --- hosts/ocaml/bin/sx_server.ml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hosts/ocaml/bin/sx_server.ml b/hosts/ocaml/bin/sx_server.ml index 74e9469c..a9fdc7a5 100644 --- a/hosts/ocaml/bin/sx_server.ml +++ b/hosts/ocaml/bin/sx_server.ml @@ -807,7 +807,9 @@ let () = Hashtbl.replace _loading_libs key true; let result = match resolve_library_path lib_spec with | Some path -> - (try load_library_file path; true + (try load_library_file path; + (* Verify the library actually registered *) + Sx_types.sx_truthy (Sx_ref.library_loaded_p lib_spec) with e -> Printf.eprintf "[import-hook] FAIL %s from %s: %s\n%!" key path (Printexc.to_string e);