feat(v4.0.0): address faults -- an address outside memory is guarded (D-14)

Ruled 2026-10-04: guarded, an error shown, back to the prompt.

- The executor checks every address a programme uses (P, A, B) before
  using it.  Outside memory the opcode does nothing, the rest of its word
  is not executed, and P becomes the node's fault handler; a node with no
  handler stops.  v4_node_load/store never index outside memory.
- capsule/quit.v4: (FAULT), the host node's handler, prints
  "Address out of range", ends an open definition, prints ERROR and
  returns to the prompt.
- tests: every memory opcode and P in test_exec.c; from the prompt, from
  inside nested words and loops, in test_host_quit.c.

This closes the hole node.h described: a wild address used to index the
model's own memory gigabytes out of bounds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rajames
2026-10-04 12:04:59 -04:00
co-authored by Claude Opus 5.5
parent b5d644d498
commit b3d2d56d11
11 changed files with 277 additions and 74 deletions
+6 -1
View File
@@ -43,7 +43,12 @@ void v4_exec_reset(v4_exec_state *es);
/* Execute one instruction word: fetch at P, advance P, run the slots left to
* right until the word ends. A unext loop runs to completion inside one call,
* so the call does not return while R is nonzero at a `unext`. Returns the
* number of instructions retired. */
* number of instructions retired.
*
* An address outside node memory -- P at the fetch, or the address an opcode
* uses -- is a fault (node.h, D-14): that opcode and the rest of the word do
* not execute, and P is the node's fault handler on return. With no handler
* the node stops, and this does nothing and returns 0 from then on. */
unsigned v4_exec_step_word(v4_node *n, v4_exec_state *es, v4_heat *h);
/* Execute a single opcode. The branch opcodes read their target from `w` and