self-review 2026-05-25: fix curiosity rotation and awareness_run timing
Three bugs fixed in awareness.el: 1. EL let-rebinding inside if-blocks creates inner scope only — outer variable unchanged after block exits. Curiosity seed terms were always "memory/knowledge/context" regardless of minute_block. Fix: state_set inside if-blocks, state_get after to retrieve selected values. 2. EL % operator completely broken in v1.0.0-20260501 — compiles as dead code (left operand assigned, modulo dropped). minute_block was always ts/60000 (a large int, never 0-3). Fix: arithmetic workaround: x%4 = x - (q+q+q+q) where q = x/4. 3. awareness_run idle_n % beat_interval == 0 also broken by same % bug — should_scan and should_beat fired every idle tick instead of every N ticks. Fix: idle_n >= interval comparisons with idle_reset() after firing, so the counter restarts cleanly after each event. EL % and * operators filed as P1 backlog item for elc compiler fix. Also adds minute_block field to curiosity_scan ISE for observability.
This commit is contained in:
Vendored
+27
-27
@@ -25363,27 +25363,32 @@ el_val_t emit_heartbeat(void) {
|
||||
|
||||
el_val_t proactive_curiosity(void) {
|
||||
el_val_t ts = time_now();
|
||||
el_val_t minute_block = (ts / 60000);
|
||||
EL_NULL;
|
||||
4;
|
||||
el_val_t curiosity_term_a = EL_STR("memory");
|
||||
el_val_t curiosity_term_b = EL_STR("knowledge");
|
||||
el_val_t curiosity_term_c = EL_STR("context");
|
||||
el_val_t ts_minutes = (ts / 60000);
|
||||
el_val_t minute_q = (ts_minutes / 4);
|
||||
el_val_t minute_q2 = (minute_q + minute_q);
|
||||
el_val_t minute_q4 = (minute_q2 + minute_q2);
|
||||
el_val_t minute_block = (ts_minutes - minute_q4);
|
||||
state_set(EL_STR("cseed_a"), EL_STR("memory"));
|
||||
state_set(EL_STR("cseed_b"), EL_STR("knowledge"));
|
||||
state_set(EL_STR("cseed_c"), EL_STR("context"));
|
||||
if (minute_block == 1) {
|
||||
curiosity_term_a = EL_STR("self");
|
||||
curiosity_term_b = EL_STR("identity");
|
||||
curiosity_term_c = EL_STR("values");
|
||||
state_set(EL_STR("cseed_a"), EL_STR("self"));
|
||||
state_set(EL_STR("cseed_b"), EL_STR("identity"));
|
||||
state_set(EL_STR("cseed_c"), EL_STR("values"));
|
||||
}
|
||||
if (minute_block == 2) {
|
||||
curiosity_term_a = EL_STR("decision");
|
||||
curiosity_term_b = EL_STR("pattern");
|
||||
curiosity_term_c = EL_STR("lesson");
|
||||
state_set(EL_STR("cseed_a"), EL_STR("decision"));
|
||||
state_set(EL_STR("cseed_b"), EL_STR("pattern"));
|
||||
state_set(EL_STR("cseed_c"), EL_STR("lesson"));
|
||||
}
|
||||
if (minute_block == 3) {
|
||||
curiosity_term_a = EL_STR("working");
|
||||
curiosity_term_b = EL_STR("project");
|
||||
curiosity_term_c = EL_STR("active");
|
||||
state_set(EL_STR("cseed_a"), EL_STR("working"));
|
||||
state_set(EL_STR("cseed_b"), EL_STR("project"));
|
||||
state_set(EL_STR("cseed_c"), EL_STR("active"));
|
||||
}
|
||||
el_val_t curiosity_term_a = state_get(EL_STR("cseed_a"));
|
||||
el_val_t curiosity_term_b = state_get(EL_STR("cseed_b"));
|
||||
el_val_t curiosity_term_c = state_get(EL_STR("cseed_c"));
|
||||
el_val_t curiosity_seed = el_str_concat(el_str_concat(el_str_concat(el_str_concat(curiosity_term_a, EL_STR(" ")), curiosity_term_b), EL_STR(" ")), curiosity_term_c);
|
||||
el_val_t results_a = engram_activate_json(curiosity_term_a, 1);
|
||||
el_val_t results_b = engram_activate_json(curiosity_term_b, 1);
|
||||
@@ -25393,7 +25398,7 @@ el_val_t proactive_curiosity(void) {
|
||||
el_val_t found_c = json_array_len(results_c);
|
||||
el_val_t found = ((found_a + found_b) + found_c);
|
||||
el_val_t wmc = engram_wm_count();
|
||||
el_val_t ise = el_str_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\":\"curiosity_scan\",\"seed\":\""), curiosity_seed), EL_STR("\",\"activated\":")), int_to_str(found)), EL_STR(",\"wm_active\":")), int_to_str(wmc)), EL_STR(",\"ts\":")), int_to_str(ts)), EL_STR("}"));
|
||||
el_val_t ise = el_str_concat(el_str_concat(el_str_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\":\"curiosity_scan\",\"seed\":\""), curiosity_seed), EL_STR("\",\"minute_block\":")), int_to_str(minute_block)), EL_STR(",\"activated\":")), int_to_str(found)), EL_STR(",\"wm_active\":")), int_to_str(wmc)), EL_STR(",\"ts\":")), int_to_str(ts)), EL_STR("}"));
|
||||
ise_post(ise);
|
||||
return (found > 0);
|
||||
return 0;
|
||||
@@ -25593,21 +25598,16 @@ el_val_t awareness_run(void) {
|
||||
if (curiosity_interval < 1) {
|
||||
curiosity_interval = 1;
|
||||
}
|
||||
el_val_t should_scan = ((!did_work && (idle_n > 0)) && idle_n);
|
||||
EL_NULL;
|
||||
((curiosity_interval == 0) && !idle_n);
|
||||
(beat_interval == 0);
|
||||
EL_NULL;
|
||||
if (should_scan) {
|
||||
el_val_t found_something = proactive_curiosity();
|
||||
}
|
||||
el_val_t should_beat = ((!did_work && (idle_n > 0)) && idle_n);
|
||||
EL_NULL;
|
||||
(beat_interval == 0);
|
||||
el_val_t should_beat = ((!did_work && (idle_n > 0)) && (idle_n >= beat_interval));
|
||||
if (should_beat) {
|
||||
emit_heartbeat();
|
||||
idle_reset();
|
||||
}
|
||||
el_val_t should_scan = (((!did_work && (idle_n > 0)) && (idle_n >= curiosity_interval)) && !should_beat);
|
||||
if (should_scan) {
|
||||
el_val_t found_something = proactive_curiosity();
|
||||
idle_reset();
|
||||
}
|
||||
sleep_ms(tick_ms);
|
||||
}
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user