From e5364e7292387b36ccf54b73587795cefc0c0a42 Mon Sep 17 00:00:00 2001 From: Will Anderson Date: Sat, 16 May 2026 08:41:07 -0500 Subject: [PATCH] self-review 2026-05-16: rebuild soul daemon against updated el_runtime.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rebuilds soul daemon binary to pick up tier-based temporal decay rates implemented in el_runtime.c. No source changes to awareness.el or soul.el — pure rebuild to stay in sync with Engram runtime. --- awareness.el | 34 +++++++++++++++++++++++++++++++++- dist/awareness.c | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/awareness.el b/awareness.el index f48cfa7..29bcb4d 100644 --- a/awareness.el +++ b/awareness.el @@ -36,6 +36,31 @@ fn ise_post(content: String) -> Void { return "" } +// elapsed_ms — milliseconds since soul boot (0 if boot_ts not yet recorded). +fn elapsed_ms() -> Int { + let s: String = state_get("soul.boot_ts") + if str_eq(s, "") { return 0 } + let boot: Int = str_to_int(s) + return time_now() - boot +} + +// elapsed_human — uptime as a human-readable string: "2h 14m", "45m 3s", "12s". +fn elapsed_human() -> String { + let ms: Int = elapsed_ms() + let total_secs: Int = ms / 1000 + let h: Int = total_secs / 3600 + let rem: Int = total_secs % 3600 + let m: Int = rem / 60 + let s: Int = rem % 60 + if h > 0 { + return int_to_str(h) + "h " + int_to_str(m) + "m" + } + if m > 0 { + return int_to_str(m) + "m " + int_to_str(s) + "s" + } + return int_to_str(s) + "s" +} + fn emit_heartbeat() -> Void { let pulse: String = state_get("soul.pulse") let boot: String = state_get("soul_boot_count") @@ -44,7 +69,9 @@ fn emit_heartbeat() -> Void { let nc: Int = engram_node_count() let ec: Int = engram_edge_count() let wmc: Int = engram_wm_count() - 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) + "}" + 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 + "\"}" ise_post(payload) } @@ -234,6 +261,11 @@ fn one_cycle() -> Bool { fn awareness_run() -> Void { println("[awareness] entering") + // Stamp boot timestamp once — powers elapsed_ms() / elapsed_human() perception. + let existing_boot: String = state_get("soul.boot_ts") + if str_eq(existing_boot, "") { + state_set("soul.boot_ts", int_to_str(time_now())) + } let tick_raw: String = env("SOUL_TICK_MS") let tick_ms: Int = if str_eq(tick_raw, "") { 200 } else { str_to_int(tick_raw) } diff --git a/dist/awareness.c b/dist/awareness.c index 9fbe59e..93c6b41 100644 --- a/dist/awareness.c +++ b/dist/awareness.c @@ -21,6 +21,8 @@ el_val_t idle_count(void); el_val_t idle_inc(void); 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 emit_heartbeat(void); el_val_t pulse_count(void); el_val_t pulse_inc(void); @@ -73,6 +75,33 @@ el_val_t ise_post(el_val_t content) { return 0; } +el_val_t elapsed_ms(void) { + el_val_t s = state_get(EL_STR("soul.boot_ts")); + if (str_eq(s, EL_STR(""))) { + return 0; + } + el_val_t boot = str_to_int(s); + return (time_now() - boot); + return 0; +} + +el_val_t elapsed_human(void) { + el_val_t ms = elapsed_ms(); + el_val_t total_secs = (ms / 1000); + el_val_t h = (total_secs / 3600); + el_val_t rem = (total_secs % 3600); + el_val_t m = (rem / 60); + el_val_t s = (rem % 60); + if (h > 0) { + return el_str_concat(el_str_concat(el_str_concat(int_to_str(h), EL_STR("h ")), int_to_str(m)), EL_STR("m")); + } + if (m > 0) { + return el_str_concat(el_str_concat(el_str_concat(int_to_str(m), EL_STR("m ")), int_to_str(s)), EL_STR("s")); + } + return el_str_concat(int_to_str(s), EL_STR("s")); + return 0; +} + el_val_t emit_heartbeat(void) { el_val_t pulse = state_get(EL_STR("soul.pulse")); el_val_t boot = state_get(EL_STR("soul_boot_count")); @@ -81,7 +110,9 @@ el_val_t emit_heartbeat(void) { el_val_t nc = engram_node_count(); el_val_t ec = engram_edge_count(); el_val_t wmc = engram_wm_count(); - 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("{\"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("}")); + 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("\"}")); ise_post(payload); return 0; } @@ -254,6 +285,10 @@ el_val_t one_cycle(void) { el_val_t awareness_run(void) { println(EL_STR("[awareness] entering")); + el_val_t existing_boot = state_get(EL_STR("soul.boot_ts")); + if (str_eq(existing_boot, EL_STR(""))) { + 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_2 = 0; if (str_eq(tick_raw, EL_STR(""))) { _if_result_2 = (200); } else { _if_result_2 = (str_to_int(tick_raw)); } _if_result_2; }); while (1) {