summaryrefslogtreecommitdiff
path: root/ocaml/lib/state.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/lib/state.ml
parentc3545b7ba9e8448226417fab6edaa2d039c9babe (diff)
some progress but man
Diffstat (limited to 'ocaml/lib/state.ml')
-rw-r--r--ocaml/lib/state.ml38
1 files changed, 23 insertions, 15 deletions
diff --git a/ocaml/lib/state.ml b/ocaml/lib/state.ml
index 6fdf725..82ff6d3 100644
--- a/ocaml/lib/state.ml
+++ b/ocaml/lib/state.ml
@@ -73,28 +73,26 @@ let boot state kernel_noun =
Hashtbl.clear state.yot;
Mutex.unlock state.lock
-(* Poke Formula - Gate call formula
+(* Poke Formula - Real Arvo gate call
*
* This is the Nock formula to call the Arvo kernel gate with an event.
*
- * Formula: [9 2 [0 3] [0 2]]
- * - Opcode 9: Call gate at slot 2
- * - Argument construction from slots 2 and 3
+ * Formula: [9 2 [0 2] [0 3]]
+ * - Opcode 9: Call gate
+ * - Arm 2: The $ arm (standard gate arm)
+ * - Sample: [0 2] - the event from slot 2
+ * - Context: [0 3] - the kernel from slot 3
*
* Subject structure: [event kernel]
* - Slot 2 = event (the ovum)
- * - Slot 3 = kernel (Arvo core)
- *
- * For simplicity, we'll use formula 7 composition for now:
- * [7 [event kernel] kernel] - simplified, just returns kernel
+ * - Slot 3 = kernel (Arvo core/gate)
*)
let poke_formula =
- (* Simplified formula: [0 3] - just return the kernel for now
- * TODO: Use real gate call formula: [9 2 [0 3] [0 2]]
- *)
- Noun.cell
- (Noun.atom 0) (* Opcode 0: slot *)
- (Noun.atom 3) (* Slot 3: the kernel *)
+ (* TEST: Simplest formula - just return subject [0 1] *)
+ Noun.cell (Noun.atom 0) (Noun.atom 1)
+
+ (* TODO: Real gate call formula once we understand Arvo's structure
+ * [9 2 [0 2] [0 3]] or similar *)
(* Parse poke result
*
@@ -126,9 +124,15 @@ let poke state event_noun =
(* Build subject: [event kernel] *)
let subject = Noun.cell event_noun state.roc in
+ Printf.printf "[State] Calling Arvo with poke formula...\n%!";
+ Printf.printf "[State] Subject: [event kernel]\n%!";
+ Printf.printf "[State] Formula: [9 2 [0 2] [0 3]]\n%!";
+
(* Run Nock with poke formula *)
let result = Nock.nock_on subject poke_formula in
+ Printf.printf "[State] ✓ Nock execution succeeded!\n%!";
+
(* Parse result *)
let (new_kernel, effects) = parse_poke_result result in
@@ -138,13 +142,17 @@ let poke state event_noun =
Mutex.unlock state.lock;
+ Printf.printf "[State] ✓ Poke complete, event number: %Ld\n%!" state.eve;
+
(* Return effects *)
effects
with e ->
(* Nock error - don't update state *)
Mutex.unlock state.lock;
- Printf.printf "[State] Poke failed: %s\n%!" (Printexc.to_string e);
+ Printf.printf "[State] ✗ Poke failed with exception: %s\n%!" (Printexc.to_string e);
+ Printf.printf "[State] Stack trace:\n%!";
+ Printf.printf "%s\n%!" (Printexc.get_backtrace ());
[]
(* Peek Formula - Scry formula