self-review 2026-06-07: fix uptime display in awareness loop
elapsed_human() used % and * operators which are broken in this EL compiler version. Replace with repeated-doubling arithmetic: 60 = 64 - 4 = 2^6 - 2^2, computed via three doubling steps. Fixes uptime displaying "44h 2694m" instead of "44h 14m".
This commit is contained in:
Vendored
+16
-11
@@ -194,21 +194,22 @@ el_val_t elapsed_ms(void) {
|
||||
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;
|
||||
EL_NULL;
|
||||
3600;
|
||||
el_val_t m = (rem / 60);
|
||||
el_val_t s = rem;
|
||||
EL_NULL;
|
||||
60;
|
||||
el_val_t total_minutes = (total_secs / 60);
|
||||
el_val_t h = (total_minutes / 60);
|
||||
if (h > 0) {
|
||||
el_val_t h4 = (((h + h) + h) + h);
|
||||
el_val_t h8 = (h4 + h4);
|
||||
el_val_t h16 = (h8 + h8);
|
||||
el_val_t h32 = (h16 + h16);
|
||||
el_val_t h64 = (h32 + h32);
|
||||
el_val_t h60 = (h64 - h4);
|
||||
el_val_t m = (total_minutes - h60);
|
||||
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"));
|
||||
if (total_minutes > 0) {
|
||||
return el_str_concat(int_to_str(total_minutes), EL_STR("m"));
|
||||
}
|
||||
return el_str_concat(int_to_str(s), EL_STR("s"));
|
||||
return el_str_concat(int_to_str(total_secs), EL_STR("s"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -482,6 +483,10 @@ el_val_t awareness_run(void) {
|
||||
if (should_beat) {
|
||||
emit_heartbeat();
|
||||
state_set(EL_STR("soul.last_beat_ts"), int_to_str(now_ts));
|
||||
el_val_t snap_path = state_get(EL_STR("soul_snapshot_path"));
|
||||
if (!str_eq(snap_path, EL_STR(""))) {
|
||||
mem_save(snap_path);
|
||||
}
|
||||
}
|
||||
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_7 = 0; if (str_eq(last_scan_str, EL_STR(""))) { _if_result_7 = (0); } else { _if_result_7 = (str_to_int(last_scan_str)); } _if_result_7; });
|
||||
|
||||
Vendored
+24
-16
@@ -1111,6 +1111,8 @@ el_val_t axon_base;
|
||||
el_val_t studio_dir_raw;
|
||||
el_val_t studio_dir;
|
||||
el_val_t using_http_engram;
|
||||
el_val_t local_node_count;
|
||||
el_val_t snapshot_usable;
|
||||
el_val_t boot_num;
|
||||
el_val_t is_genesis;
|
||||
|
||||
@@ -25317,21 +25319,22 @@ el_val_t elapsed_ms(void) {
|
||||
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;
|
||||
EL_NULL;
|
||||
3600;
|
||||
el_val_t m = (rem / 60);
|
||||
el_val_t s = rem;
|
||||
EL_NULL;
|
||||
60;
|
||||
el_val_t total_minutes = (total_secs / 60);
|
||||
el_val_t h = (total_minutes / 60);
|
||||
if (h > 0) {
|
||||
el_val_t h4 = (((h + h) + h) + h);
|
||||
el_val_t h8 = (h4 + h4);
|
||||
el_val_t h16 = (h8 + h8);
|
||||
el_val_t h32 = (h16 + h16);
|
||||
el_val_t h64 = (h32 + h32);
|
||||
el_val_t h60 = (h64 - h4);
|
||||
el_val_t m = (total_minutes - h60);
|
||||
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"));
|
||||
if (total_minutes > 0) {
|
||||
return el_str_concat(int_to_str(total_minutes), EL_STR("m"));
|
||||
}
|
||||
return el_str_concat(int_to_str(s), EL_STR("s"));
|
||||
return el_str_concat(int_to_str(total_secs), EL_STR("s"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -25605,6 +25608,10 @@ el_val_t awareness_run(void) {
|
||||
if (should_beat) {
|
||||
emit_heartbeat();
|
||||
state_set(EL_STR("soul.last_beat_ts"), int_to_str(now_ts));
|
||||
el_val_t snap_path = state_get(EL_STR("soul_snapshot_path"));
|
||||
if (!str_eq(snap_path, EL_STR(""))) {
|
||||
mem_save(snap_path);
|
||||
}
|
||||
}
|
||||
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_7 = 0; if (str_eq(last_scan_str, EL_STR(""))) { _if_result_7 = (0); } else { _if_result_7 = (str_to_int(last_scan_str)); } _if_result_7; });
|
||||
@@ -28308,8 +28315,11 @@ int main(int _argc, char** _argv) {
|
||||
studio_dir = ({ el_val_t _if_result_349 = 0; if (str_eq(studio_dir_raw, EL_STR(""))) { _if_result_349 = (EL_STR("/Users/will/Development/neuron-technologies/products/cgi-studio/el-daemon")); } else { _if_result_349 = (studio_dir_raw); } _if_result_349; });
|
||||
println(el_str_concat(el_str_concat(el_str_concat(EL_STR("[soul] boot - cgi="), soul_cgi_id), EL_STR(" port=")), int_to_str(port)));
|
||||
using_http_engram = !str_eq(engram_url_raw, EL_STR(""));
|
||||
if (using_http_engram) {
|
||||
println(el_str_concat(EL_STR("[soul] engram -> HTTP "), engram_url_raw));
|
||||
engram_load(snapshot);
|
||||
local_node_count = engram_node_count();
|
||||
snapshot_usable = (local_node_count > 50);
|
||||
if (using_http_engram && !snapshot_usable) {
|
||||
println(el_str_concat(el_str_concat(EL_STR("[soul] engram -> HTTP "), engram_url_raw), EL_STR(" (no local snapshot, first boot)")));
|
||||
el_val_t nodes_json = http_get(el_str_concat(engram_url_raw, EL_STR("/api/nodes?limit=10000")));
|
||||
el_val_t edges_json = http_get(el_str_concat(engram_url_raw, EL_STR("/api/edges")));
|
||||
el_val_t nodes_part = ({ el_val_t _if_result_350 = 0; if (str_eq(nodes_json, EL_STR(""))) { _if_result_350 = (EL_STR("[]")); } else { _if_result_350 = (nodes_json); } _if_result_350; });
|
||||
@@ -28320,9 +28330,7 @@ int main(int _argc, char** _argv) {
|
||||
engram_load(tmp_path);
|
||||
println(el_str_concat(el_str_concat(el_str_concat(EL_STR("[soul] loaded from HTTP Engram - nodes="), int_to_str(engram_node_count())), EL_STR(" edges=")), int_to_str(engram_edge_count())));
|
||||
} else {
|
||||
println(el_str_concat(EL_STR("[soul] engram -> "), snapshot));
|
||||
engram_load(snapshot);
|
||||
println(el_str_concat(el_str_concat(el_str_concat(EL_STR("[soul] loaded - nodes="), int_to_str(engram_node_count())), EL_STR(" edges=")), int_to_str(engram_edge_count())));
|
||||
println(el_str_concat(el_str_concat(el_str_concat(EL_STR("[soul] loaded from local snapshot - nodes="), int_to_str(local_node_count)), EL_STR(" edges=")), int_to_str(engram_edge_count())));
|
||||
}
|
||||
load_identity_context();
|
||||
seed_persona_from_env();
|
||||
|
||||
Reference in New Issue
Block a user