diff --git a/dist/memory.c b/dist/memory.c index fd77cef..a464f29 100644 --- a/dist/memory.c +++ b/dist/memory.c @@ -120,8 +120,8 @@ el_val_t mem_consolidate(void) { } el_val_t mem_save(el_val_t path) { - el_val_t save_result = engram_save(path); - if (str_eq(save_result, EL_STR(""))) { + el_val_t saved = engram_save(path); + if (saved == 0) { println(el_str_concat(el_str_concat(EL_STR("[memory] mem_save: engram_save failed for "), path), EL_STR(" \xe2\x80\x94 snapshot may be incomplete"))); } return 0; diff --git a/dist/neuron-api.c b/dist/neuron-api.c index 1a97d4a..c03371e 100644 --- a/dist/neuron-api.c +++ b/dist/neuron-api.c @@ -744,8 +744,8 @@ el_val_t handle_api_consolidate(el_val_t body) { el_val_t summary = json_get(body, EL_STR("summary")); el_val_t snap = state_get(EL_STR("soul_snapshot_path")); if (!str_eq(snap, EL_STR(""))) { - el_val_t save_result = engram_save(snap); - if (str_eq(save_result, EL_STR(""))) { + el_val_t saved = engram_save(snap); + if (saved == 0) { println(el_str_concat(el_str_concat(EL_STR("[api] consolidate: engram_save failed for "), snap), EL_STR(" \xe2\x80\x94 snapshot may be out of sync"))); } } diff --git a/dist/soul.c b/dist/soul.c index c7fb6eb..0265c00 100644 --- a/dist/soul.c +++ b/dist/soul.c @@ -25383,8 +25383,8 @@ el_val_t mem_consolidate(void) { } el_val_t mem_save(el_val_t path) { - el_val_t save_result = engram_save(path); - if (str_eq(save_result, EL_STR(""))) { + el_val_t saved = engram_save(path); + if (saved == 0) { println(el_str_concat(el_str_concat(EL_STR("[memory] mem_save: engram_save failed for "), path), EL_STR(" \xe2\x80\x94 snapshot may be incomplete"))); } return 0; @@ -29336,8 +29336,8 @@ el_val_t handle_api_consolidate(el_val_t body) { el_val_t summary = json_get(body, EL_STR("summary")); el_val_t snap = state_get(EL_STR("soul_snapshot_path")); if (!str_eq(snap, EL_STR(""))) { - el_val_t save_result = engram_save(snap); - if (str_eq(save_result, EL_STR(""))) { + el_val_t saved = engram_save(snap); + if (saved == 0) { println(el_str_concat(el_str_concat(EL_STR("[api] consolidate: engram_save failed for "), snap), EL_STR(" \xe2\x80\x94 snapshot may be out of sync"))); } } diff --git a/memory.el b/memory.el index 46d9f28..542ee6c 100644 --- a/memory.el +++ b/memory.el @@ -133,8 +133,12 @@ fn mem_consolidate() -> String { } fn mem_save(path: String) -> Void { - let save_result: String = engram_save(path) - if str_eq(save_result, "") { + // engram_save returns an Int (1 = ok, 0 = failure), NOT a String. Calling + // str_eq on it casts EL_CSTR(1) -> (char*)0x1 and SIGSEGVs on a SUCCESSFUL + // save — which is exactly what a fresh-install genesis boot does first + // (seeds the brain, saves, crashes). This is issue #150. Check the Int. + let saved: Int = engram_save(path) + if saved == 0 { println("[memory] mem_save: engram_save failed for " + path + " — snapshot may be incomplete") } } diff --git a/neuron-api.el b/neuron-api.el index 12ce4c5..e1196f1 100644 --- a/neuron-api.el +++ b/neuron-api.el @@ -725,8 +725,10 @@ fn handle_api_consolidate(body: String) -> String { let summary: String = json_get(body, "summary") let snap: String = state_get("soul_snapshot_path") if !str_eq(snap, "") { - let save_result: String = engram_save(snap) - if str_eq(save_result, "") { + // engram_save returns an Int (1 = ok, 0 = failure); str_eq on it derefs + // EL_CSTR(1)=0x1 and SIGSEGVs on success (issue #150). Check the Int. + let saved: Int = engram_save(snap) + if saved == 0 { println("[api] consolidate: engram_save failed for " + snap + " — snapshot may be out of sync") } }