Merge pull request 'fix(routes): /api/graph/edges must not write the canonical snapshot' (#161) from fix/graph-edges-no-canonical-clobber into main
Neuron Soul CI / build (push) Failing after 14m2s
Neuron Soul CI / deploy (push) Has been skipped

This commit was merged in pull request #161.
This commit is contained in:
2026-08-16 01:44:57 +00:00
+17 -8
View File
@@ -420,14 +420,23 @@ fn r_api_graph_nodes(method: String, path: String, body: String) -> String {
@route("/api/graph/edges", "GET", "exact") @manager @route("/api/graph/edges", "GET", "exact") @manager
fn r_api_graph_edges(method: String, path: String, body: String) -> String { fn r_api_graph_edges(method: String, path: String, body: String) -> String {
// TODO(reliability #8): engram_save races with awareness loop mem_save(). // Reads edges straight from the store. No file is written or read.
// Both now use atomic write-to-temp+rename (el_runtime.c). Serialised //
// by engram_global_mu. Future: add engram_edges_json() builtin. // This route used to engram_save() the ENTIRE graph over
let snap_path: String = env("HOME") + "/.neuron/engram/snapshot.json" // ~/.neuron/engram/snapshot.json the engram server's CANONICAL store
engram_save(snap_path) // and then fs_read it back, just to answer a read query. Two defects in
let snap: String = fs_read(snap_path) // one line: a READ route clobbering the persistence owner's canonical
let edges_raw: String = json_get_raw(snap, "edges") // file (the defect fixed once already, then reintroduced when the
return if str_eq(edges_raw, "") { "[]" } else { edges_raw } // hand-written dispatch block was replaced by @route dispatch and the
// unfixed copy is the one that survived), and a 128 MB serialize +
// reread + parse per request. Calling it on 2026-08-15 overwrote the
// canonical snapshot and preceded an engram crash loop.
//
// engram_edges_json is the builtin the old TODO here asked for. Bounded
// by default (1000) the unbounded whole-graph read is what fell over.
let lim: Int = api_query_int(path, "limit", 1000)
let off: Int = api_query_int(path, "offset", 0)
return engram_edges_json(lim, off)
} }
// GET /api/chat legacy probe interface; body may be empty ─────────────── // GET /api/chat legacy probe interface; body may be empty ───────────────