diff --git a/awareness.el b/awareness.el index 1d50f39..3569ef1 100644 --- a/awareness.el +++ b/awareness.el @@ -61,6 +61,17 @@ fn elapsed_human() -> String { return int_to_str(s) + "s" } +// embed_ok — returns 1 if Ollama embedding service is reachable, 0 if not. +// Probes http://localhost:11434 (Ollama root) with a GET; any non-empty +// response means the service is up. Used in heartbeat for observability: +// when embed_ok=0, semantic seed injection silently falls back to lexical- +// only activation and that gap should be visible in the ISE stream. +fn embed_ok() -> Int { + let resp: String = http_get("http://localhost:11434") + if str_eq(resp, "") { return 0 } + return 1 +} + fn emit_heartbeat() -> Void { // Guard against empty state values producing invalid JSON (e.g. "pulse":,). // state_get returns "" for unset keys; default to "0" for numeric fields. @@ -75,7 +86,8 @@ fn emit_heartbeat() -> Void { let wmc: Int = engram_wm_count() let up_ms: Int = elapsed_ms() let up_human: String = elapsed_human() - let payload: String = "{\"event\":\"heartbeat\",\"pulse\":" + pulse + ",\"boot\":" + boot + ",\"idle\":" + idle + ",\"node_count\":" + int_to_str(nc) + ",\"edge_count\":" + int_to_str(ec) + ",\"wm_active\":" + int_to_str(wmc) + ",\"ts\":" + int_to_str(ts) + ",\"uptime_ms\":" + int_to_str(up_ms) + ",\"uptime\":\"" + up_human + "\"}" + let emb_ok: Int = embed_ok() + let payload: String = "{\"event\":\"heartbeat\",\"pulse\":" + pulse + ",\"boot\":" + boot + ",\"idle\":" + idle + ",\"node_count\":" + int_to_str(nc) + ",\"edge_count\":" + int_to_str(ec) + ",\"wm_active\":" + int_to_str(wmc) + ",\"ts\":" + int_to_str(ts) + ",\"uptime_ms\":" + int_to_str(up_ms) + ",\"uptime\":\"" + up_human + "\",\"embed_ok\":" + int_to_str(emb_ok) + "}" ise_post(payload) } diff --git a/dist/awareness.c b/dist/awareness.c index 8018c84..365ba42 100644 --- a/dist/awareness.c +++ b/dist/awareness.c @@ -23,6 +23,7 @@ el_val_t idle_reset(void); el_val_t ise_post(el_val_t content); el_val_t elapsed_ms(void); el_val_t elapsed_human(void); +el_val_t embed_ok(void); el_val_t emit_heartbeat(void); el_val_t pulse_count(void); el_val_t pulse_inc(void); @@ -102,6 +103,15 @@ el_val_t elapsed_human(void) { return 0; } +el_val_t embed_ok(void) { + el_val_t resp = http_get(EL_STR("http://localhost:11434")); + if (str_eq(resp, EL_STR(""))) { + return 0; + } + return 1; + return 0; +} + el_val_t emit_heartbeat(void) { el_val_t pulse_raw = state_get(EL_STR("soul.pulse")); el_val_t pulse = ({ el_val_t _if_result_2 = 0; if (str_eq(pulse_raw, EL_STR(""))) { _if_result_2 = (EL_STR("0")); } else { _if_result_2 = (pulse_raw); } _if_result_2; }); @@ -114,7 +124,8 @@ el_val_t emit_heartbeat(void) { el_val_t wmc = engram_wm_count(); el_val_t up_ms = elapsed_ms(); el_val_t up_human = elapsed_human(); - 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("{\"event\":\"heartbeat\",\"pulse\":"), pulse), EL_STR(",\"boot\":")), boot), EL_STR(",\"idle\":")), idle), EL_STR(",\"node_count\":")), int_to_str(nc)), EL_STR(",\"edge_count\":")), int_to_str(ec)), EL_STR(",\"wm_active\":")), int_to_str(wmc)), EL_STR(",\"ts\":")), int_to_str(ts)), EL_STR(",\"uptime_ms\":")), int_to_str(up_ms)), EL_STR(",\"uptime\":\"")), up_human), EL_STR("\"}")); + el_val_t emb_ok = embed_ok(); + 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("{\"event\":\"heartbeat\",\"pulse\":"), pulse), EL_STR(",\"boot\":")), boot), EL_STR(",\"idle\":")), idle), EL_STR(",\"node_count\":")), int_to_str(nc)), EL_STR(",\"edge_count\":")), int_to_str(ec)), EL_STR(",\"wm_active\":")), int_to_str(wmc)), 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("}")); ise_post(payload); return 0; } diff --git a/dist/elp-c-decls.h b/dist/elp-c-decls.h index 82fc03e..ff24523 100644 --- a/dist/elp-c-decls.h +++ b/dist/elp-c-decls.h @@ -226,6 +226,7 @@ el_val_t elapsed_ms(void); el_val_t elp_detect_predicate(el_val_t msg); el_val_t elp_extract_topic(el_val_t msg); el_val_t elp_parse(el_val_t msg); +el_val_t embed_ok(void); el_val_t emit_heartbeat(void); el_val_t emit_session_start_event(void); el_val_t en_irregular_plural(el_val_t word); diff --git a/dist/neuron b/dist/neuron index 46478db..d48e411 100755 Binary files a/dist/neuron and b/dist/neuron differ