summaryrefslogtreecommitdiff
path: root/ocaml/scripts/inspect_event.ml
diff options
context:
space:
mode:
Diffstat (limited to 'ocaml/scripts/inspect_event.ml')
-rw-r--r--ocaml/scripts/inspect_event.ml77
1 files changed, 77 insertions, 0 deletions
diff --git a/ocaml/scripts/inspect_event.ml b/ocaml/scripts/inspect_event.ml
new file mode 100644
index 0000000..569f103
--- /dev/null
+++ b/ocaml/scripts/inspect_event.ml
@@ -0,0 +1,77 @@
+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 rec print_noun_structure noun depth =
+ let indent = String.make (depth * 2) ' ' in
+ match noun with
+ | Noun.Atom z ->
+ let size = Z.numbits z in
+ if size <= 64 then
+ Printf.printf "%sAtom: %s (0x%s, %d bits)\n"
+ indent (Z.to_string z) (Z.format "%x" z) size
+ else
+ Printf.printf "%sAtom: <large %d bits>\n" indent size
+ | Noun.Cell (h, t) ->
+ Printf.printf "%sCell:\n" indent;
+ Printf.printf "%s Head:\n" indent;
+ print_noun_structure h (depth + 2);
+ Printf.printf "%s Tail:\n" indent;
+ print_noun_structure t (depth + 2)
+
+let () =
+ if Array.length Sys.argv < 2 then begin
+ Printf.printf "Usage: %s <event_number>\n" Sys.argv.(0);
+ exit 1
+ end;
+
+ let event_num = Int64.of_string Sys.argv.(1) in
+ let pier_path = Filename.concat project_root "test-pier" in
+
+ if not (Sys.file_exists pier_path) then begin
+ Printf.printf "Test pier not found at: %s\n" pier_path;
+ Printf.printf "Run test_pier_boot.exe first\n";
+ exit 1
+ end;
+
+ Printf.printf "\n╔═══════════════════════════════════════════════════════╗\n";
+ Printf.printf "║ Event Inspector ║\n";
+ Printf.printf "╚═══════════════════════════════════════════════════════╝\n\n";
+
+ let eventlog = Eventlog.create ~enabled:false pier_path in
+
+ Printf.printf "Reading event %Ld from test pier...\n\n" event_num;
+
+ let event = Eventlog.read_event eventlog event_num in
+
+ Printf.printf "Event structure:\n";
+ print_noun_structure event 0;
+
+ Printf.printf "\n";
+
+ (* Check if it's a timestamped event [timestamp data] *)
+ match event with
+ | Noun.Cell (Noun.Atom timestamp, event_data) ->
+ Printf.printf "✓ Event is properly timestamped!\n";
+ Printf.printf " Timestamp: %s\n" (Z.to_string timestamp);
+ Printf.printf " Timestamp (hex): 0x%s\n" (Z.format "%x" timestamp);
+ Printf.printf " Timestamp bits: %d\n" (Z.numbits timestamp);
+ Printf.printf "\n Event data structure:\n";
+ print_noun_structure event_data 2
+ | _ ->
+ Printf.printf "⚠ Event does NOT appear to be timestamped!\n";
+ Printf.printf " Expected: [timestamp event_data]\n";
+ Printf.printf " Got something else\n"