self-review 2026-07-21: break perceive→respond→store feedback loop in awareness
The soul daemon leaked ~104 orphan in-memory nodes/min (17.6GB RSS, OOM-killed) because the perceive gate substring-matched 'soul-inbox' against the loop's own verbatim-copy output, the trigger node was strengthened but never consumed, and record() persisted a Memory node per cycle. Fixes: perceive gates and activates only on the dedicated soul-inbox-pending tag; one_cycle requires the tag on the node's tags field before attending (makes consumption safe); processed triggers are consumed via engram_forget; loop outcomes route through ISE telemetry (48h prune) instead of permanent Memory nodes. Verified post-restart: node_delta 104→~0, curiosity scans resumed, WM average unfrozen (0.120833→0.0676), RSS 17.6GB→184MB.
This commit is contained in:
+12
-12
@@ -284,7 +284,7 @@ el_val_t make_action(el_val_t kind, el_val_t payload) {
|
||||
}
|
||||
|
||||
el_val_t perceive(void) {
|
||||
el_val_t inbox_check = engram_search_json(EL_STR("soul-inbox"), 5);
|
||||
el_val_t inbox_check = engram_search_json(EL_STR("soul-inbox-pending"), 5);
|
||||
el_val_t has_inbox = (!str_eq(inbox_check, EL_STR("")) && !str_eq(inbox_check, EL_STR("[]")));
|
||||
if (!has_inbox) {
|
||||
return EL_STR("[]");
|
||||
@@ -294,11 +294,6 @@ el_val_t perceive(void) {
|
||||
if (pending_ok) {
|
||||
return from_pending;
|
||||
}
|
||||
el_val_t from_inbox = engram_activate_json(EL_STR("soul-inbox"), 2);
|
||||
el_val_t inbox_ok = (!str_eq(from_inbox, EL_STR("")) && !str_eq(from_inbox, EL_STR("[]")));
|
||||
if (inbox_ok) {
|
||||
return from_inbox;
|
||||
}
|
||||
return EL_STR("[]");
|
||||
return 0;
|
||||
}
|
||||
@@ -310,10 +305,6 @@ el_val_t attend(el_val_t node_json) {
|
||||
if (str_eq(node_json, EL_STR("[]"))) {
|
||||
return make_action(EL_STR("noop"), EL_STR(""));
|
||||
}
|
||||
el_val_t node_id = json_get(node_json, EL_STR("id"));
|
||||
if (!str_eq(node_id, EL_STR(""))) {
|
||||
engram_strengthen(node_id);
|
||||
}
|
||||
el_val_t content = json_get(node_json, EL_STR("content"));
|
||||
if (str_eq(content, EL_STR(""))) {
|
||||
return make_action(EL_STR("noop"), EL_STR(""));
|
||||
@@ -392,8 +383,9 @@ el_val_t respond(el_val_t action_json) {
|
||||
}
|
||||
|
||||
el_val_t record(el_val_t outcome_json) {
|
||||
el_val_t tags = EL_STR("[\"loop-outcome\"]");
|
||||
mem_store(outcome_json, EL_STR("loop-outcome"), tags);
|
||||
el_val_t safe = str_replace(outcome_json, EL_STR("\""), EL_STR("'"));
|
||||
el_val_t ts = time_now();
|
||||
ise_post(el_str_concat(el_str_concat(el_str_concat(el_str_concat(EL_STR("{\"event\":\"loop-outcome\",\"outcome\":\""), safe), EL_STR("\",\"ts\":")), int_to_str(ts)), EL_STR("}")));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -409,6 +401,10 @@ el_val_t one_cycle(void) {
|
||||
if (str_eq(node, EL_STR(""))) {
|
||||
return 0;
|
||||
}
|
||||
el_val_t node_tags = json_get(node, EL_STR("tags"));
|
||||
if (!str_contains(node_tags, EL_STR("soul-inbox-pending"))) {
|
||||
return 0;
|
||||
}
|
||||
el_val_t action = attend(node);
|
||||
el_val_t kind = json_get(action, EL_STR("kind"));
|
||||
el_val_t is_interesting = (!str_eq(kind, EL_STR("noop")) && !str_eq(kind, EL_STR("respond")));
|
||||
@@ -424,6 +420,10 @@ el_val_t one_cycle(void) {
|
||||
}
|
||||
el_val_t outcome = respond(action);
|
||||
record(outcome);
|
||||
el_val_t trigger_id = json_get(node, EL_STR("id"));
|
||||
if (!str_eq(trigger_id, EL_STR(""))) {
|
||||
engram_forget(trigger_id);
|
||||
}
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user