soul: engram-store wiring (soul client path) + elc-fold source fixes

- soul.el/memory.el: ENGRAM_STORE-gated store boot/checkpoint (client path) + fix a
  latent memory.el segfault (engram_save returns Int, was str_eq'd as a pointer).
- sessions.el/safety.el/chat.el: fix malformed El constructs that hung the elc fold
  (unterminated string literals, block-expression, undefined distill_transcript).
This commit is contained in:
2026-08-12 14:13:35 -05:00
parent fd6df322f6
commit c8d5f57de7
5 changed files with 51 additions and 8 deletions
+18 -1
View File
@@ -500,11 +500,28 @@ println("[soul] boot - cgi=" + soul_cgi_id + " port=" + int_to_str(port))
let using_http_engram: Bool = !str_eq(engram_url_raw, "")
// ENGRAM_STORE (tiered paged store): when the flag is on, the durable neuron.egm
// store not the JSON snapshot is the source of truth. engram_store_boot does
// import-once + WAL-replay + resident load; every structural mutation is mirrored
// into the store's WAL, and mem_save() checkpoints the resident graph (incl.
// learned hebb) so associations survive a restart. Flag OFF is unchanged.
let engram_store_flag: String = env("ENGRAM_STORE")
let engram_store_on: Bool = str_eq(engram_store_flag, "1") || str_eq(engram_store_flag, "on") || str_eq(engram_store_flag, "true")
let engram_data_dir_raw: String = env("ENGRAM_DATA_DIR")
let engram_data_dir: String = if str_eq(engram_data_dir_raw, "") { env("HOME") + "/.neuron/engram" } else { engram_data_dir_raw }
// Always try local snapshot first. If it has content (>50 nodes) it was
// previously seeded from HTTP Engram and is kept up-to-date by the awareness
// loop use it. This preserves sessions and memories across restarts.
// HTTP Engram is only used for the very first boot (empty/absent snapshot).
engram_load(snapshot)
if engram_store_on {
let booted: Int = engram_store_boot(engram_data_dir)
println("[soul] ENGRAM_STORE on — booted paged store from " + engram_data_dir
+ " (rc=" + int_to_str(booted) + ") nodes=" + int_to_str(engram_node_count())
+ " edges=" + int_to_str(engram_edge_count()))
} else {
engram_load(snapshot)
}
let local_node_count: Int = engram_node_count()
let snapshot_usable: Bool = local_node_count > 50