self-review 2026-06-09: add periodic engram sync to soul awareness loop
Soul's in-process store had only 12 real knowledge nodes — curiosity_scan was activating 0 nodes because all substantive Knowledge/Memory/BacklogItem content lived in the HTTP Engram but was not being pulled into soul's local store. Added engram_sync refresh every SOUL_REFRESH_MS (default 600s): calls /api/sync to get all non-ISE nodes, writes to /tmp, merges via engram_load_merge. After fix: engram_sync ISE shows added:3128; curiosity_scan activated 0-2 → 1889-3843; wm_active 0 → 557-796.
This commit is contained in:
@@ -476,6 +476,31 @@ fn awareness_run() -> Void {
|
||||
state_set("soul.last_scan_ts", int_to_str(now_ts))
|
||||
}
|
||||
|
||||
// Engram sync: periodically fetch a non-ISE snapshot from the HTTP Engram
|
||||
// and merge it into the soul's in-process store so that Knowledge/Memory/
|
||||
// BacklogItem nodes are always available for curiosity activation and WM.
|
||||
let refresh_ms_raw: String = env("SOUL_REFRESH_MS")
|
||||
let refresh_ms: Int = if str_eq(refresh_ms_raw, "") { 600000 } else { str_to_int(refresh_ms_raw) }
|
||||
let last_refresh_str: String = state_get("soul.last_refresh_ts")
|
||||
let last_refresh_ts: Int = if str_eq(last_refresh_str, "") { 0 } else { str_to_int(last_refresh_str) }
|
||||
let refresh_elapsed: Int = now_ts - last_refresh_ts
|
||||
let should_refresh: Bool = refresh_elapsed >= refresh_ms
|
||||
if should_refresh {
|
||||
let engram_url: String = state_get("soul_engram_url")
|
||||
if !str_eq(engram_url, "") {
|
||||
let sync_json: String = http_get(engram_url + "/api/sync")
|
||||
if !str_eq(sync_json, "") && !str_eq(sync_json, "{}") {
|
||||
let cgi_id: String = state_get("soul_cgi_id")
|
||||
let tmp: String = "/tmp/soul-sync-" + cgi_id + ".json"
|
||||
fs_write(tmp, sync_json)
|
||||
let added: Int = engram_load_merge(tmp)
|
||||
let ts2: Int = time_now()
|
||||
ise_post("{\"event\":\"engram_sync\",\"added\":" + int_to_str(added) + ",\"ts\":" + int_to_str(ts2) + "}")
|
||||
}
|
||||
}
|
||||
state_set("soul.last_refresh_ts", int_to_str(now_ts))
|
||||
}
|
||||
|
||||
sleep_ms(tick_ms)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user