summaryrefslogtreecommitdiff
path: root/ocaml/test/test_ivory_boot.ml
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-10-06 10:30:19 +0700
committerpolwex <polwex@sortug.com>2025-10-06 10:30:19 +0700
commit4be1d7f999ffb3eb1c12c54e863b141af21b3fbf (patch)
tree6e33b141cd98985799e02a253dddcf201fec6b74 /ocaml/test/test_ivory_boot.ml
parentc3545b7ba9e8448226417fab6edaa2d039c9babe (diff)
some progress but man
Diffstat (limited to 'ocaml/test/test_ivory_boot.ml')
-rw-r--r--ocaml/test/test_ivory_boot.ml97
1 files changed, 97 insertions, 0 deletions
diff --git a/ocaml/test/test_ivory_boot.ml b/ocaml/test/test_ivory_boot.ml
new file mode 100644
index 0000000..7cada9e
--- /dev/null
+++ b/ocaml/test/test_ivory_boot.ml
@@ -0,0 +1,97 @@
+(* Test Ivory Pill Boot Sequence
+ *
+ * Implements C Vere's u3v_life() lifecycle boot
+ *)
+
+open Nock_lib
+
+let test_ivory_boot env =
+ Printf.printf "šŸŽÆ Testing Ivory Pill Boot (C Vere u3v_life pattern)\n\n";
+
+ Eio.Switch.run @@ fun _sw ->
+ let fs = Eio.Stdenv.fs env in
+
+ (* Create state *)
+ let state = State.create () in
+
+ (* Boot using ivory boot sequence *)
+ Printf.printf "Step 1: Load ivory pill\n";
+ Printf.printf "Step 2: Validate 'ivory' tag\n";
+ Printf.printf "Step 3: Run lifecycle formula [2 [0 3] [0 2]]\n";
+ Printf.printf "Step 4: Extract slot 7 from result\n\n";
+
+ match Boot.boot_ivory ~fs state "ivory.pill" with
+ | Error msg ->
+ Printf.printf "āœ— Boot failed: %s\n%!" msg
+
+ | Ok () ->
+ let arvo = State.get_arvo state in
+ Printf.printf "\n✨ SUCCESS! Ivory pill booted!\n\n";
+
+ (* Verify structure *)
+ Printf.printf "Verifying booted core structure:\n";
+ Printf.printf " Is cell: %s\n" (if Noun.is_cell arvo then "āœ“" else "āœ—");
+
+ if Noun.is_cell arvo then begin
+ let battery = Noun.head arvo in
+ let payload = Noun.tail arvo in
+
+ Printf.printf " Battery: %s\n"
+ (if Noun.is_cell battery then "āœ“ Cell (contains code)" else "Atom");
+ Printf.printf " Payload: %s\n\n"
+ (if Noun.is_cell payload then "āœ“ Cell (contains data)" else "Atom");
+
+ (* Now try the C Vere poke pattern on this booted core *)
+ Printf.printf "Testing if this core has slot 23 (poke interface)...\n";
+ (try
+ let slot_23 = Noun.slot (Z.of_int 23) arvo in
+ Printf.printf " āœ“ Slot 23 exists!\n";
+ Printf.printf " Is formula: %s\n"
+ (if Noun.is_cell slot_23 then "āœ“ Cell" else "Atom");
+
+ (* Try to run poke sequence *)
+ Printf.printf "\nAttempting C Vere poke sequence:\n";
+ Printf.printf " 1. Get slot 23 formula\n";
+ Printf.printf " 2. Run formula on Arvo core\n";
+ Printf.printf " 3. Slam result with test event\n\n";
+
+ let poke_gate = Nock.nock_on arvo slot_23 in
+ Printf.printf " āœ“ Got poke gate from slot 23\n";
+
+ (* Create test event *)
+ let event = Noun.cell (Noun.atom 0) (Noun.atom 42) in
+
+ (* Slam: build [battery [event context]] and call arm 2 *)
+ let battery = Noun.head poke_gate in
+ let context = Noun.tail (Noun.tail poke_gate) in
+ let new_core = Noun.cell battery (Noun.cell event context) in
+ let kick_formula = Noun.cell (Noun.atom 9)
+ (Noun.cell (Noun.atom 2)
+ (Noun.cell (Noun.atom 0) (Noun.atom 1))) in
+
+ let start = Unix.gettimeofday () in
+ let result = Nock.nock_on new_core kick_formula in
+ let elapsed = Unix.gettimeofday () -. start in
+
+ Printf.printf " āœ“ Poke succeeded in %.4fs!\n" elapsed;
+ Printf.printf " Result: %s\n\n"
+ (if Noun.is_cell result then "Cell (effects + new state)" else "Atom");
+
+ Printf.printf "šŸŽ‰ FULL ARVO BOOT SUCCESSFUL!\n";
+ Printf.printf "We have a working Arvo instance!\n"
+
+ with e ->
+ Printf.printf " āœ— Slot 23 not found: %s\n" (Printexc.to_string e);
+ Printf.printf "\nThis is expected for ivory pills.\n";
+ Printf.printf "Ivory contains %%zuse core, not full Arvo.\n";
+ Printf.printf "For full poke interface, need solid/brass pill.\n")
+ end
+
+let () =
+ Printf.printf "\n";
+ Printf.printf "═══════════════════════════════════════════════════════════\n";
+ Printf.printf " Testing Ivory Pill Boot Sequence (u3v_life)\n";
+ Printf.printf "═══════════════════════════════════════════════════════════\n";
+ Printf.printf "\n";
+
+ Eio_main.run test_ivory_boot