reconcile: merge Will's self-review WIP (456267a) into main
Union of all ship-critical soul fixes for the Mac beta: - Keeps main's honest receipts (#100/#101), immutability arc + #199 by-id gate (#83), Track B threat routing (#76), bounded beginSession (#103), CI hardening (#85/#86), elc typo hotfix (#77), neuron-dev-setup (#84). - Brings WIP's genesis-boot SIGSEGV fix (#150/#95), safety-contact 988 truncation fix (#96), bounded-persona floor (#93), and 10 self-review commits (importance flattening, curiosity DF gating, WM/heartbeat observability, boot-counter telemetry). - Folds the multi-word ranked-search fix: api_query_param now url_decode()s the extracted value so q=foo%20bar / foo+bar tokenize as two words. Conflicts (neuron-api.el payload-bound comments, mcp-wrapper tool_forget) resolved toward the correct end state: main's verified honest-receipt read-back is kept; WIP's improved forget description is kept. Generated dist/*.c taken from main and will be regenerated from this reconciled source in the following commit.
This commit is contained in:
+27
-11
@@ -59,8 +59,14 @@ fn api_query_param(path: String, key: String) -> String {
|
||||
if pos < 0 { return "" }
|
||||
let after: String = str_slice(qs, pos + str_len(needle), str_len(qs))
|
||||
let amp: Int = str_index_of(after, "&")
|
||||
if amp < 0 { return after }
|
||||
return str_slice(after, 0, amp)
|
||||
let raw: String = if amp < 0 { after } else { str_slice(after, 0, amp) }
|
||||
// URL-decode the extracted value BEFORE any downstream tokenizing. Clients
|
||||
// percent-encode spaces (%20) and form-encode them as '+', so a multi-word
|
||||
// query like "foo bar" arrives as "foo%20bar" / "foo+bar". Left undecoded,
|
||||
// the ranked lexical search sees a single un-splittable token and matches
|
||||
// nothing (single-word queries still hit). url_decode maps '+' -> space
|
||||
// and %XX -> byte, restoring the word boundaries for recall + knowledge search.
|
||||
return url_decode(raw)
|
||||
}
|
||||
|
||||
fn api_query_int(path: String, key: String, default_val: Int) -> Int {
|
||||
@@ -337,7 +343,7 @@ fn handle_api_remember(body: String) -> String {
|
||||
"[" + inner + ",\"project:" + project + "\"]"
|
||||
}
|
||||
let id: String = engram_node_full(content, "Memory", "memory:remembered",
|
||||
el_from_float(sal), el_from_float(sal), el_from_float(0.9),
|
||||
sal, sal, el_from_float(0.9),
|
||||
"Episodic", final_tags)
|
||||
if !api_persisted(id) { return api_not_persisted(id) }
|
||||
return "{\"id\":\"" + id + "\",\"ok\":true}"
|
||||
@@ -364,7 +370,7 @@ fn handle_api_node_create(body: String) -> String {
|
||||
}
|
||||
}
|
||||
let id: String = engram_node_full(content, node_type, label,
|
||||
el_from_float(sal), el_from_float(sal), el_from_float(0.9),
|
||||
sal, sal, el_from_float(0.9),
|
||||
tier, tags)
|
||||
if !api_persisted(id) { return api_not_persisted(id) }
|
||||
return "{\"id\":\"" + id + "\",\"ok\":true}"
|
||||
@@ -480,13 +486,19 @@ fn handle_api_browse_knowledge(path: String, body: String) -> String {
|
||||
}
|
||||
|
||||
// handle_api_capture_knowledge — create a Knowledge node.
|
||||
// LABEL FIX (2026-07-23 self-review): the sentinel label "knowledge:captured"
|
||||
// made every capture anonymous in WM telemetry (35 identical wm_top entries)
|
||||
// and starved the curiosity auto-term seeder, which needs meaningful labels.
|
||||
// Use the title as the label; empty label lets engram_node_full derive
|
||||
// content[:60], which for captures starts with the title anyway.
|
||||
fn handle_api_capture_knowledge(body: String) -> String {
|
||||
let content: String = json_get(body, "content")
|
||||
let title: String = json_get(body, "title")
|
||||
if str_eq(content, "") { return api_err("content is required") }
|
||||
let full: String = if str_eq(title, "") { content } else { title + ": " + content }
|
||||
let lbl: String = str_slice(title, 0, 80)
|
||||
let tags: String = "[\"Knowledge\",\"captured\"]"
|
||||
let id: String = engram_node_full(full, "Knowledge", "knowledge:captured",
|
||||
let id: String = engram_node_full(full, "Knowledge", lbl,
|
||||
el_from_float(0.85), el_from_float(0.8), el_from_float(0.9),
|
||||
"Episodic", tags)
|
||||
if !api_persisted(id) { return api_not_persisted(id) }
|
||||
@@ -500,7 +512,8 @@ fn handle_api_evolve_knowledge(body: String) -> String {
|
||||
if str_eq(content, "") { return api_err("content is required") }
|
||||
if !str_eq(prior_id, "") && is_protected_node(prior_id) { return api_err_protected(prior_id) }
|
||||
let tags: String = "[\"Knowledge\",\"evolved\"]"
|
||||
let new_id: String = engram_node_full(content, "Knowledge", "knowledge:evolved",
|
||||
// Empty label → engram_node_full derives content[:60] (LABEL FIX 2026-07-23).
|
||||
let new_id: String = engram_node_full(content, "Knowledge", "",
|
||||
el_from_float(0.75), el_from_float(0.75), el_from_float(0.9),
|
||||
"Episodic", tags)
|
||||
if !api_persisted(new_id) { return api_not_persisted(new_id) }
|
||||
@@ -521,7 +534,8 @@ fn handle_api_promote_knowledge(body: String) -> String {
|
||||
let tags: String = if str_eq(tags_raw, "") {
|
||||
"[\"Knowledge\",\"tier:canonical\",\"disposition:stable\"]"
|
||||
} else { tags_raw }
|
||||
let new_id: String = engram_node_full(content, "Knowledge", "knowledge:canonical",
|
||||
// Empty label → engram_node_full derives content[:60] (LABEL FIX 2026-07-23).
|
||||
let new_id: String = engram_node_full(content, "Knowledge", "",
|
||||
el_from_float(0.9), el_from_float(0.9), el_from_float(1.0),
|
||||
"Canonical", tags)
|
||||
if !api_persisted(new_id) { return api_not_persisted(new_id) }
|
||||
@@ -714,7 +728,7 @@ fn handle_api_evolve_memory(body: String) -> String {
|
||||
}
|
||||
let tags: String = "[\"Memory\",\"evolved\"]"
|
||||
let new_id: String = engram_node_full(content, "Memory", "memory:evolved",
|
||||
el_from_float(sal), el_from_float(sal), el_from_float(0.9),
|
||||
sal, sal, el_from_float(0.9),
|
||||
"Episodic", tags)
|
||||
if !str_eq(prior_id, "") && !str_eq(new_id, "") {
|
||||
engram_connect(new_id, prior_id, el_from_float(0.9), "supersedes")
|
||||
@@ -796,7 +810,7 @@ fn handle_api_cultivate(body: String) -> String {
|
||||
}
|
||||
let tags: String = "[\"Memory\",\"evolved\",\"cultivated\"]"
|
||||
let new_id: String = engram_node_full(content, "Memory", "memory:cultivated",
|
||||
el_from_float(sal), el_from_float(sal), el_from_float(0.9),
|
||||
sal, sal, el_from_float(0.9),
|
||||
"Episodic", tags)
|
||||
if !str_eq(prior_id, "") && !str_eq(new_id, "") {
|
||||
engram_connect(new_id, prior_id, el_from_float(0.9), "supersedes")
|
||||
@@ -844,8 +858,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")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user