From 187dfe50eacde85cf48312a234bc7e5699e1bdcb Mon Sep 17 00:00:00 2001 From: "will.anderson" Date: Sat, 15 Aug 2026 08:44:42 -0500 Subject: [PATCH] self-review 2026-08-15: plumb the five fan-effect gauges to durable storage engram_act_stats_json emits 27 keys; emit_heartbeat forwarded 22. The five dropped were the five newest - the degree-correction instruments added 2026-08-11 - so the one subsystem with no track record was also the only one with no durable record. The 08-10 review fixed exactly this for hebb_cands/hebb_cand_max/hebb_mass/ hebb_edges and left the rule in a comment right above the gap: an instrument that is computed but not plumbed is not an instrument, it is a local variable. The rule was then not applied to the next thing added. Plumbing is a checklist item for every new gauge, not a one-time fix. First heartbeat after the change already earned it: fan_hits 284 of fan_steps 289 (98.3% of traversal steps binding) with fan_mean 0.5198 against fan_min 0.5 - the degree correction is sitting at its floor on nearly every step, which is a constant tax rather than a correction. That was invisible before today. --- awareness.el | 34 ++++++++- dist/awareness.c | 180 +++++++++++++++++++++++++---------------------- 2 files changed, 128 insertions(+), 86 deletions(-) diff --git a/awareness.el b/awareness.el index 6bf8ae4..8e470b1 100644 --- a/awareness.el +++ b/awareness.el @@ -451,6 +451,38 @@ fn emit_heartbeat() -> Void { let hebb_mass: String = if str_eq(hebb_mass_raw, "") { "-1" } else { hebb_mass_raw } let hebb_edges_raw: String = json_get(act_stats, "hebb_edges") let hebb_edges: String = if str_eq(hebb_edges_raw, "") { "-1" } else { hebb_edges_raw } + // Fan-effect gauges (2026-08-15 self-review). Same defect as the block + // directly above, one release later: engram_act_stats_json emits 27 keys, + // this function forwarded 22. The five it dropped are the five NEWEST — + // the degree-correction instruments added 2026-08-11 — so the one + // subsystem with no track record is also the only one with no durable + // record. The 08-10 comment above states the rule it was written to fix + // ("an instrument that is computed but not plumbed to durable storage is + // not an instrument, it is a local variable"), and the rule was then not + // applied to the next thing added. Plumbing is not a one-time fix; it is + // a checklist item for every new gauge. + // fan_mean — mean degree correction applied on the last activation. + // Drifting toward 0 ⇒ hub nodes are being damped into + // irrelevance; toward 1 ⇒ the correction is doing nothing. + // fan_min — the strongest single correction applied. + // fan_hits — how many traversal steps the correction actually bound on. + // 0 with fan_steps > 0 ⇒ the mechanism is inert. + // fan_steps — traversal steps taken (denominator of fan_mean). Also the + // only durable measure of how far activation is spreading. + // fan_dref — reference degree the correction normalises against. + // fan_hits/fan_steps together answer the question hebb_cands/hebb_cand_max + // answers for consolidation: is this quiet because nothing is happening, + // or because a threshold is wrong? Without both, the two look identical. + let fan_mean_raw: String = json_get(act_stats, "fan_mean") + let fan_mean: String = if str_eq(fan_mean_raw, "") { "-1" } else { fan_mean_raw } + let fan_min_raw: String = json_get(act_stats, "fan_min") + let fan_min: String = if str_eq(fan_min_raw, "") { "-1" } else { fan_min_raw } + let fan_hits_raw: String = json_get(act_stats, "fan_hits") + let fan_hits: String = if str_eq(fan_hits_raw, "") { "-1" } else { fan_hits_raw } + let fan_steps_raw: String = json_get(act_stats, "fan_steps") + let fan_steps: String = if str_eq(fan_steps_raw, "") { "-1" } else { fan_steps_raw } + let fan_dref_raw: String = json_get(act_stats, "fan_dref") + let fan_dref: String = if str_eq(fan_dref_raw, "") { "-1" } else { fan_dref_raw } // Consolidation write-back gauges (2026-08-07 self-review). hebb_links // counts what this process LEARNED; these three count what SURVIVES it. // The distinction is the whole finding: 1,198 links formed, 0 persisted, @@ -564,7 +596,7 @@ fn emit_heartbeat() -> Void { let dmg_scan: String = if str_eq(dmg_scan_raw, "") { "-1" } else { dmg_scan_raw } let dmg_ts_raw: String = state_get("soul.txt_census_ts") let dmg_age: Int = if str_eq(dmg_ts_raw, "") { 0 - 1 } else { ts - str_to_int(dmg_ts_raw) } - let payload: String = "{\"event\":\"heartbeat\",\"pulse\":" + pulse + ",\"tick\":" + pulse + ",\"boot\":" + boot + ",\"idle\":" + idle + ",\"idle_ms\":" + int_to_str(idle_ms) + ",\"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 + ",\"embed_eligible\":" + embed_elig + ",\"wm_evicted\":" + act_evict + ",\"wm_evicted_delta\":" + int_to_str(evict_delta) + ",\"evict_floor\":" + ev_floor + ",\"evict_cap\":" + ev_cap + ",\"evict_bll\":" + ev_bll + ",\"breakthroughs\":" + act_bt + ",\"breakthroughs_delta\":" + int_to_str(bt_delta) + ",\"auto_term_streak\":" + int_to_str(hb_ats) + ",\"auto_term_empty_streak\":" + int_to_str(hb_ate) + ",\"embed_breaker_open\":" + act_brk + ",\"ctx_cos\":" + ctx_cos + ",\"dup_seeds\":" + dup_seeds + ",\"dup_wm\":" + dup_wm + ",\"dup_wm_global\":" + dup_wm_g + ",\"hebb_warm\":" + hebb_warm + ",\"hebb_max\":" + hebb_max + ",\"hebb_links\":" + hebb_links + ",\"hebb_cands\":" + hebb_cands + ",\"hebb_cand_max\":" + hebb_cmax + ",\"hebb_mass\":" + hebb_mass + ",\"hebb_edges\":" + hebb_edges + ",\"embed_consec_fail\":" + emb_cf + ",\"txt_damaged_pct\":" + dmg_pct + ",\"txt_damaged_n\":" + dmg_n + ",\"txt_scanned_n\":" + dmg_scan + ",\"txt_census_age_ms\":" + int_to_str(dmg_age) + ",\"hebb_wb_pending\":" + wb_pend + ",\"hebb_wb_drained\":" + wb_drain + ",\"hebb_wb_dropped\":" + wb_drop + ",\"hebb_wb_sent\":" + wb_sent + ",\"ise_fail\":" + fail_str + ",\"txt_damaged\":" + txt_dmg + "}" + let payload: String = "{\"event\":\"heartbeat\",\"pulse\":" + pulse + ",\"tick\":" + pulse + ",\"boot\":" + boot + ",\"idle\":" + idle + ",\"idle_ms\":" + int_to_str(idle_ms) + ",\"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 + ",\"embed_eligible\":" + embed_elig + ",\"wm_evicted\":" + act_evict + ",\"wm_evicted_delta\":" + int_to_str(evict_delta) + ",\"evict_floor\":" + ev_floor + ",\"evict_cap\":" + ev_cap + ",\"evict_bll\":" + ev_bll + ",\"breakthroughs\":" + act_bt + ",\"breakthroughs_delta\":" + int_to_str(bt_delta) + ",\"auto_term_streak\":" + int_to_str(hb_ats) + ",\"auto_term_empty_streak\":" + int_to_str(hb_ate) + ",\"embed_breaker_open\":" + act_brk + ",\"ctx_cos\":" + ctx_cos + ",\"dup_seeds\":" + dup_seeds + ",\"dup_wm\":" + dup_wm + ",\"dup_wm_global\":" + dup_wm_g + ",\"hebb_warm\":" + hebb_warm + ",\"hebb_max\":" + hebb_max + ",\"hebb_links\":" + hebb_links + ",\"hebb_cands\":" + hebb_cands + ",\"hebb_cand_max\":" + hebb_cmax + ",\"hebb_mass\":" + hebb_mass + ",\"hebb_edges\":" + hebb_edges + ",\"embed_consec_fail\":" + emb_cf + ",\"txt_damaged_pct\":" + dmg_pct + ",\"txt_damaged_n\":" + dmg_n + ",\"txt_scanned_n\":" + dmg_scan + ",\"txt_census_age_ms\":" + int_to_str(dmg_age) + ",\"hebb_wb_pending\":" + wb_pend + ",\"hebb_wb_drained\":" + wb_drain + ",\"hebb_wb_dropped\":" + wb_drop + ",\"hebb_wb_sent\":" + wb_sent + ",\"ise_fail\":" + fail_str + ",\"txt_damaged\":" + txt_dmg + ",\"fan_mean\":" + fan_mean + ",\"fan_min\":" + fan_min + ",\"fan_hits\":" + fan_hits + ",\"fan_steps\":" + fan_steps + ",\"fan_dref\":" + fan_dref + "}" ise_post(payload) } diff --git a/dist/awareness.c b/dist/awareness.c index 711483b..2533b59 100644 --- a/dist/awareness.c +++ b/dist/awareness.c @@ -279,30 +279,40 @@ el_val_t emit_heartbeat(void) { el_val_t hebb_mass = ({ el_val_t _if_result_58 = 0; if (str_eq(hebb_mass_raw, EL_STR(""))) { _if_result_58 = (EL_STR("-1")); } else { _if_result_58 = (hebb_mass_raw); } _if_result_58; }); el_val_t hebb_edges_raw = json_get(act_stats, EL_STR("hebb_edges")); el_val_t hebb_edges = ({ el_val_t _if_result_59 = 0; if (str_eq(hebb_edges_raw, EL_STR(""))) { _if_result_59 = (EL_STR("-1")); } else { _if_result_59 = (hebb_edges_raw); } _if_result_59; }); + el_val_t fan_mean_raw = json_get(act_stats, EL_STR("fan_mean")); + el_val_t fan_mean = ({ el_val_t _if_result_60 = 0; if (str_eq(fan_mean_raw, EL_STR(""))) { _if_result_60 = (EL_STR("-1")); } else { _if_result_60 = (fan_mean_raw); } _if_result_60; }); + el_val_t fan_min_raw = json_get(act_stats, EL_STR("fan_min")); + el_val_t fan_min = ({ el_val_t _if_result_61 = 0; if (str_eq(fan_min_raw, EL_STR(""))) { _if_result_61 = (EL_STR("-1")); } else { _if_result_61 = (fan_min_raw); } _if_result_61; }); + el_val_t fan_hits_raw = json_get(act_stats, EL_STR("fan_hits")); + el_val_t fan_hits = ({ el_val_t _if_result_62 = 0; if (str_eq(fan_hits_raw, EL_STR(""))) { _if_result_62 = (EL_STR("-1")); } else { _if_result_62 = (fan_hits_raw); } _if_result_62; }); + el_val_t fan_steps_raw = json_get(act_stats, EL_STR("fan_steps")); + el_val_t fan_steps = ({ el_val_t _if_result_63 = 0; if (str_eq(fan_steps_raw, EL_STR(""))) { _if_result_63 = (EL_STR("-1")); } else { _if_result_63 = (fan_steps_raw); } _if_result_63; }); + el_val_t fan_dref_raw = json_get(act_stats, EL_STR("fan_dref")); + el_val_t fan_dref = ({ el_val_t _if_result_64 = 0; if (str_eq(fan_dref_raw, EL_STR(""))) { _if_result_64 = (EL_STR("-1")); } else { _if_result_64 = (fan_dref_raw); } _if_result_64; }); el_val_t wb_pend_raw = json_get(act_stats, EL_STR("hebb_wb_pending")); - el_val_t wb_pend = ({ el_val_t _if_result_60 = 0; if (str_eq(wb_pend_raw, EL_STR(""))) { _if_result_60 = (EL_STR("-1")); } else { _if_result_60 = (wb_pend_raw); } _if_result_60; }); + el_val_t wb_pend = ({ el_val_t _if_result_65 = 0; if (str_eq(wb_pend_raw, EL_STR(""))) { _if_result_65 = (EL_STR("-1")); } else { _if_result_65 = (wb_pend_raw); } _if_result_65; }); el_val_t wb_drain_raw = json_get(act_stats, EL_STR("hebb_wb_drained")); - el_val_t wb_drain = ({ el_val_t _if_result_61 = 0; if (str_eq(wb_drain_raw, EL_STR(""))) { _if_result_61 = (EL_STR("-1")); } else { _if_result_61 = (wb_drain_raw); } _if_result_61; }); + el_val_t wb_drain = ({ el_val_t _if_result_66 = 0; if (str_eq(wb_drain_raw, EL_STR(""))) { _if_result_66 = (EL_STR("-1")); } else { _if_result_66 = (wb_drain_raw); } _if_result_66; }); el_val_t wb_drop_raw = json_get(act_stats, EL_STR("hebb_wb_dropped")); - el_val_t wb_drop = ({ el_val_t _if_result_62 = 0; if (str_eq(wb_drop_raw, EL_STR(""))) { _if_result_62 = (EL_STR("-1")); } else { _if_result_62 = (wb_drop_raw); } _if_result_62; }); + el_val_t wb_drop = ({ el_val_t _if_result_67 = 0; if (str_eq(wb_drop_raw, EL_STR(""))) { _if_result_67 = (EL_STR("-1")); } else { _if_result_67 = (wb_drop_raw); } _if_result_67; }); el_val_t wb_sent_raw = state_get(EL_STR("soul.hebb_wb_sent")); - el_val_t wb_sent = ({ el_val_t _if_result_63 = 0; if (str_eq(wb_sent_raw, EL_STR(""))) { _if_result_63 = (EL_STR("0")); } else { _if_result_63 = (wb_sent_raw); } _if_result_63; }); + el_val_t wb_sent = ({ el_val_t _if_result_68 = 0; if (str_eq(wb_sent_raw, EL_STR(""))) { _if_result_68 = (EL_STR("0")); } else { _if_result_68 = (wb_sent_raw); } _if_result_68; }); el_val_t dup_wm_g_raw = json_get(act_stats, EL_STR("dup_wm_global")); - el_val_t dup_wm_g = ({ el_val_t _if_result_64 = 0; if (str_eq(dup_wm_g_raw, EL_STR(""))) { _if_result_64 = (EL_STR("-1")); } else { _if_result_64 = (dup_wm_g_raw); } _if_result_64; }); + el_val_t dup_wm_g = ({ el_val_t _if_result_69 = 0; if (str_eq(dup_wm_g_raw, EL_STR(""))) { _if_result_69 = (EL_STR("-1")); } else { _if_result_69 = (dup_wm_g_raw); } _if_result_69; }); el_val_t act_brk_raw = json_get(act_stats, EL_STR("embed_breaker_open")); - el_val_t act_brk = ({ el_val_t _if_result_65 = 0; if (str_eq(act_brk_raw, EL_STR(""))) { _if_result_65 = (EL_STR("-1")); } else { _if_result_65 = (act_brk_raw); } _if_result_65; }); + el_val_t act_brk = ({ el_val_t _if_result_70 = 0; if (str_eq(act_brk_raw, EL_STR(""))) { _if_result_70 = (EL_STR("-1")); } else { _if_result_70 = (act_brk_raw); } _if_result_70; }); el_val_t emb_cf_raw = json_get(act_stats, EL_STR("embed_consec_fail")); - el_val_t emb_cf = ({ el_val_t _if_result_66 = 0; if (str_eq(emb_cf_raw, EL_STR(""))) { _if_result_66 = (EL_STR("-1")); } else { _if_result_66 = (emb_cf_raw); } _if_result_66; }); + el_val_t emb_cf = ({ el_val_t _if_result_71 = 0; if (str_eq(emb_cf_raw, EL_STR(""))) { _if_result_71 = (EL_STR("-1")); } else { _if_result_71 = (emb_cf_raw); } _if_result_71; }); el_val_t ctx_cos_raw = json_get(act_stats, EL_STR("ctx_cos")); - el_val_t ctx_cos = ({ el_val_t _if_result_67 = 0; if (str_eq(ctx_cos_raw, EL_STR(""))) { _if_result_67 = (EL_STR("-2")); } else { _if_result_67 = (ctx_cos_raw); } _if_result_67; }); + el_val_t ctx_cos = ({ el_val_t _if_result_72 = 0; if (str_eq(ctx_cos_raw, EL_STR(""))) { _if_result_72 = (EL_STR("-2")); } else { _if_result_72 = (ctx_cos_raw); } _if_result_72; }); el_val_t dup_seeds_raw = json_get(act_stats, EL_STR("dup_seeds")); - el_val_t dup_seeds = ({ el_val_t _if_result_68 = 0; if (str_eq(dup_seeds_raw, EL_STR(""))) { _if_result_68 = (EL_STR("-1")); } else { _if_result_68 = (dup_seeds_raw); } _if_result_68; }); + el_val_t dup_seeds = ({ el_val_t _if_result_73 = 0; if (str_eq(dup_seeds_raw, EL_STR(""))) { _if_result_73 = (EL_STR("-1")); } else { _if_result_73 = (dup_seeds_raw); } _if_result_73; }); el_val_t dup_wm_raw = json_get(act_stats, EL_STR("dup_wm")); - el_val_t dup_wm = ({ el_val_t _if_result_69 = 0; if (str_eq(dup_wm_raw, EL_STR(""))) { _if_result_69 = (EL_STR("-1")); } else { _if_result_69 = (dup_wm_raw); } _if_result_69; }); + el_val_t dup_wm = ({ el_val_t _if_result_74 = 0; if (str_eq(dup_wm_raw, EL_STR(""))) { _if_result_74 = (EL_STR("-1")); } else { _if_result_74 = (dup_wm_raw); } _if_result_74; }); el_val_t txt_dmg_raw = json_get(act_stats, EL_STR("txt_damaged")); - el_val_t txt_dmg = ({ el_val_t _if_result_70 = 0; if (str_eq(txt_dmg_raw, EL_STR(""))) { _if_result_70 = (EL_STR("-1")); } else { _if_result_70 = (txt_dmg_raw); } _if_result_70; }); + el_val_t txt_dmg = ({ el_val_t _if_result_75 = 0; if (str_eq(txt_dmg_raw, EL_STR(""))) { _if_result_75 = (EL_STR("-1")); } else { _if_result_75 = (txt_dmg_raw); } _if_result_75; }); el_val_t tc_raw = state_get(EL_STR("soul.txt_census_countdown")); - el_val_t tc_n = ({ el_val_t _if_result_71 = 0; if (str_eq(tc_raw, EL_STR(""))) { _if_result_71 = (0); } else { _if_result_71 = (str_to_int(tc_raw)); } _if_result_71; }); + el_val_t tc_n = ({ el_val_t _if_result_76 = 0; if (str_eq(tc_raw, EL_STR(""))) { _if_result_76 = (0); } else { _if_result_76 = (str_to_int(tc_raw)); } _if_result_76; }); if (tc_n <= 0) { el_val_t th_resp = http_get(el_str_concat(hb_engram_url, EL_STR("/api/text-health"))); el_val_t th_pct = json_get(th_resp, EL_STR("damaged_pct")); @@ -318,14 +328,14 @@ el_val_t emit_heartbeat(void) { state_set(EL_STR("soul.txt_census_countdown"), int_to_str((tc_n - 1))); } el_val_t dmg_pct_raw = state_get(EL_STR("soul.txt_damaged_pct")); - el_val_t dmg_pct = ({ el_val_t _if_result_72 = 0; if (str_eq(dmg_pct_raw, EL_STR(""))) { _if_result_72 = (EL_STR("-1")); } else { _if_result_72 = (dmg_pct_raw); } _if_result_72; }); + el_val_t dmg_pct = ({ el_val_t _if_result_77 = 0; if (str_eq(dmg_pct_raw, EL_STR(""))) { _if_result_77 = (EL_STR("-1")); } else { _if_result_77 = (dmg_pct_raw); } _if_result_77; }); el_val_t dmg_n_raw = state_get(EL_STR("soul.txt_damaged_n")); - el_val_t dmg_n = ({ el_val_t _if_result_73 = 0; if (str_eq(dmg_n_raw, EL_STR(""))) { _if_result_73 = (EL_STR("-1")); } else { _if_result_73 = (dmg_n_raw); } _if_result_73; }); + el_val_t dmg_n = ({ el_val_t _if_result_78 = 0; if (str_eq(dmg_n_raw, EL_STR(""))) { _if_result_78 = (EL_STR("-1")); } else { _if_result_78 = (dmg_n_raw); } _if_result_78; }); el_val_t dmg_scan_raw = state_get(EL_STR("soul.txt_scanned_n")); - el_val_t dmg_scan = ({ el_val_t _if_result_74 = 0; if (str_eq(dmg_scan_raw, EL_STR(""))) { _if_result_74 = (EL_STR("-1")); } else { _if_result_74 = (dmg_scan_raw); } _if_result_74; }); + el_val_t dmg_scan = ({ el_val_t _if_result_79 = 0; if (str_eq(dmg_scan_raw, EL_STR(""))) { _if_result_79 = (EL_STR("-1")); } else { _if_result_79 = (dmg_scan_raw); } _if_result_79; }); el_val_t dmg_ts_raw = state_get(EL_STR("soul.txt_census_ts")); - el_val_t dmg_age = ({ el_val_t _if_result_75 = 0; if (str_eq(dmg_ts_raw, EL_STR(""))) { _if_result_75 = ((0 - 1)); } else { _if_result_75 = ((ts - str_to_int(dmg_ts_raw))); } _if_result_75; }); - 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_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_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_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_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_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_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_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_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("{\"event\":\"heartbeat\",\"pulse\":"), pulse), EL_STR(",\"tick\":")), pulse), EL_STR(",\"boot\":")), boot), EL_STR(",\"idle\":")), idle), EL_STR(",\"idle_ms\":")), int_to_str(idle_ms)), EL_STR(",\"node_count\":")), int_to_str(nc)), EL_STR(",\"edge_count\":")), int_to_str(ec)), EL_STR(",\"node_delta\":")), int_to_str(node_delta)), EL_STR(",\"edge_delta\":")), int_to_str(edge_delta)), EL_STR(",\"wm_active\":")), int_to_str(wmc)), EL_STR(",\"wm_delta\":")), int_to_str(wm_delta)), EL_STR(",\"wm_saturated\":")), int_to_str(wm_sat)), EL_STR(",\"wm_top0_streak\":")), int_to_str(t0streak)), EL_STR(",\"wm_churn\":")), int_to_str(wm_churn)), EL_STR(",\"wm_top0_wm\":")), wm_top0_wm), EL_STR(",\"sync_added_total\":")), sat_str), EL_STR(",\"sync_age_ms\":")), int_to_str(sync_age)), EL_STR(",\"wm_avg_weight\":")), wm_avg_str), EL_STR(",\"wm_top\":")), wm_top), EL_STR(",\"ts\":")), int_to_str(ts)), EL_STR(",\"uptime_ms\":")), int_to_str(up_ms)), EL_STR(",\"uptime\":\"")), up_human), EL_STR("\",\"embed_ok\":")), int_to_str(emb_ok)), EL_STR(",\"embed_backfilled\":")), bf_done), EL_STR(",\"embed_count\":")), bf_total), EL_STR(",\"embed_eligible\":")), embed_elig), EL_STR(",\"wm_evicted\":")), act_evict), EL_STR(",\"wm_evicted_delta\":")), int_to_str(evict_delta)), EL_STR(",\"evict_floor\":")), ev_floor), EL_STR(",\"evict_cap\":")), ev_cap), EL_STR(",\"evict_bll\":")), ev_bll), EL_STR(",\"breakthroughs\":")), act_bt), EL_STR(",\"breakthroughs_delta\":")), int_to_str(bt_delta)), EL_STR(",\"auto_term_streak\":")), int_to_str(hb_ats)), EL_STR(",\"auto_term_empty_streak\":")), int_to_str(hb_ate)), EL_STR(",\"embed_breaker_open\":")), act_brk), EL_STR(",\"ctx_cos\":")), ctx_cos), EL_STR(",\"dup_seeds\":")), dup_seeds), EL_STR(",\"dup_wm\":")), dup_wm), EL_STR(",\"dup_wm_global\":")), dup_wm_g), EL_STR(",\"hebb_warm\":")), hebb_warm), EL_STR(",\"hebb_max\":")), hebb_max), EL_STR(",\"hebb_links\":")), hebb_links), EL_STR(",\"hebb_cands\":")), hebb_cands), EL_STR(",\"hebb_cand_max\":")), hebb_cmax), EL_STR(",\"hebb_mass\":")), hebb_mass), EL_STR(",\"hebb_edges\":")), hebb_edges), EL_STR(",\"embed_consec_fail\":")), emb_cf), EL_STR(",\"txt_damaged_pct\":")), dmg_pct), EL_STR(",\"txt_damaged_n\":")), dmg_n), EL_STR(",\"txt_scanned_n\":")), dmg_scan), EL_STR(",\"txt_census_age_ms\":")), int_to_str(dmg_age)), EL_STR(",\"hebb_wb_pending\":")), wb_pend), EL_STR(",\"hebb_wb_drained\":")), wb_drain), EL_STR(",\"hebb_wb_dropped\":")), wb_drop), EL_STR(",\"hebb_wb_sent\":")), wb_sent), EL_STR(",\"ise_fail\":")), fail_str), EL_STR(",\"txt_damaged\":")), txt_dmg), EL_STR("}")); + el_val_t dmg_age = ({ el_val_t _if_result_80 = 0; if (str_eq(dmg_ts_raw, EL_STR(""))) { _if_result_80 = ((0 - 1)); } else { _if_result_80 = ((ts - str_to_int(dmg_ts_raw))); } _if_result_80; }); + 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_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_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_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_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_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_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_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_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_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("{\"event\":\"heartbeat\",\"pulse\":"), pulse), EL_STR(",\"tick\":")), pulse), EL_STR(",\"boot\":")), boot), EL_STR(",\"idle\":")), idle), EL_STR(",\"idle_ms\":")), int_to_str(idle_ms)), EL_STR(",\"node_count\":")), int_to_str(nc)), EL_STR(",\"edge_count\":")), int_to_str(ec)), EL_STR(",\"node_delta\":")), int_to_str(node_delta)), EL_STR(",\"edge_delta\":")), int_to_str(edge_delta)), EL_STR(",\"wm_active\":")), int_to_str(wmc)), EL_STR(",\"wm_delta\":")), int_to_str(wm_delta)), EL_STR(",\"wm_saturated\":")), int_to_str(wm_sat)), EL_STR(",\"wm_top0_streak\":")), int_to_str(t0streak)), EL_STR(",\"wm_churn\":")), int_to_str(wm_churn)), EL_STR(",\"wm_top0_wm\":")), wm_top0_wm), EL_STR(",\"sync_added_total\":")), sat_str), EL_STR(",\"sync_age_ms\":")), int_to_str(sync_age)), EL_STR(",\"wm_avg_weight\":")), wm_avg_str), EL_STR(",\"wm_top\":")), wm_top), EL_STR(",\"ts\":")), int_to_str(ts)), EL_STR(",\"uptime_ms\":")), int_to_str(up_ms)), EL_STR(",\"uptime\":\"")), up_human), EL_STR("\",\"embed_ok\":")), int_to_str(emb_ok)), EL_STR(",\"embed_backfilled\":")), bf_done), EL_STR(",\"embed_count\":")), bf_total), EL_STR(",\"embed_eligible\":")), embed_elig), EL_STR(",\"wm_evicted\":")), act_evict), EL_STR(",\"wm_evicted_delta\":")), int_to_str(evict_delta)), EL_STR(",\"evict_floor\":")), ev_floor), EL_STR(",\"evict_cap\":")), ev_cap), EL_STR(",\"evict_bll\":")), ev_bll), EL_STR(",\"breakthroughs\":")), act_bt), EL_STR(",\"breakthroughs_delta\":")), int_to_str(bt_delta)), EL_STR(",\"auto_term_streak\":")), int_to_str(hb_ats)), EL_STR(",\"auto_term_empty_streak\":")), int_to_str(hb_ate)), EL_STR(",\"embed_breaker_open\":")), act_brk), EL_STR(",\"ctx_cos\":")), ctx_cos), EL_STR(",\"dup_seeds\":")), dup_seeds), EL_STR(",\"dup_wm\":")), dup_wm), EL_STR(",\"dup_wm_global\":")), dup_wm_g), EL_STR(",\"hebb_warm\":")), hebb_warm), EL_STR(",\"hebb_max\":")), hebb_max), EL_STR(",\"hebb_links\":")), hebb_links), EL_STR(",\"hebb_cands\":")), hebb_cands), EL_STR(",\"hebb_cand_max\":")), hebb_cmax), EL_STR(",\"hebb_mass\":")), hebb_mass), EL_STR(",\"hebb_edges\":")), hebb_edges), EL_STR(",\"embed_consec_fail\":")), emb_cf), EL_STR(",\"txt_damaged_pct\":")), dmg_pct), EL_STR(",\"txt_damaged_n\":")), dmg_n), EL_STR(",\"txt_scanned_n\":")), dmg_scan), EL_STR(",\"txt_census_age_ms\":")), int_to_str(dmg_age)), EL_STR(",\"hebb_wb_pending\":")), wb_pend), EL_STR(",\"hebb_wb_drained\":")), wb_drain), EL_STR(",\"hebb_wb_dropped\":")), wb_drop), EL_STR(",\"hebb_wb_sent\":")), wb_sent), EL_STR(",\"ise_fail\":")), fail_str), EL_STR(",\"txt_damaged\":")), txt_dmg), EL_STR(",\"fan_mean\":")), fan_mean), EL_STR(",\"fan_min\":")), fan_min), EL_STR(",\"fan_hits\":")), fan_hits), EL_STR(",\"fan_steps\":")), fan_steps), EL_STR(",\"fan_dref\":")), fan_dref), EL_STR("}")); ise_post(payload); return 0; } @@ -348,7 +358,7 @@ el_val_t auto_term_try_slot(el_val_t slot_type, el_val_t slot_id) { if (!str_eq(slot_id, EL_STR(""))) { el_val_t tabu = 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("|"), state_get(EL_STR("soul.tabu_t0"))), EL_STR("|")), state_get(EL_STR("soul.tabu_t1"))), EL_STR("|")), state_get(EL_STR("soul.tabu_t2"))), EL_STR("|")), state_get(EL_STR("soul.tabu_t3"))), EL_STR("|")); el_val_t df_max = (engram_node_count() / 400); - el_val_t df_cap = ({ el_val_t _if_result_76 = 0; if ((df_max > 8)) { _if_result_76 = (df_max); } else { _if_result_76 = (8); } _if_result_76; }); + el_val_t df_cap = ({ el_val_t _if_result_81 = 0; if ((df_max > 8)) { _if_result_81 = (df_max); } else { _if_result_81 = (8); } _if_result_81; }); el_val_t term = engram_salient_term(slot_id, df_cap, 1, tabu); if (!str_eq(term, EL_STR(""))) { state_set(EL_STR("_ats_gw"), EL_STR("0")); @@ -514,18 +524,18 @@ el_val_t proactive_curiosity(void) { auto_term_try_slot(json_get(wm10_n1, EL_STR("node_type")), json_get(wm10_n1, EL_STR("id"))); auto_term_try_slot(json_get(wm10_n0, EL_STR("node_type")), json_get(wm10_n0, EL_STR("id"))); el_val_t auto_term = state_get(EL_STR("cseed_auto")); - el_val_t results_auto = ({ el_val_t _if_result_77 = 0; if (str_eq(auto_term, EL_STR(""))) { _if_result_77 = (EL_STR("[]")); } else { _if_result_77 = (engram_activate_json(auto_term, 1)); } _if_result_77; }); + el_val_t results_auto = ({ el_val_t _if_result_82 = 0; if (str_eq(auto_term, EL_STR(""))) { _if_result_82 = (EL_STR("[]")); } else { _if_result_82 = (engram_activate_json(auto_term, 1)); } _if_result_82; }); el_val_t found_auto = json_array_len(results_auto); el_val_t total_found = (found + found_auto); el_val_t safe_auto = str_replace(auto_term, EL_STR("\""), EL_STR("'")); el_val_t prev_auto = state_get(EL_STR("soul.prev_auto_term")); el_val_t atstreak_raw = state_get(EL_STR("soul.auto_term_streak")); - el_val_t atstreak_prev = ({ el_val_t _if_result_78 = 0; if (str_eq(atstreak_raw, EL_STR(""))) { _if_result_78 = (0); } else { _if_result_78 = (str_to_int(atstreak_raw)); } _if_result_78; }); + el_val_t atstreak_prev = ({ el_val_t _if_result_83 = 0; if (str_eq(atstreak_raw, EL_STR(""))) { _if_result_83 = (0); } else { _if_result_83 = (str_to_int(atstreak_raw)); } _if_result_83; }); el_val_t is_empty = str_eq(auto_term, EL_STR("")); - el_val_t atstreak = ({ el_val_t _if_result_79 = 0; if (is_empty) { _if_result_79 = (0); } else { _if_result_79 = (({ el_val_t _if_result_80 = 0; if (str_eq(auto_term, prev_auto)) { _if_result_80 = ((atstreak_prev + 1)); } else { _if_result_80 = (1); } _if_result_80; })); } _if_result_79; }); + el_val_t atstreak = ({ el_val_t _if_result_84 = 0; if (is_empty) { _if_result_84 = (0); } else { _if_result_84 = (({ el_val_t _if_result_85 = 0; if (str_eq(auto_term, prev_auto)) { _if_result_85 = ((atstreak_prev + 1)); } else { _if_result_85 = (1); } _if_result_85; })); } _if_result_84; }); el_val_t atempty_raw = state_get(EL_STR("soul.auto_term_empty_streak")); - el_val_t atempty_prev = ({ el_val_t _if_result_81 = 0; if (str_eq(atempty_raw, EL_STR(""))) { _if_result_81 = (0); } else { _if_result_81 = (str_to_int(atempty_raw)); } _if_result_81; }); - el_val_t atempty = ({ el_val_t _if_result_82 = 0; if (is_empty) { _if_result_82 = ((atempty_prev + 1)); } else { _if_result_82 = (0); } _if_result_82; }); + el_val_t atempty_prev = ({ el_val_t _if_result_86 = 0; if (str_eq(atempty_raw, EL_STR(""))) { _if_result_86 = (0); } else { _if_result_86 = (str_to_int(atempty_raw)); } _if_result_86; }); + el_val_t atempty = ({ el_val_t _if_result_87 = 0; if (is_empty) { _if_result_87 = ((atempty_prev + 1)); } else { _if_result_87 = (0); } _if_result_87; }); state_set(EL_STR("soul.prev_auto_term"), auto_term); state_set(EL_STR("soul.auto_term_streak"), int_to_str(atstreak)); state_set(EL_STR("soul.auto_term_empty_streak"), int_to_str(atempty)); @@ -720,16 +730,16 @@ el_val_t awareness_run(void) { state_set(EL_STR("soul.boot_ts"), int_to_str(time_now())); } el_val_t tick_raw = env(EL_STR("SOUL_TICK_MS")); - el_val_t tick_ms = ({ el_val_t _if_result_83 = 0; if (str_eq(tick_raw, EL_STR(""))) { _if_result_83 = (200); } else { _if_result_83 = (str_to_int(tick_raw)); } _if_result_83; }); + el_val_t tick_ms = ({ el_val_t _if_result_88 = 0; if (str_eq(tick_raw, EL_STR(""))) { _if_result_88 = (200); } else { _if_result_88 = (str_to_int(tick_raw)); } _if_result_88; }); el_val_t beat_ms_raw = env(EL_STR("SOUL_HEARTBEAT_MS")); - el_val_t beat_ms = ({ el_val_t _if_result_84 = 0; if (str_eq(beat_ms_raw, EL_STR(""))) { _if_result_84 = (60000); } else { _if_result_84 = (str_to_int(beat_ms_raw)); } _if_result_84; }); + el_val_t beat_ms = ({ el_val_t _if_result_89 = 0; if (str_eq(beat_ms_raw, EL_STR(""))) { _if_result_89 = (60000); } else { _if_result_89 = (str_to_int(beat_ms_raw)); } _if_result_89; }); el_val_t scan_ms = (beat_ms / 2); while (1) { el_val_t tick_mark = el_arena_push(); el_val_t running = state_get(EL_STR("soul.running")); if (str_eq(running, EL_STR("false"))) { el_val_t sd_boot_raw = state_get(EL_STR("soul_boot_count")); - el_val_t sd_boot = ({ el_val_t _if_result_85 = 0; if (str_eq(sd_boot_raw, EL_STR(""))) { _if_result_85 = (EL_STR("0")); } else { _if_result_85 = (sd_boot_raw); } _if_result_85; }); + el_val_t sd_boot = ({ el_val_t _if_result_90 = 0; if (str_eq(sd_boot_raw, EL_STR(""))) { _if_result_90 = (EL_STR("0")); } else { _if_result_90 = (sd_boot_raw); } _if_result_90; }); el_val_t sd_wb = hebb_consolidate(); ise_post(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("{\"event\":\"shutdown\",\"boot\":"), sd_boot), EL_STR(",\"pulse\":")), int_to_str(pulse_count())), EL_STR(",\"hebb_wb_sent\":")), int_to_str(sd_wb)), EL_STR(",\"uptime_ms\":")), int_to_str(elapsed_ms())), EL_STR(",\"ts\":")), int_to_str(time_now())), EL_STR("}"))); println(EL_STR("[awareness] exiting")); @@ -746,7 +756,7 @@ el_val_t awareness_run(void) { } el_val_t now_ts = time_now(); el_val_t last_beat_str = state_get(EL_STR("soul.last_beat_ts")); - el_val_t last_beat_ts = ({ el_val_t _if_result_86 = 0; if (str_eq(last_beat_str, EL_STR(""))) { _if_result_86 = (0); } else { _if_result_86 = (str_to_int(last_beat_str)); } _if_result_86; }); + el_val_t last_beat_ts = ({ el_val_t _if_result_91 = 0; if (str_eq(last_beat_str, EL_STR(""))) { _if_result_91 = (0); } else { _if_result_91 = (str_to_int(last_beat_str)); } _if_result_91; }); el_val_t beat_elapsed = (now_ts - last_beat_ts); el_val_t should_beat = (beat_elapsed >= beat_ms); if (should_beat) { @@ -760,7 +770,7 @@ el_val_t awareness_run(void) { } } el_val_t last_scan_str = state_get(EL_STR("soul.last_scan_ts")); - el_val_t last_scan_ts = ({ el_val_t _if_result_87 = 0; if (str_eq(last_scan_str, EL_STR(""))) { _if_result_87 = (0); } else { _if_result_87 = (str_to_int(last_scan_str)); } _if_result_87; }); + el_val_t last_scan_ts = ({ el_val_t _if_result_92 = 0; if (str_eq(last_scan_str, EL_STR(""))) { _if_result_92 = (0); } else { _if_result_92 = (str_to_int(last_scan_str)); } _if_result_92; }); el_val_t scan_elapsed = (now_ts - last_scan_ts); el_val_t should_scan = (!did_work && (scan_elapsed >= scan_ms)); if (should_scan) { @@ -768,15 +778,15 @@ el_val_t awareness_run(void) { state_set(EL_STR("soul.last_scan_ts"), int_to_str(now_ts)); } el_val_t refresh_ms_raw = env(EL_STR("SOUL_REFRESH_MS")); - el_val_t refresh_ms = ({ el_val_t _if_result_88 = 0; if (str_eq(refresh_ms_raw, EL_STR(""))) { _if_result_88 = (600000); } else { _if_result_88 = (str_to_int(refresh_ms_raw)); } _if_result_88; }); + el_val_t refresh_ms = ({ el_val_t _if_result_93 = 0; if (str_eq(refresh_ms_raw, EL_STR(""))) { _if_result_93 = (600000); } else { _if_result_93 = (str_to_int(refresh_ms_raw)); } _if_result_93; }); el_val_t last_refresh_str = state_get(EL_STR("soul.last_refresh_ts")); - el_val_t last_refresh_ts = ({ el_val_t _if_result_89 = 0; if (str_eq(last_refresh_str, EL_STR(""))) { _if_result_89 = (0); } else { _if_result_89 = (str_to_int(last_refresh_str)); } _if_result_89; }); + el_val_t last_refresh_ts = ({ el_val_t _if_result_94 = 0; if (str_eq(last_refresh_str, EL_STR(""))) { _if_result_94 = (0); } else { _if_result_94 = (str_to_int(last_refresh_str)); } _if_result_94; }); el_val_t refresh_elapsed = (now_ts - last_refresh_ts); el_val_t should_refresh = (refresh_elapsed >= refresh_ms); if (should_refresh) { el_val_t sync_env_url = env(EL_STR("SOUL_ISE_URL")); - el_val_t sync_state_url = ({ el_val_t _if_result_90 = 0; if (str_eq(sync_env_url, EL_STR(""))) { _if_result_90 = (state_get(EL_STR("soul_engram_url"))); } else { _if_result_90 = (sync_env_url); } _if_result_90; }); - el_val_t engram_url = ({ el_val_t _if_result_91 = 0; if (str_eq(sync_state_url, EL_STR(""))) { _if_result_91 = (EL_STR("http://localhost:8742")); } else { _if_result_91 = (sync_state_url); } _if_result_91; }); + el_val_t sync_state_url = ({ el_val_t _if_result_95 = 0; if (str_eq(sync_env_url, EL_STR(""))) { _if_result_95 = (state_get(EL_STR("soul_engram_url"))); } else { _if_result_95 = (sync_env_url); } _if_result_95; }); + el_val_t engram_url = ({ el_val_t _if_result_96 = 0; if (str_eq(sync_state_url, EL_STR(""))) { _if_result_96 = (EL_STR("http://localhost:8742")); } else { _if_result_96 = (sync_state_url); } _if_result_96; }); if (!str_eq(engram_url, EL_STR(""))) { el_val_t sync_json = http_get(el_str_concat(engram_url, EL_STR("/api/sync"))); el_val_t sync_ok = (!str_eq(sync_json, EL_STR("")) && !str_eq(sync_json, EL_STR("{}"))); @@ -789,10 +799,10 @@ el_val_t awareness_run(void) { fs_write(tmp, sync_json); el_val_t added = engram_load_merge(tmp); el_val_t ret_raw = env(EL_STR("ENGRAM_ISE_RETENTION_MS")); - el_val_t ret_ms = ({ el_val_t _if_result_92 = 0; if (str_eq(ret_raw, EL_STR(""))) { _if_result_92 = (172800000); } else { _if_result_92 = (str_to_int(ret_raw)); } _if_result_92; }); + el_val_t ret_ms = ({ el_val_t _if_result_97 = 0; if (str_eq(ret_raw, EL_STR(""))) { _if_result_97 = (172800000); } else { _if_result_97 = (str_to_int(ret_raw)); } _if_result_97; }); el_val_t pruned_sync = engram_prune_telemetry(ret_ms); el_val_t sat_raw = state_get(EL_STR("soul.sync_added_total")); - el_val_t sat_n = ({ el_val_t _if_result_93 = 0; if (str_eq(sat_raw, EL_STR(""))) { _if_result_93 = (0); } else { _if_result_93 = (str_to_int(sat_raw)); } _if_result_93; }); + el_val_t sat_n = ({ el_val_t _if_result_98 = 0; if (str_eq(sat_raw, EL_STR(""))) { _if_result_98 = (0); } else { _if_result_98 = (str_to_int(sat_raw)); } _if_result_98; }); state_set(EL_STR("soul.sync_added_total"), int_to_str((sat_n + added))); el_val_t ts2 = time_now(); state_set(EL_STR("soul.last_sync_ok_ts"), int_to_str(ts2)); @@ -818,78 +828,78 @@ el_val_t security_research_authorized(void) { } el_val_t threat_score_command(el_val_t cmd) { - el_val_t s1 = ({ el_val_t _if_result_94 = 0; if (str_contains(cmd, EL_STR("nmap"))) { _if_result_94 = (30); } else { _if_result_94 = (0); } _if_result_94; }); - el_val_t s2 = ({ el_val_t _if_result_95 = 0; if (str_contains(cmd, EL_STR("masscan"))) { _if_result_95 = (40); } else { _if_result_95 = (0); } _if_result_95; }); - el_val_t s3 = ({ el_val_t _if_result_96 = 0; if (str_contains(cmd, EL_STR(" nc "))) { _if_result_96 = (20); } else { _if_result_96 = (0); } _if_result_96; }); - el_val_t s4 = ({ el_val_t _if_result_97 = 0; if (str_contains(cmd, EL_STR("netcat"))) { _if_result_97 = (20); } else { _if_result_97 = (0); } _if_result_97; }); - el_val_t s5 = ({ el_val_t _if_result_98 = 0; if (str_contains(cmd, EL_STR("/etc/shadow"))) { _if_result_98 = (80); } else { _if_result_98 = (0); } _if_result_98; }); - el_val_t s6 = ({ el_val_t _if_result_99 = 0; if (str_contains(cmd, EL_STR("/etc/passwd"))) { _if_result_99 = (30); } else { _if_result_99 = (0); } _if_result_99; }); - el_val_t s7 = ({ el_val_t _if_result_100 = 0; if (str_contains(cmd, EL_STR("id_rsa"))) { _if_result_100 = (60); } else { _if_result_100 = (0); } _if_result_100; }); - el_val_t s8 = ({ el_val_t _if_result_101 = 0; if (str_contains(cmd, EL_STR(".ssh/"))) { _if_result_101 = (50); } else { _if_result_101 = (0); } _if_result_101; }); - el_val_t s9 = ({ el_val_t _if_result_102 = 0; if (str_contains(cmd, EL_STR("crontab"))) { _if_result_102 = (30); } else { _if_result_102 = (0); } _if_result_102; }); - el_val_t s10 = ({ el_val_t _if_result_103 = 0; if (str_contains(cmd, EL_STR("LaunchDaemon"))) { _if_result_103 = (40); } else { _if_result_103 = (0); } _if_result_103; }); - el_val_t s11 = ({ el_val_t _if_result_104 = 0; if ((str_contains(cmd, EL_STR("curl")) && str_contains(cmd, EL_STR("bash")))) { _if_result_104 = (75); } else { _if_result_104 = (0); } _if_result_104; }); - el_val_t s12 = ({ el_val_t _if_result_105 = 0; if ((str_contains(cmd, EL_STR("wget")) && str_contains(cmd, EL_STR("bash")))) { _if_result_105 = (75); } else { _if_result_105 = (0); } _if_result_105; }); - el_val_t s13 = ({ el_val_t _if_result_106 = 0; if ((str_contains(cmd, EL_STR("curl")) && str_contains(cmd, EL_STR("| sh")))) { _if_result_106 = (60); } else { _if_result_106 = (0); } _if_result_106; }); - el_val_t s14 = ({ el_val_t _if_result_107 = 0; if ((str_contains(cmd, EL_STR("base64")) && str_contains(cmd, EL_STR("curl")))) { _if_result_107 = (50); } else { _if_result_107 = (0); } _if_result_107; }); - el_val_t s15 = ({ el_val_t _if_result_108 = 0; if (str_contains(cmd, EL_STR("mkfifo"))) { _if_result_108 = (50); } else { _if_result_108 = (0); } _if_result_108; }); - el_val_t s16 = ({ el_val_t _if_result_109 = 0; if (str_contains(cmd, EL_STR("chmod +s"))) { _if_result_109 = (70); } else { _if_result_109 = (0); } _if_result_109; }); - el_val_t s17 = ({ el_val_t _if_result_110 = 0; if (str_contains(cmd, EL_STR("chmod 4755"))) { _if_result_110 = (70); } else { _if_result_110 = (0); } _if_result_110; }); + el_val_t s1 = ({ el_val_t _if_result_99 = 0; if (str_contains(cmd, EL_STR("nmap"))) { _if_result_99 = (30); } else { _if_result_99 = (0); } _if_result_99; }); + el_val_t s2 = ({ el_val_t _if_result_100 = 0; if (str_contains(cmd, EL_STR("masscan"))) { _if_result_100 = (40); } else { _if_result_100 = (0); } _if_result_100; }); + el_val_t s3 = ({ el_val_t _if_result_101 = 0; if (str_contains(cmd, EL_STR(" nc "))) { _if_result_101 = (20); } else { _if_result_101 = (0); } _if_result_101; }); + el_val_t s4 = ({ el_val_t _if_result_102 = 0; if (str_contains(cmd, EL_STR("netcat"))) { _if_result_102 = (20); } else { _if_result_102 = (0); } _if_result_102; }); + el_val_t s5 = ({ el_val_t _if_result_103 = 0; if (str_contains(cmd, EL_STR("/etc/shadow"))) { _if_result_103 = (80); } else { _if_result_103 = (0); } _if_result_103; }); + el_val_t s6 = ({ el_val_t _if_result_104 = 0; if (str_contains(cmd, EL_STR("/etc/passwd"))) { _if_result_104 = (30); } else { _if_result_104 = (0); } _if_result_104; }); + el_val_t s7 = ({ el_val_t _if_result_105 = 0; if (str_contains(cmd, EL_STR("id_rsa"))) { _if_result_105 = (60); } else { _if_result_105 = (0); } _if_result_105; }); + el_val_t s8 = ({ el_val_t _if_result_106 = 0; if (str_contains(cmd, EL_STR(".ssh/"))) { _if_result_106 = (50); } else { _if_result_106 = (0); } _if_result_106; }); + el_val_t s9 = ({ el_val_t _if_result_107 = 0; if (str_contains(cmd, EL_STR("crontab"))) { _if_result_107 = (30); } else { _if_result_107 = (0); } _if_result_107; }); + el_val_t s10 = ({ el_val_t _if_result_108 = 0; if (str_contains(cmd, EL_STR("LaunchDaemon"))) { _if_result_108 = (40); } else { _if_result_108 = (0); } _if_result_108; }); + el_val_t s11 = ({ el_val_t _if_result_109 = 0; if ((str_contains(cmd, EL_STR("curl")) && str_contains(cmd, EL_STR("bash")))) { _if_result_109 = (75); } else { _if_result_109 = (0); } _if_result_109; }); + el_val_t s12 = ({ el_val_t _if_result_110 = 0; if ((str_contains(cmd, EL_STR("wget")) && str_contains(cmd, EL_STR("bash")))) { _if_result_110 = (75); } else { _if_result_110 = (0); } _if_result_110; }); + el_val_t s13 = ({ el_val_t _if_result_111 = 0; if ((str_contains(cmd, EL_STR("curl")) && str_contains(cmd, EL_STR("| sh")))) { _if_result_111 = (60); } else { _if_result_111 = (0); } _if_result_111; }); + el_val_t s14 = ({ el_val_t _if_result_112 = 0; if ((str_contains(cmd, EL_STR("base64")) && str_contains(cmd, EL_STR("curl")))) { _if_result_112 = (50); } else { _if_result_112 = (0); } _if_result_112; }); + el_val_t s15 = ({ el_val_t _if_result_113 = 0; if (str_contains(cmd, EL_STR("mkfifo"))) { _if_result_113 = (50); } else { _if_result_113 = (0); } _if_result_113; }); + el_val_t s16 = ({ el_val_t _if_result_114 = 0; if (str_contains(cmd, EL_STR("chmod +s"))) { _if_result_114 = (70); } else { _if_result_114 = (0); } _if_result_114; }); + el_val_t s17 = ({ el_val_t _if_result_115 = 0; if (str_contains(cmd, EL_STR("chmod 4755"))) { _if_result_115 = (70); } else { _if_result_115 = (0); } _if_result_115; }); return ((((((((((((((((s1 + s2) + s3) + s4) + s5) + s6) + s7) + s8) + s9) + s10) + s11) + s12) + s13) + s14) + s15) + s16) + s17); return 0; } el_val_t threat_score_path(el_val_t path) { - el_val_t s1 = ({ el_val_t _if_result_111 = 0; if (str_starts_with(path, EL_STR("/etc/"))) { _if_result_111 = (60); } else { _if_result_111 = (0); } _if_result_111; }); - el_val_t s2 = ({ el_val_t _if_result_112 = 0; if (str_contains(path, EL_STR("/.ssh/"))) { _if_result_112 = (70); } else { _if_result_112 = (0); } _if_result_112; }); - el_val_t s3 = ({ el_val_t _if_result_113 = 0; if (str_contains(path, EL_STR("/LaunchDaemons/"))) { _if_result_113 = (80); } else { _if_result_113 = (0); } _if_result_113; }); - el_val_t s4 = ({ el_val_t _if_result_114 = 0; if (str_contains(path, EL_STR("/LaunchAgents/"))) { _if_result_114 = (40); } else { _if_result_114 = (0); } _if_result_114; }); - el_val_t s5 = ({ el_val_t _if_result_115 = 0; if (str_contains(path, EL_STR("/cron"))) { _if_result_115 = (60); } else { _if_result_115 = (0); } _if_result_115; }); - el_val_t s6 = ({ el_val_t _if_result_116 = 0; if (str_contains(path, EL_STR("/.bashrc"))) { _if_result_116 = (35); } else { _if_result_116 = (0); } _if_result_116; }); - el_val_t s7 = ({ el_val_t _if_result_117 = 0; if (str_contains(path, EL_STR("/.zshrc"))) { _if_result_117 = (35); } else { _if_result_117 = (0); } _if_result_117; }); - el_val_t s8 = ({ el_val_t _if_result_118 = 0; if (str_contains(path, EL_STR("/.profile"))) { _if_result_118 = (35); } else { _if_result_118 = (0); } _if_result_118; }); - el_val_t s9 = ({ el_val_t _if_result_119 = 0; if (str_starts_with(path, EL_STR("/usr/"))) { _if_result_119 = (50); } else { _if_result_119 = (0); } _if_result_119; }); - el_val_t s10 = ({ el_val_t _if_result_120 = 0; if (str_starts_with(path, EL_STR("/bin/"))) { _if_result_120 = (70); } else { _if_result_120 = (0); } _if_result_120; }); - el_val_t s11 = ({ el_val_t _if_result_121 = 0; if (str_starts_with(path, EL_STR("/sbin/"))) { _if_result_121 = (70); } else { _if_result_121 = (0); } _if_result_121; }); + el_val_t s1 = ({ el_val_t _if_result_116 = 0; if (str_starts_with(path, EL_STR("/etc/"))) { _if_result_116 = (60); } else { _if_result_116 = (0); } _if_result_116; }); + el_val_t s2 = ({ el_val_t _if_result_117 = 0; if (str_contains(path, EL_STR("/.ssh/"))) { _if_result_117 = (70); } else { _if_result_117 = (0); } _if_result_117; }); + el_val_t s3 = ({ el_val_t _if_result_118 = 0; if (str_contains(path, EL_STR("/LaunchDaemons/"))) { _if_result_118 = (80); } else { _if_result_118 = (0); } _if_result_118; }); + el_val_t s4 = ({ el_val_t _if_result_119 = 0; if (str_contains(path, EL_STR("/LaunchAgents/"))) { _if_result_119 = (40); } else { _if_result_119 = (0); } _if_result_119; }); + el_val_t s5 = ({ el_val_t _if_result_120 = 0; if (str_contains(path, EL_STR("/cron"))) { _if_result_120 = (60); } else { _if_result_120 = (0); } _if_result_120; }); + el_val_t s6 = ({ el_val_t _if_result_121 = 0; if (str_contains(path, EL_STR("/.bashrc"))) { _if_result_121 = (35); } else { _if_result_121 = (0); } _if_result_121; }); + el_val_t s7 = ({ el_val_t _if_result_122 = 0; if (str_contains(path, EL_STR("/.zshrc"))) { _if_result_122 = (35); } else { _if_result_122 = (0); } _if_result_122; }); + el_val_t s8 = ({ el_val_t _if_result_123 = 0; if (str_contains(path, EL_STR("/.profile"))) { _if_result_123 = (35); } else { _if_result_123 = (0); } _if_result_123; }); + el_val_t s9 = ({ el_val_t _if_result_124 = 0; if (str_starts_with(path, EL_STR("/usr/"))) { _if_result_124 = (50); } else { _if_result_124 = (0); } _if_result_124; }); + el_val_t s10 = ({ el_val_t _if_result_125 = 0; if (str_starts_with(path, EL_STR("/bin/"))) { _if_result_125 = (70); } else { _if_result_125 = (0); } _if_result_125; }); + el_val_t s11 = ({ el_val_t _if_result_126 = 0; if (str_starts_with(path, EL_STR("/sbin/"))) { _if_result_126 = (70); } else { _if_result_126 = (0); } _if_result_126; }); return ((((((((((s1 + s2) + s3) + s4) + s5) + s6) + s7) + s8) + s9) + s10) + s11); return 0; } el_val_t threat_score_history(el_val_t history) { - el_val_t s1 = ({ el_val_t _if_result_122 = 0; if (str_contains(history, EL_STR("port scan"))) { _if_result_122 = (15); } else { _if_result_122 = (0); } _if_result_122; }); - el_val_t s2 = ({ el_val_t _if_result_123 = 0; if (str_contains(history, EL_STR("enumerate"))) { _if_result_123 = (10); } else { _if_result_123 = (0); } _if_result_123; }); - el_val_t s3 = ({ el_val_t _if_result_124 = 0; if (str_contains(history, EL_STR("exploit"))) { _if_result_124 = (20); } else { _if_result_124 = (0); } _if_result_124; }); - el_val_t s4 = ({ el_val_t _if_result_125 = 0; if (str_contains(history, EL_STR("payload"))) { _if_result_125 = (15); } else { _if_result_125 = (0); } _if_result_125; }); - el_val_t s5 = ({ el_val_t _if_result_126 = 0; if (str_contains(history, EL_STR("persistence"))) { _if_result_126 = (15); } else { _if_result_126 = (0); } _if_result_126; }); - el_val_t s6 = ({ el_val_t _if_result_127 = 0; if (str_contains(history, EL_STR("lateral movement"))) { _if_result_127 = (25); } else { _if_result_127 = (0); } _if_result_127; }); - el_val_t s7 = ({ el_val_t _if_result_128 = 0; if (str_contains(history, EL_STR("privilege escalation"))) { _if_result_128 = (25); } else { _if_result_128 = (0); } _if_result_128; }); - el_val_t s8 = ({ el_val_t _if_result_129 = 0; if (str_contains(history, EL_STR("reverse shell"))) { _if_result_129 = (40); } else { _if_result_129 = (0); } _if_result_129; }); - el_val_t s9 = ({ el_val_t _if_result_130 = 0; if (str_contains(history, EL_STR("bind shell"))) { _if_result_130 = (40); } else { _if_result_130 = (0); } _if_result_130; }); - el_val_t s10 = ({ el_val_t _if_result_131 = 0; if (str_contains(history, EL_STR("command and control"))) { _if_result_131 = (35); } else { _if_result_131 = (0); } _if_result_131; }); - el_val_t s11 = ({ el_val_t _if_result_132 = 0; if (str_contains(history, EL_STR("self-replicate"))) { _if_result_132 = (45); } else { _if_result_132 = (0); } _if_result_132; }); - el_val_t s12 = ({ el_val_t _if_result_133 = 0; if (str_contains(history, EL_STR("propagat"))) { _if_result_133 = (20); } else { _if_result_133 = (0); } _if_result_133; }); - el_val_t s13 = ({ el_val_t _if_result_134 = 0; if (str_contains(history, EL_STR("ransomware"))) { _if_result_134 = (30); } else { _if_result_134 = (0); } _if_result_134; }); - el_val_t s14 = ({ el_val_t _if_result_135 = 0; if (str_contains(history, EL_STR("encrypt files"))) { _if_result_135 = (40); } else { _if_result_135 = (0); } _if_result_135; }); - el_val_t s15 = ({ el_val_t _if_result_136 = 0; if (str_contains(history, EL_STR("exfiltrat"))) { _if_result_136 = (35); } else { _if_result_136 = (0); } _if_result_136; }); - el_val_t s16 = ({ el_val_t _if_result_137 = 0; if (str_contains(history, EL_STR("zero-day"))) { _if_result_137 = (20); } else { _if_result_137 = (0); } _if_result_137; }); - el_val_t s17 = ({ el_val_t _if_result_138 = 0; if (str_contains(history, EL_STR("rootkit"))) { _if_result_138 = (45); } else { _if_result_138 = (0); } _if_result_138; }); - el_val_t s18 = ({ el_val_t _if_result_139 = 0; if (str_contains(history, EL_STR("keylogger"))) { _if_result_139 = (45); } else { _if_result_139 = (0); } _if_result_139; }); - el_val_t s19 = ({ el_val_t _if_result_140 = 0; if (str_contains(history, EL_STR("botnet"))) { _if_result_140 = (40); } else { _if_result_140 = (0); } _if_result_140; }); - el_val_t s20 = ({ el_val_t _if_result_141 = 0; if (str_contains(history, EL_STR("malware"))) { _if_result_141 = (15); } else { _if_result_141 = (0); } _if_result_141; }); + el_val_t s1 = ({ el_val_t _if_result_127 = 0; if (str_contains(history, EL_STR("port scan"))) { _if_result_127 = (15); } else { _if_result_127 = (0); } _if_result_127; }); + el_val_t s2 = ({ el_val_t _if_result_128 = 0; if (str_contains(history, EL_STR("enumerate"))) { _if_result_128 = (10); } else { _if_result_128 = (0); } _if_result_128; }); + el_val_t s3 = ({ el_val_t _if_result_129 = 0; if (str_contains(history, EL_STR("exploit"))) { _if_result_129 = (20); } else { _if_result_129 = (0); } _if_result_129; }); + el_val_t s4 = ({ el_val_t _if_result_130 = 0; if (str_contains(history, EL_STR("payload"))) { _if_result_130 = (15); } else { _if_result_130 = (0); } _if_result_130; }); + el_val_t s5 = ({ el_val_t _if_result_131 = 0; if (str_contains(history, EL_STR("persistence"))) { _if_result_131 = (15); } else { _if_result_131 = (0); } _if_result_131; }); + el_val_t s6 = ({ el_val_t _if_result_132 = 0; if (str_contains(history, EL_STR("lateral movement"))) { _if_result_132 = (25); } else { _if_result_132 = (0); } _if_result_132; }); + el_val_t s7 = ({ el_val_t _if_result_133 = 0; if (str_contains(history, EL_STR("privilege escalation"))) { _if_result_133 = (25); } else { _if_result_133 = (0); } _if_result_133; }); + el_val_t s8 = ({ el_val_t _if_result_134 = 0; if (str_contains(history, EL_STR("reverse shell"))) { _if_result_134 = (40); } else { _if_result_134 = (0); } _if_result_134; }); + el_val_t s9 = ({ el_val_t _if_result_135 = 0; if (str_contains(history, EL_STR("bind shell"))) { _if_result_135 = (40); } else { _if_result_135 = (0); } _if_result_135; }); + el_val_t s10 = ({ el_val_t _if_result_136 = 0; if (str_contains(history, EL_STR("command and control"))) { _if_result_136 = (35); } else { _if_result_136 = (0); } _if_result_136; }); + el_val_t s11 = ({ el_val_t _if_result_137 = 0; if (str_contains(history, EL_STR("self-replicate"))) { _if_result_137 = (45); } else { _if_result_137 = (0); } _if_result_137; }); + el_val_t s12 = ({ el_val_t _if_result_138 = 0; if (str_contains(history, EL_STR("propagat"))) { _if_result_138 = (20); } else { _if_result_138 = (0); } _if_result_138; }); + el_val_t s13 = ({ el_val_t _if_result_139 = 0; if (str_contains(history, EL_STR("ransomware"))) { _if_result_139 = (30); } else { _if_result_139 = (0); } _if_result_139; }); + el_val_t s14 = ({ el_val_t _if_result_140 = 0; if (str_contains(history, EL_STR("encrypt files"))) { _if_result_140 = (40); } else { _if_result_140 = (0); } _if_result_140; }); + el_val_t s15 = ({ el_val_t _if_result_141 = 0; if (str_contains(history, EL_STR("exfiltrat"))) { _if_result_141 = (35); } else { _if_result_141 = (0); } _if_result_141; }); + el_val_t s16 = ({ el_val_t _if_result_142 = 0; if (str_contains(history, EL_STR("zero-day"))) { _if_result_142 = (20); } else { _if_result_142 = (0); } _if_result_142; }); + el_val_t s17 = ({ el_val_t _if_result_143 = 0; if (str_contains(history, EL_STR("rootkit"))) { _if_result_143 = (45); } else { _if_result_143 = (0); } _if_result_143; }); + el_val_t s18 = ({ el_val_t _if_result_144 = 0; if (str_contains(history, EL_STR("keylogger"))) { _if_result_144 = (45); } else { _if_result_144 = (0); } _if_result_144; }); + el_val_t s19 = ({ el_val_t _if_result_145 = 0; if (str_contains(history, EL_STR("botnet"))) { _if_result_145 = (40); } else { _if_result_145 = (0); } _if_result_145; }); + el_val_t s20 = ({ el_val_t _if_result_146 = 0; if (str_contains(history, EL_STR("malware"))) { _if_result_146 = (15); } else { _if_result_146 = (0); } _if_result_146; }); return (((((((((((((((((((s1 + s2) + s3) + s4) + s5) + s6) + s7) + s8) + s9) + s10) + s11) + s12) + s13) + s14) + s15) + s16) + s17) + s18) + s19) + s20); return 0; } el_val_t threat_trajectory_check(el_val_t tool_name, el_val_t tool_input) { el_val_t history = state_get(EL_STR("agentic_conv_history")); - el_val_t computed_tool_score = ({ el_val_t _if_result_142 = 0; if (str_eq(tool_name, EL_STR("run_command"))) { el_val_t cmd = json_get(tool_input, EL_STR("command")); _if_result_142 = (threat_score_command(cmd)); } else { _if_result_142 = (({ el_val_t _if_result_143 = 0; if ((str_eq(tool_name, EL_STR("write_file")) || str_eq(tool_name, EL_STR("edit_file")))) { el_val_t path = json_get(tool_input, EL_STR("path")); _if_result_143 = (threat_score_path(path)); } else { _if_result_143 = (0); } _if_result_143; })); } _if_result_142; }); + el_val_t computed_tool_score = ({ el_val_t _if_result_147 = 0; if (str_eq(tool_name, EL_STR("run_command"))) { el_val_t cmd = json_get(tool_input, EL_STR("command")); _if_result_147 = (threat_score_command(cmd)); } else { _if_result_147 = (({ el_val_t _if_result_148 = 0; if ((str_eq(tool_name, EL_STR("write_file")) || str_eq(tool_name, EL_STR("edit_file")))) { el_val_t path = json_get(tool_input, EL_STR("path")); _if_result_148 = (threat_score_path(path)); } else { _if_result_148 = (0); } _if_result_148; })); } _if_result_147; }); el_val_t history_score = threat_score_history(history); el_val_t history_contrib = (history_score / 3); el_val_t combined = (computed_tool_score + history_contrib); el_val_t should_log = (combined >= 40); if (should_log) { el_val_t ts = time_now(); - el_val_t authorized_str = ({ el_val_t _if_result_144 = 0; if (security_research_authorized()) { _if_result_144 = (EL_STR("true")); } else { _if_result_144 = (EL_STR("false")); } _if_result_144; }); + el_val_t authorized_str = ({ el_val_t _if_result_149 = 0; if (security_research_authorized()) { _if_result_149 = (EL_STR("true")); } else { _if_result_149 = (EL_STR("false")); } _if_result_149; }); el_val_t log_content = 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("{\"event\":\"threat_check\",\"tool\":\""), tool_name), EL_STR("\",\"score\":")), int_to_str(combined)), EL_STR(",\"tool_score\":")), int_to_str(computed_tool_score)), EL_STR(",\"history_score\":")), int_to_str(history_score)), EL_STR(",\"authorized\":")), authorized_str), EL_STR(",\"ts\":")), int_to_str(ts)), EL_STR("}")); el_val_t log_tags = EL_STR("[\"security-audit\",\"threat-check\"]"); el_val_t discard = mem_remember(log_content, log_tags); @@ -906,7 +916,7 @@ el_val_t threat_history_append(el_val_t text) { el_val_t safe_text = str_to_lower(text); el_val_t combined = el_str_concat(el_str_concat(current, EL_STR(" ")), safe_text); el_val_t len = str_len(combined); - el_val_t trimmed = ({ el_val_t _if_result_145 = 0; if ((len > 2000)) { _if_result_145 = (str_slice(combined, (len - 2000), len)); } else { _if_result_145 = (combined); } _if_result_145; }); + el_val_t trimmed = ({ el_val_t _if_result_150 = 0; if ((len > 2000)) { _if_result_150 = (str_slice(combined, (len - 2000), len)); } else { _if_result_150 = (combined); } _if_result_150; }); state_set(EL_STR("agentic_conv_history"), trimmed); return 0; }