chore(dist): compile EL recall/dedup/session-continuity fixes to C
Updates soul.c and all per-module .c files with: - parse_float_x100() engram score fix - id_in_seen dedup wiring across session_preload - session-end summary hook + session-start recall - Emergency structural repair (no duplicate fns, all callsites wired)
This commit is contained in:
+38
-12
@@ -34,7 +34,7 @@ el_val_t tier_canonical(void) {
|
||||
}
|
||||
|
||||
el_val_t mem_store(el_val_t content, el_val_t label, el_val_t tags) {
|
||||
return engram_node_full(content, EL_STR("Memory"), label, el_from_float(el_from_float(0.5)), el_from_float(el_from_float(0.5)), el_from_float(el_from_float(0.8)), EL_STR("Working"), tags);
|
||||
return engram_node_full(content, EL_STR("Memory"), label, el_from_float(0.5), el_from_float(0.5), el_from_float(0.8), EL_STR("Working"), tags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -65,15 +65,43 @@ el_val_t mem_forget(el_val_t node_id) {
|
||||
|
||||
el_val_t mem_consolidate(void) {
|
||||
el_val_t scanned = engram_node_count();
|
||||
el_val_t dummy = engram_scan_nodes_json(100, 0);
|
||||
el_val_t total_nodes = engram_node_count();
|
||||
el_val_t total_edges = engram_edge_count();
|
||||
return el_str_concat(el_str_concat(el_str_concat(el_str_concat(el_str_concat(el_str_concat(EL_STR("{\"scanned\":"), int_to_str(scanned)), EL_STR(",\"total_nodes\":")), int_to_str(total_nodes)), EL_STR(",\"total_edges\":")), int_to_str(total_edges)), EL_STR("}"));
|
||||
el_val_t strengthened = 0;
|
||||
el_val_t wm_top = engram_wm_top_json(10);
|
||||
el_val_t wm_len = json_array_len(wm_top);
|
||||
el_val_t wi = 0;
|
||||
while (wi < wm_len) {
|
||||
el_val_t wm_node = json_array_get(wm_top, wi);
|
||||
el_val_t wm_id = json_get(wm_node, EL_STR("id"));
|
||||
if (!str_eq(wm_id, EL_STR(""))) {
|
||||
engram_strengthen(wm_id);
|
||||
strengthened = (strengthened + 1);
|
||||
}
|
||||
wi = (wi + 1);
|
||||
}
|
||||
el_val_t scan_result = engram_scan_nodes_json(50, 0);
|
||||
el_val_t scan_len = json_array_len(scan_result);
|
||||
el_val_t si = 0;
|
||||
while (si < scan_len) {
|
||||
el_val_t s_node = json_array_get(scan_result, si);
|
||||
el_val_t s_tier = json_get(s_node, EL_STR("tier"));
|
||||
el_val_t s_id = json_get(s_node, EL_STR("id"));
|
||||
if (str_eq(s_tier, EL_STR("Canonical")) && !str_eq(s_id, EL_STR(""))) {
|
||||
engram_strengthen(s_id);
|
||||
strengthened = (strengthened + 1);
|
||||
}
|
||||
si = (si + 1);
|
||||
}
|
||||
el_val_t total_nodes = engram_node_count();
|
||||
return el_str_concat(el_str_concat(el_str_concat(el_str_concat(el_str_concat(el_str_concat(el_str_concat(el_str_concat(EL_STR("{\"scanned\":"), int_to_str(scanned)), EL_STR(",\"total_nodes\":")), int_to_str(total_nodes)), EL_STR(",\"total_edges\":")), int_to_str(total_edges)), EL_STR(",\"strengthened\":")), int_to_str(strengthened)), EL_STR("}"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
el_val_t mem_save(el_val_t path) {
|
||||
engram_save(path);
|
||||
el_val_t save_result = engram_save(path);
|
||||
if (str_eq(save_result, EL_STR(""))) {
|
||||
println(el_str_concat(el_str_concat(EL_STR("[memory] mem_save: engram_save failed for "), path), EL_STR(" \xe2\x80\x94 snapshot may be incomplete")));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -106,7 +134,10 @@ el_val_t mem_boot_count_inc(void) {
|
||||
el_val_t next = (current + 1);
|
||||
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 discard = engram_node_full(content, EL_STR("Memory"), EL_STR("soul:boot_count"), el_from_float(el_from_float(0.9)), el_from_float(el_from_float(0.9)), el_from_float(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.9), el_from_float(0.9), el_from_float(1.0), EL_STR("Canonical"), tags);
|
||||
if (str_eq(boot_node_id, EL_STR(""))) {
|
||||
println(el_str_concat(el_str_concat(EL_STR("[memory] mem_boot_count_inc: engram write failed \xe2\x80\x94 boot counter node lost (count="), int_to_str(next)), EL_STR(")")));
|
||||
}
|
||||
return next;
|
||||
return 0;
|
||||
}
|
||||
@@ -118,12 +149,7 @@ el_val_t mem_emit_state_event(el_val_t trigger, el_val_t kind, el_val_t content)
|
||||
el_val_t safe_content = str_replace(content, EL_STR("\""), EL_STR("'"));
|
||||
el_val_t payload = el_str_concat(el_str_concat(el_str_concat(el_str_concat(el_str_concat(el_str_concat(el_str_concat(el_str_concat(el_str_concat(el_str_concat(el_str_concat(el_str_concat(el_str_concat(EL_STR("{\"trigger\":\""), safe_trigger), EL_STR("\"")), EL_STR(",\"kind\":\"")), kind), EL_STR("\"")), EL_STR(",\"content\":\"")), safe_content), EL_STR("\"")), EL_STR(",\"boot\":")), int_to_str(boot)), EL_STR(",\"ts\":")), int_to_str(ts)), EL_STR("}"));
|
||||
el_val_t tags = EL_STR("[\"internal-state\",\"pre-reasoning\",\"InternalStateEvent\"]");
|
||||
return engram_node_full(payload, EL_STR("InternalStateEvent"), el_str_concat(EL_STR("state-event:"), kind), el_from_float(el_from_float(0.85)), el_from_float(el_from_float(0.8)), el_from_float(el_from_float(0.9)), EL_STR("Episodic"), tags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int _argc, char** _argv) {
|
||||
el_runtime_init_args(_argc, _argv);
|
||||
return engram_node_full(payload, EL_STR("InternalStateEvent"), el_str_concat(EL_STR("state-event:"), kind), el_from_float(0.85), el_from_float(0.8), el_from_float(0.9), EL_STR("Episodic"), tags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user