self-review 2026-07-26: heartbeat wm_churn + wm_top0_wm; fix streak counting on empty id
- wm_churn: count of top-5 WM ids absent from previous beat — separates 'one stuck node' from 'whole WM frozen' without hand-correlating ISEs. - wm_top0_wm: leader's weight; a frozen anchor reads as a constant here. - Streak guard: before the runtime emitted id in wm_top JSON, json_get(...,"id") was always empty and the streak incremented on ""=="" every beat — wm_top0_streak measured uptime, not fixation. Empty id now resets the streak to 0.
This commit is contained in:
+25
-2
@@ -210,10 +210,33 @@ fn emit_heartbeat() -> Void {
|
||||
let prev_top0: String = state_get("soul.prev_wm_top0")
|
||||
let t0streak_raw: String = state_get("soul.wm_top0_streak")
|
||||
let t0streak_prev: Int = if str_eq(t0streak_raw, "") { 0 } else { str_to_int(t0streak_raw) }
|
||||
let t0streak: Int = if str_eq(wm_top0_id, prev_top0) { t0streak_prev + 1 } else { 1 }
|
||||
// 2026-07-26 self-review: guard the empty-id case — before the runtime
|
||||
// emitted "id" in wm_top JSON, ""=="" incremented the streak every beat
|
||||
// (streak measured uptime, not fixation). Empty id now resets to 0.
|
||||
let t0streak: Int = if str_eq(wm_top0_id, "") { 0 } else { if str_eq(wm_top0_id, prev_top0) { t0streak_prev + 1 } else { 1 } }
|
||||
state_set("soul.prev_wm_top0", wm_top0_id)
|
||||
state_set("soul.wm_top0_streak", int_to_str(t0streak))
|
||||
let payload: String = "{\"event\":\"heartbeat\",\"pulse\":" + pulse + ",\"tick\":" + pulse + ",\"boot\":" + boot + ",\"idle\":" + idle + ",\"node_count\":" + int_to_str(nc) + ",\"edge_count\":" + int_to_str(ec) + ",\"node_delta\":" + int_to_str(node_delta) + ",\"edge_delta\":" + int_to_str(edge_delta) + ",\"wm_active\":" + int_to_str(wmc) + ",\"wm_delta\":" + int_to_str(wm_delta) + ",\"wm_saturated\":" + int_to_str(wm_sat) + ",\"wm_top0_streak\":" + int_to_str(t0streak) + ",\"sync_added_total\":" + sat_str + ",\"sync_age_ms\":" + int_to_str(sync_age) + ",\"wm_avg_weight\":" + wm_avg_str + ",\"wm_top\":" + wm_top + ",\"ts\":" + int_to_str(ts) + ",\"uptime_ms\":" + int_to_str(up_ms) + ",\"uptime\":\"" + up_human + "\",\"embed_ok\":" + int_to_str(emb_ok) + ",\"embed_backfilled\":" + bf_done + ",\"embed_count\":" + bf_total + ",\"ise_fail\":" + fail_str + "}"
|
||||
// wm_churn (2026-07-26 self-review): count of current top-5 WM ids absent
|
||||
// from the previous heartbeat's top-5. Distinguishes "one stuck node"
|
||||
// (churn 4) from "whole WM frozen" (churn 0) at a glance — the 07-26
|
||||
// frozen-anchor diagnosis took cross-referencing ISE streams by hand.
|
||||
let ch_id1: String = json_get(json_array_get(wm_top, 1), "id")
|
||||
let ch_id2: String = json_get(json_array_get(wm_top, 2), "id")
|
||||
let ch_id3: String = json_get(json_array_get(wm_top, 3), "id")
|
||||
let ch_id4: String = json_get(json_array_get(wm_top, 4), "id")
|
||||
let prev_top5: String = state_get("soul.prev_wm_top5")
|
||||
let ch0: Int = if str_eq(wm_top0_id, "") { 0 } else { if str_contains(prev_top5, wm_top0_id) { 0 } else { 1 } }
|
||||
let ch1: Int = if str_eq(ch_id1, "") { 0 } else { if str_contains(prev_top5, ch_id1) { 0 } else { 1 } }
|
||||
let ch2: Int = if str_eq(ch_id2, "") { 0 } else { if str_contains(prev_top5, ch_id2) { 0 } else { 1 } }
|
||||
let ch3: Int = if str_eq(ch_id3, "") { 0 } else { if str_contains(prev_top5, ch_id3) { 0 } else { 1 } }
|
||||
let ch4: Int = if str_eq(ch_id4, "") { 0 } else { if str_contains(prev_top5, ch_id4) { 0 } else { 1 } }
|
||||
let wm_churn: Int = ch0 + ch1 + ch2 + ch3 + ch4
|
||||
state_set("soul.prev_wm_top5", wm_top0_id + "|" + ch_id1 + "|" + ch_id2 + "|" + ch_id3 + "|" + ch_id4)
|
||||
// wm_top0_wm: the leader's weight. A frozen anchor reads as a constant
|
||||
// here; healthy rotation shows it moving with the promotion scores.
|
||||
let wm_top0_wm_raw: String = json_get(wm_top0, "wm")
|
||||
let wm_top0_wm: String = if str_eq(wm_top0_wm_raw, "") { "0" } else { wm_top0_wm_raw }
|
||||
let payload: String = "{\"event\":\"heartbeat\",\"pulse\":" + pulse + ",\"tick\":" + pulse + ",\"boot\":" + boot + ",\"idle\":" + idle + ",\"node_count\":" + int_to_str(nc) + ",\"edge_count\":" + int_to_str(ec) + ",\"node_delta\":" + int_to_str(node_delta) + ",\"edge_delta\":" + int_to_str(edge_delta) + ",\"wm_active\":" + int_to_str(wmc) + ",\"wm_delta\":" + int_to_str(wm_delta) + ",\"wm_saturated\":" + int_to_str(wm_sat) + ",\"wm_top0_streak\":" + int_to_str(t0streak) + ",\"wm_churn\":" + int_to_str(wm_churn) + ",\"wm_top0_wm\":" + wm_top0_wm + ",\"sync_added_total\":" + sat_str + ",\"sync_age_ms\":" + int_to_str(sync_age) + ",\"wm_avg_weight\":" + wm_avg_str + ",\"wm_top\":" + wm_top + ",\"ts\":" + int_to_str(ts) + ",\"uptime_ms\":" + int_to_str(up_ms) + ",\"uptime\":\"" + up_human + "\",\"embed_ok\":" + int_to_str(emb_ok) + ",\"embed_backfilled\":" + bf_done + ",\"embed_count\":" + bf_total + ",\"ise_fail\":" + fail_str + "}"
|
||||
ise_post(payload)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user