self-review 2026-07-24: boot counter — demote to telemetry weight, restore persistence via HTTP write-back
Three stale soul:boot_count copies (salience .9, importance .9, Canonical: +0.2 tier bias, 0.15 threshold) held the top WM slots for 23h — a boot counter outcompeting real context. Demoted to salience .55 / importance .2 / tier Working: plumbing, not memory. Persistence was also broken: in HTTP-engram mode the server owns state and nothing wrote the counter back — the log shows boot #5 on three consecutive boots. mem_boot_count_inc now mirrors the persona write-back: delete stale server copies (matched by content prefix — route_create_node sets label=content), create the replacement server-side. Working tier is in the boot seed (/api/nodes) but excluded from periodic /api/sync, so the count survives restarts without re-importing mid-session. Verified: restart incremented 1->2 with exactly one server-side counter node.
This commit is contained in:
+26
-1
@@ -188,7 +188,32 @@ el_val_t auto_term_try_slot(el_val_t slot_type, el_val_t slot_lbl) {
|
||||
if (!str_eq(slot_lbl, EL_STR(""))) {
|
||||
el_val_t sp = str_find_chars(slot_lbl, EL_STR(" :(["));
|
||||
if (sp > 3) {
|
||||
state_set(EL_STR("cseed_auto"), str_slice(slot_lbl, 0, sp));
|
||||
el_val_t term = str_slice(slot_lbl, 0, sp);
|
||||
state_set(EL_STR("_ats_gw"), EL_STR("0"));
|
||||
if (str_eq(term, EL_STR("Method"))) {
|
||||
state_set(EL_STR("_ats_gw"), EL_STR("1"));
|
||||
}
|
||||
if (str_eq(term, EL_STR("Theory"))) {
|
||||
state_set(EL_STR("_ats_gw"), EL_STR("1"));
|
||||
}
|
||||
if (str_eq(term, EL_STR("Finding"))) {
|
||||
state_set(EL_STR("_ats_gw"), EL_STR("1"));
|
||||
}
|
||||
if (str_eq(term, EL_STR("Survey"))) {
|
||||
state_set(EL_STR("_ats_gw"), EL_STR("1"));
|
||||
}
|
||||
if (str_eq(term, EL_STR("Paper"))) {
|
||||
state_set(EL_STR("_ats_gw"), EL_STR("1"));
|
||||
}
|
||||
if (str_eq(term, EL_STR("Knowledge"))) {
|
||||
state_set(EL_STR("_ats_gw"), EL_STR("1"));
|
||||
}
|
||||
if (str_eq(term, EL_STR("Value"))) {
|
||||
state_set(EL_STR("_ats_gw"), EL_STR("1"));
|
||||
}
|
||||
if (str_eq(state_get(EL_STR("_ats_gw")), EL_STR("0"))) {
|
||||
state_set(EL_STR("cseed_auto"), term);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+27
-1
@@ -169,7 +169,7 @@ el_val_t mem_boot_count_inc(void) {
|
||||
}
|
||||
el_val_t content = el_str_concat(EL_STR("soul:boot_count:"), int_to_str(next));
|
||||
el_val_t tags = EL_STR("[\"soul-meta\",\"boot-counter\"]");
|
||||
el_val_t boot_node_id = engram_node_full(content, EL_STR("Memory"), EL_STR("soul:boot_count"), el_from_float(0.9), el_from_float(0.9), el_from_float(1.0), EL_STR("Canonical"), tags);
|
||||
el_val_t boot_node_id = engram_node_full(content, EL_STR("Memory"), EL_STR("soul:boot_count"), el_from_float(0.55), el_from_float(0.2), el_from_float(1.0), EL_STR("Working"), tags);
|
||||
if (str_eq(boot_node_id, EL_STR(""))) {
|
||||
println(el_str_concat(el_str_concat(EL_STR("[memory] mem_boot_count_inc: write rejected (empty id) \xe2\x80\x94 boot counter node lost (count="), int_to_str(next)), EL_STR(")")));
|
||||
return next;
|
||||
@@ -178,6 +178,32 @@ el_val_t mem_boot_count_inc(void) {
|
||||
if (str_eq(boot_readback, EL_STR("")) || str_eq(boot_readback, EL_STR("{}"))) {
|
||||
println(el_str_concat(el_str_concat(el_str_concat(EL_STR("[memory] mem_boot_count_inc: WRITE VERIFY FAILED id="), boot_node_id), EL_STR(" count=")), int_to_str(next)));
|
||||
}
|
||||
el_val_t wb_url = env(EL_STR("ENGRAM_URL"));
|
||||
el_val_t wb_key = env(EL_STR("ENGRAM_API_KEY"));
|
||||
if (!str_eq(wb_url, EL_STR("")) && !str_eq(wb_key, EL_STR(""))) {
|
||||
el_val_t auth_body = el_str_concat(el_str_concat(EL_STR("{\"_auth\":\""), json_safe(wb_key)), EL_STR("\"}"));
|
||||
el_val_t srv_old = http_get(el_str_concat(wb_url, EL_STR("/api/search?q=soul:boot_count&limit=20")));
|
||||
if (!str_eq(srv_old, EL_STR("")) && !str_eq(srv_old, EL_STR("[]"))) {
|
||||
el_val_t srv_len = json_array_len(srv_old);
|
||||
el_val_t si = 0;
|
||||
while (si < srv_len) {
|
||||
el_val_t srv_node = json_array_get(srv_old, si);
|
||||
el_val_t srv_content = json_get(srv_node, EL_STR("content"));
|
||||
if (str_starts_with(srv_content, EL_STR("soul:boot_count:"))) {
|
||||
el_val_t srv_id = json_get(srv_node, EL_STR("id"));
|
||||
if (!str_eq(srv_id, EL_STR(""))) {
|
||||
http_delete_json(el_str_concat(el_str_concat(wb_url, EL_STR("/api/nodes/")), srv_id), auth_body);
|
||||
}
|
||||
}
|
||||
si = (si + 1);
|
||||
}
|
||||
}
|
||||
el_val_t wb_body = el_str_concat(el_str_concat(el_str_concat(el_str_concat(EL_STR("{\"content\":\""), content), EL_STR("\",\"node_type\":\"Memory\",\"label\":\"soul:boot_count\",\"salience\":0.55,\"importance\":0.2,\"tier\":\"Working\",\"tags\":\"[\\\"soul-meta\\\",\\\"boot-counter\\\"]\",\"_auth\":\"")), json_safe(wb_key)), EL_STR("\"}"));
|
||||
el_val_t wb_resp = http_post_json(el_str_concat(wb_url, EL_STR("/api/nodes")), wb_body);
|
||||
if (str_contains(wb_resp, EL_STR("\"error\""))) {
|
||||
println(el_str_concat(EL_STR("[memory] mem_boot_count_inc: HTTP write-back failed (count in-memory only): "), wb_resp));
|
||||
}
|
||||
}
|
||||
return next;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user