blob: 7e37516487a04bc75113dcc8ab227863d2a494cc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
(* Bisect the ivory pill to find where lifecycle formula diverges *)
open Nock_lib
let lifecycle_formula = Noun.cell
(Noun.atom 2)
(Noun.cell
(Noun.cell (Noun.atom 0) (Noun.atom 3))
(Noun.cell (Noun.atom 0) (Noun.atom 2)))
let test_lifecycle subject_name subject =
Printf.printf "Testing: %s\n" subject_name;
Printf.printf " Subject mug: 0x%08lx\n" (Noun.mug subject);
(* Check if subject has valid structure for lifecycle *)
if not (Noun.is_cell subject) then begin
Printf.printf " SKIP: subject is atom\n\n";
None
end else begin
let slot2 = Noun.head subject in
(* Check if slot 2 is a valid formula *)
if not (Noun.is_cell slot2) then begin
Printf.printf " SKIP: slot 2 is atom (not a formula)\n\n";
None
end else begin
try
let result = Nock.nock_on subject lifecycle_formula in
let result_mug = Noun.mug result in
Printf.printf " Result mug: 0x%08lx\n\n" result_mug;
Some result_mug
with _ ->
Printf.printf " CRASH: nock failed\n\n";
None
end
end
let rec walk_tree prefix subject depth max_depth =
if depth >= max_depth then () else begin
(* Test current node *)
let _ = test_lifecycle prefix subject in
(* Walk children if cell *)
if Noun.is_cell subject then begin
let h = Noun.head subject in
let t = Noun.tail subject in
walk_tree (prefix ^ ".2") h (depth + 1) max_depth;
walk_tree (prefix ^ ".3") t (depth + 1) max_depth
end
end
let () =
Eio_main.run (fun env ->
let fs = Eio.Stdenv.fs env in
Printf.printf "Loading ivory.pill...\n";
let pill_bytes = Eio.Path.(load (fs / "ivory.pill")) |> Bytes.of_string in
let pill = Serial.cue pill_bytes in
let core = Noun.tail pill in
Printf.printf "Ivory core mug: 0x%08lx\n\n" (Noun.mug core);
Printf.printf "Walking tree and testing lifecycle at each node...\n";
Printf.printf "Format: slot path (e.g. '.2.3' = slot 6)\n\n";
(* Reset counters *)
Nock.call_count := 0;
Nock.depth := 0;
(* Walk tree up to depth 5 *)
walk_tree "core" core 0 5
)
|