summaryrefslogtreecommitdiff
path: root/ocaml/scripts/test_lifecycle_boot.ml
diff options
context:
space:
mode:
Diffstat (limited to 'ocaml/scripts/test_lifecycle_boot.ml')
-rw-r--r--ocaml/scripts/test_lifecycle_boot.ml74
1 files changed, 74 insertions, 0 deletions
diff --git a/ocaml/scripts/test_lifecycle_boot.ml b/ocaml/scripts/test_lifecycle_boot.ml
new file mode 100644
index 0000000..77ca16b
--- /dev/null
+++ b/ocaml/scripts/test_lifecycle_boot.ml
@@ -0,0 +1,74 @@
+open Nock_lib
+
+let rec find_project_root dir =
+ let pills_dir = Filename.concat dir "pills" in
+ if Sys.file_exists pills_dir && Sys.is_directory pills_dir then dir
+ else
+ let parent = Filename.dirname dir in
+ if String.equal parent dir then failwith "unable to locate project root containing pills/"
+ else find_project_root parent
+
+let project_root =
+ match Sys.getenv_opt "NEOVERE_ROOT" with
+ | Some root -> root
+ | None ->
+ let exe_dir = Filename.dirname Sys.executable_name in
+ find_project_root exe_dir
+
+let () =
+ Printf.printf "\n╔═══════════════════════════════════════════════════════╗\n";
+ Printf.printf "║ Lifecycle Formula Boot Test ║\n";
+ Printf.printf "╚═══════════════════════════════════════════════════════╝\n\n";
+
+ let pier_path = Filename.concat project_root "test-pier-lifecycle" in
+ Printf.printf "Creating test pier at: %s\n%!" pier_path;
+
+ if Sys.file_exists pier_path then begin
+ Printf.printf "Removing old test pier...\n%!";
+ let _ = Sys.command (Printf.sprintf "rm -rf '%s'" pier_path) in
+ ()
+ end;
+
+ Unix.mkdir pier_path 0o755;
+
+ Printf.printf "\n[1] Creating state...\n%!";
+ let state = State.create ~pier_path () in
+
+ Printf.printf "\n[2] Booting ivory.pill...\n%!";
+ let ivory_path = Filename.concat project_root "pills/ivory.pill" in
+ begin match Boot.boot_ivory state ivory_path with
+ | Error (Boot.Invalid_pill msg) ->
+ Printf.printf "✗ Ivory boot failed: %s\n%!" msg;
+ exit 1
+ | Error (Boot.Unsupported msg) ->
+ Printf.printf "✗ Unsupported: %s\n%!" msg;
+ exit 1
+ | Ok () ->
+ Printf.printf "✓ Ivory kernel loaded\n\n%!";
+ end;
+
+ Printf.printf "[3] Booting solid.pill with lifecycle formula...\n%!";
+ let solid_path = Filename.concat project_root "pills/solid.pill" in
+
+ begin match Boot.boot_solid_lifecycle state solid_path with
+ | Error (Boot.Invalid_pill msg) ->
+ Printf.printf "✗ Solid boot failed: %s\n%!" msg;
+ exit 1
+ | Error (Boot.Unsupported msg) ->
+ Printf.printf "✗ Unsupported: %s\n%!" msg;
+ exit 1
+ | Ok () ->
+ let eve = State.event_number state in
+ Printf.printf "✓ Solid boot completed via lifecycle formula!\n%!";
+ Printf.printf " Events in state: %Ld\n\n%!" eve;
+
+ (* Get kernel and compute mug for verification *)
+ let kernel = State.arvo_core state in
+ Printf.printf " Kernel is_cell: %b\n" (Noun.is_cell kernel);
+
+ Printf.printf "\n╔═══════════════════════════════════════════════════════╗\n";
+ Printf.printf "║ Lifecycle Boot SUCCESS! 🎉 ║\n";
+ Printf.printf "╚═══════════════════════════════════════════════════════╝\n\n";
+ end;
+
+ State.close_eventlog state