feat(v4): the mesh boot to spec -- Hera born empty in the kernel's fabric; births, kills, every node stepping together (#189)

ENGINE step 4 Phase 1, Tasks 5b-5d, and the edge cases (Captain Bob, 2026-11-13: "Build it to proper
spec"; "Check for the edge cases"; "Yes, add it to v4-checks").

- v4/system/mesh.c, v4/include/v4/mesh.h: the nucleus assembled by the ROM and given to Hera as F18
  cells; Hera born empty at place 0, the kernel on port 0, the console on port 1; told she is 10, in the
  registry, the kernel's words, FORTH-79, sealed, POST, the kernel's capsules. NODE-BORN / NODE-KILL in
  the owner's room.
- No scheduler: v4_mesh_tell returns once the node told says how its text ended, and
  v4_mesh_step / v4_mesh_busy let the host step the fabric while it waits, so nodes run between
  lines as during them. A text left "waiting" is owed its end: the next line ends it "Interrupted"
  and is then run (MESH.md 7b.6).
- kernel: sk_v4.c boots through the mesh; its idle steps the fabric while a node can run, and halts
  only when none can (#151 kept). stadium_return_quota and stadium_ops_forget on a kill.
- Tests: v4/tests/test_mesh_boot.c (32 checks: the boot, births, kills, rebirth, a live number, a
  fault, no such node, Hera not killing herself, no room, a line too long, a node running for ever,
  a wait broken by the next line), run by `make -C v4 test` and under ASan+UBSan by `sanitize`
  (v4-checks); kernel/tests quota return; scripts/qemu_session.py births() and the edges on bare
  metal.
- Docs: ENGINE.md 6 "who runs next" struck (settled: no scheduler); the Phase 1 plan; FABRIC-3
  XLVIII.23; .claude/memory/rules.md: alpha.5 closed to new work.
- Evidence: v4-checks 80 programs under the sanitizers, 0 failures; the hosted builds alike; two
  stopped v4-checks runs labelled STOPPED; three development amd64 boots labelled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
Claude
2026-11-13 17:00:08 +00:00
parent d7d3e088db
commit 046ce0be65
34 changed files with 1166 additions and 181 deletions
+40
View File
@@ -495,6 +495,46 @@ def registry():
check("NODE-ME: Hera is at place 0 of the kernel's fabric",
wait_for(PROMPT, 60, n) and re.search(r"(?:^|[^0-9])0\s+ok", text()[-200:]) is not None
and "UNKNOWN WORD" not in text()[-200:])
births()
def births():
"""A node born from Hera in the kernel's fabric, answering, and killed (#189, Phase 1 Task 5d):
11 2 2 BIRTH gives it the nucleus and FORTH-79 (its parity line); Hera sends it a line and awaits
it; 11 KILL removes it, its Stadium quota given back, and conservation holds after."""
n = count(PROMPT)
type_line("11 2 2 BIRTH .")
check("BIRTH: node 11 born from Hera, its parity recorded",
wait_for(PROMPT, 300, n) and re.search(r"PARITY:V4_BIRTH node=11 dict_hash=0x[0-9a-f]{16}", text()) is not None
and "ERROR" not in text()[-300:])
n = count(PROMPT)
type_line('S" 6 7 * ." 11 SEND 11 AWAIT .')
check("node 11 answers Hera: 42, and its text completed",
wait_for(PROMPT, 120, n) and re.search(r"42\s", text()[-300:]) is not None and "ERROR" not in text()[-300:])
c = count(r"Stadium conservation: CONSERVED")
n = count(PROMPT)
type_line("11 KILL")
check("KILL: node 11 removed, the Stadium CONSERVED after",
wait_for(PROMPT, 120, n) and count(r"Stadium conservation: CONSERVED") > c and "ERROR" not in text()[-300:])
# the edges (Captain Bob, 2026-11-13: "Check for the edge cases"): a node set running for ever
# does not hold the console -- it runs on between lines, and is killed
n = count(PROMPT)
type_line("11 2 2 BIRTH .")
check("after a kill, 11 is born again", wait_for(PROMPT, 300, n) and "ERROR" not in text()[-300:])
n = count(PROMPT)
type_line('S" VARIABLE N1 : SPIN BEGIN 1 N1 +! AGAIN ;" 11 SEND 11 AWAIT .')
check("node 11 is given SPIN", wait_for(PROMPT, 120, n) and "ERROR" not in text()[-300:])
n = count(PROMPT)
type_line('S" SPIN" 11 SEND')
check("Hera's line ends, though node 11 runs for ever", wait_for(PROMPT, 120, n) and "ERROR" not in text()[-300:])
n = count(PROMPT)
type_line("3 4 + .")
check("and the prompt answers while it runs: 7 ok", wait_for(PROMPT, 120, n) and re.search(r"7\s+ok", text()[-300:]) is not None)
c = count(r"Stadium conservation: CONSERVED")
n = count(PROMPT)
type_line("11 KILL")
check("a node running for ever is killed, the Stadium CONSERVED after",
wait_for(PROMPT, 120, n) and count(r"Stadium conservation: CONSERVED") > c and "ERROR" not in text()[-300:])
check("POST: PASSED", wait_for(r"POST: PASSED", 900))