diff options
author | polwex <polwex@sortug.com> | 2025-10-06 23:18:59 +0700 |
---|---|---|
committer | polwex <polwex@sortug.com> | 2025-10-06 23:18:59 +0700 |
commit | 5de3f7a3ad7b0cf63b4a6cbddfc1e26359dea161 (patch) | |
tree | b55b2258123149bed40bd89bbaa58e7da54f3a26 /ocaml/test/old/test_ivory_boot.ml | |
parent | fdab65f6dac4ba85ed4749f61970660d1132d453 (diff) |
cleaned up tests
Diffstat (limited to 'ocaml/test/old/test_ivory_boot.ml')
-rw-r--r-- | ocaml/test/old/test_ivory_boot.ml | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/ocaml/test/old/test_ivory_boot.ml b/ocaml/test/old/test_ivory_boot.ml new file mode 100644 index 0000000..f9d511a --- /dev/null +++ b/ocaml/test/old/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_lite ~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 |