self-review 2026-05-18: add embed_ok to heartbeat ISE

Ollama availability is a silent failure mode: when the embedding service
is down, semantic seed injection falls back to lexical-only activation with
no signal in the ISE stream. Add embed_ok field (0/1) to every heartbeat
by probing http://localhost:11434 — makes Ollama health visible without
a separate monitoring path.
This commit is contained in:
2026-05-18 08:41:07 -05:00
parent ffd17b2774
commit 2099522c28
4 changed files with 26 additions and 2 deletions
+13 -1
View File
@@ -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)
}