(* Examine what the bot/mod/use events actually contain *) open Nock_lib let describe_noun noun = match noun with | Noun.Atom a -> if Z.numbits a <= 64 then Printf.sprintf "Atom(%s)" (Z.to_string a) else Printf.sprintf "Atom(%d bits)" (Z.numbits a) | Noun.Cell _ -> "Cell" let rec to_list acc noun = match noun with | Noun.Atom _ -> List.rev acc | Noun.Cell (item, rest) -> to_list (item :: acc) rest let examine _env = Printf.printf "Loading solid.noun...\n"; let in_channel = open_in_bin "solid.noun" in let pill = (Marshal.from_channel in_channel : Noun.noun) in close_in in_channel; match pill with | Noun.Cell (_tag, events) -> Printf.printf "\n=== solid.noun structure ===\n\n"; let event_list = to_list [] events in Printf.printf "Total: %d items in list\n\n" (List.length event_list); List.iteri (fun i event -> Printf.printf "Item %d: %s\n" i (describe_noun event) ) event_list; (* Check if this matches what u3v_life expects *) Printf.printf "\n=== Testing u3v_life on this list ===\n\n"; (* Functional BIOS formula: [2 [0 3] [0 2]] *) let lyf = Noun.cell (Noun.atom 2) (Noun.cell (Noun.cell (Noun.atom 0) (Noun.atom 3)) (Noun.cell (Noun.atom 0) (Noun.atom 2))) in Printf.printf "Running [2 [0 3] [0 2]] on events...\n%!"; begin try (* What does [0 2] get from events? *) let slot2 = Noun.slot (Z.of_int 2) events in Printf.printf " Slot 2 of events: %s\n" (describe_noun slot2); (* What does [0 3] get from events? *) let slot3 = Noun.slot (Z.of_int 3) events in Printf.printf " Slot 3 of events: %s\n\n" (describe_noun slot3); let start = Unix.gettimeofday () in let gat = Nock.nock_on events lyf in let elapsed = Unix.gettimeofday () -. start in Printf.printf "āœ“ Formula succeeded in %.4fs!\n\n" elapsed; (* Extract slot 7 *) let kernel = Noun.slot (Z.of_int 7) gat in Printf.printf "āœ“ Extracted kernel from slot 7\n\n"; (* Check if kernel has slot 23 *) begin try let _poke = Noun.slot (Z.of_int 23) kernel in Printf.printf "āœ“ Kernel has poke at slot 23\n"; Printf.printf "\nšŸŽ‰ This is the correct event list format!\n" with _ -> Printf.printf "āœ— No slot 23\n" end with | Not_found -> Printf.printf "āœ— Slot not found\n" | Noun.Exit -> Printf.printf "āœ— Nock Exit\n" | e -> Printf.printf "āœ— Error: %s\n" (Printexc.to_string e) end | Noun.Atom _ -> Printf.printf "Pill is atom\n" let () = Eio_main.run examine