feat(v4): Phase 7 Task 1 -- v3's physics fields on the word records, and each node's physics state (#189)

v4_mesh_account gains v3's DictPhysics: heat (execution_heat), last_decay_tick, temperature_q8, and the
kernel's own state flags (pinned, frozen); v4_mesh_physics gives each node v3's VM fields -- its tick,
the decay slope (v3's initial 21845, Q48.16), L8's gate on Loop #3. v4_mesh_state_flags derives a word's
flags as v3 does, immediate and hidden read from the node's header when asked. Test first:
test_mesh_boot.c, 48 checks. The kernel gives each of its 16 places its physics. Not pushed (held,
Captain Bob 2026-11-13: "Hold it, go ahead with Task 1").

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 20:00:28 +00:00
parent 41f8c1ec28
commit 922451cf52
5 changed files with 69 additions and 0 deletions
+15
View File
@@ -35,6 +35,7 @@ static v4_image im;
static v4_mesh ms;
static v4_mesh_account accounts[PLACES * V4_MESH_WORD_IDS]; /* the words' records (#189, Phase 2) */
static unsigned char is_word[PLACES * (V4_NODE_WORDS / 8u)];
static v4_mesh_physics physics[PLACES];
static unsigned forgotten;
static v4_cell forgotten_id = -1;
static void forgot(void *self, unsigned place, v4_cell id) { (void)self; (void)place; forgotten++; forgotten_id = id; }
@@ -89,6 +90,7 @@ int main(void)
ms.out = out; ms.key = key; ms.words = words; ms.word_count = 1; ms.serve = serve;
ms.capsules = capsules; ms.capsule_count = 2; ms.im = &im; ms.self = 0;
ms.accounts = accounts; ms.is_word = is_word; ms.forgot = forgot;
ms.physics = physics;
/* ---- the boot ---- */
CHECK(v4_mesh_boot(&ms) == 1, "the boot: %s", said);
@@ -184,6 +186,19 @@ int main(void)
a = v4_mesh_account_at(&ms, 0, xt);
CHECK(how == V4_TEXT_COMPLETED && xt > 0 && a && a->calls == 0 && a->xt == xt,
"a word defined at the prompt has a record, called 0 times: \"%s\"", r);
/* Phase 7, Task 1: v3's physics on the record (DictPhysics; v3/include/vm.h) */
CHECK(a && a->heat == 0 && a->temperature_q8 == 0 && a->last_decay_tick == 0 && a->state_flags == 0,
"a new word's physics: no heat, no temperature, never decayed, no state flags");
CHECK(ms.physics[0].decay_slope_q48 == 21845u && ms.physics[0].l3_decay == 1,
"each node has v3's initial decay slope (Q48.16, 1/3) and Loop #3 on");
r = line(V4_MESH_HERA, ": IMM ; IMMEDIATE ' IMM .", &how);
{
v4_cell ix = (v4_cell)strtol(r, 0, 10);
CHECK(v4_mesh_state_flags(&ms, 0, ix) == V4_MESH_STATE_IMMEDIATE,
"a word's state flags, as v3 derives them: IMMEDIATE, read from its header when asked");
CHECK(v4_mesh_state_flags(&ms, 0, xt) == 0, "and none for SQ");
}
r = line(V4_MESH_HERA, "FORGET IMM", &how);
r = line(V4_MESH_HERA, "3 SQ .", &how);
CHECK(strcmp(r, "9 ") == 0 && a && a->calls == 1, "a call to it counts one: %lu", a ? (unsigned long)a->calls : 0ul);
r = line(V4_MESH_HERA, "5 SQ 6 SQ + .", &how);