feat(v4): Phase 7 Task 3 -- the heartbeat snapshot; the loops complete (#189)

Each cycle publishes v3's HeartbeatSnapshot: the tick, the window's width and fill, the decay slope, and the
dictionary's heat as inference last counted it (words over 50, cooling, the heat in all). One copy, not
v3's two, which are for its heartbeat thread. With it every loop v3 runs before its prompt runs on v4's
word records on every node. Test first: test_mesh_boot.c 73 checks, 81 on. Not pushed.

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-14 00:10:46 +00:00
parent 6d954ac279
commit b5d99ba98b
4 changed files with 34 additions and 1 deletions
+20
View File
@@ -535,6 +535,18 @@ static void inference_tick(unsigned place, v4_mesh_physics *p)
if (!p->is_warm || !x) return;
p->inference_runs++;
window_service(p);
{ /* the dictionary's heat, counted (as v3's) */
uint64_t hot = 0, stale = 0, total = 0;
unsigned k;
for (k = 0; k < V4_MESH_WORD_IDS; k++) {
const v4_mesh_account *a = &accounts_of(place)[k];
if (!a->xt) continue;
if (a->heat > V4_MESH_HOT_HEAT) hot++;
else if (a->heat > 0 && a->heat < 10) stale++;
total += a->heat;
}
p->hot_at_check = hot; p->stale_at_check = stale; p->total_heat_at_check = total;
}
/* the heat of each word in the window, the newest `span` of them, oldest first (v3's extract_heat_trajectory) */
have = p->total_executions < V4_MESH_WINDOW ? p->total_executions : V4_MESH_WINDOW;
span = p->effective_window_size < have ? p->effective_window_size : have;
@@ -571,6 +583,14 @@ static void heartbeat_cycle(unsigned place, v4_mesh_physics *p)
background_decay(place, p);
window_service(p);
l8_update(p);
/* the snapshot (v3's heartbeat_publish_snapshot) */
p->snapshot.tick = p->tick;
p->snapshot.window_width = p->effective_window_size;
p->snapshot.fill = (uint32_t)(p->total_executions < V4_MESH_WINDOW ? p->total_executions : V4_MESH_WINDOW);
p->snapshot.decay_slope_q48 = p->decay_slope_q48;
p->snapshot.hot = p->hot_at_check;
p->snapshot.stale = p->stale_at_check;
p->snapshot.total_heat = p->total_heat_at_check;
}
/* at `call` (exec.h), on a word -- any other target, nothing -- in v3's order (physics_pre_execute,