soul loop-1: identity loading, boot counter, internal state events, richer awareness
- memory.el: mem_boot_count_get/inc (persisted counter), mem_emit_state_event (InternalStateEvent schema) - soul.el: load_identity_context() loads intel-dna/values/mem-philosophy nodes into state at boot; boot counter incremented on every startup - awareness.el: attend() gains search/activate/strengthen/forget action types; one_cycle() emits InternalStateEvent for non-trivial decisions - chat.el: build_system_prompt includes [IDENTITY GRAPH] block from graph-loaded context; handle_chat strengthens activated nodes after each turn
This commit is contained in:
@@ -88,6 +88,47 @@ fn init_soul_edges() -> Void {
|
||||
engram_connect(val_hope, val_trust, el_from_float(0.7), "co-value")
|
||||
}
|
||||
|
||||
// load_identity_context — pull key identity nodes from engram into working state.
|
||||
// Called at boot after engram_load. These nodes contain values, intellectual-dna,
|
||||
// memory-philosophy — the graph-stored self that chat.el can include in prompts.
|
||||
// Stores a condensed version in state_key "soul_identity_context".
|
||||
fn load_identity_context() -> Void {
|
||||
// Known identity node IDs — set during init_soul_edges or imported from snapshot
|
||||
let node_intel: String = engram_get_node_json("kn-5adecd7e-d6db-4576-87fe-6ef8a935cea6")
|
||||
let node_values: String = engram_get_node_json("kn-5b606390-a52d-4ca2-8e0e-eba141d13440")
|
||||
let node_mem_phil: String = engram_get_node_json("kn-dcfe04b3-3702-4cac-b6f0-ecb4db837eee")
|
||||
|
||||
let intel_ok: Bool = !str_eq(node_intel, "") && !str_eq(node_intel, "null")
|
||||
let values_ok: Bool = !str_eq(node_values, "") && !str_eq(node_values, "null")
|
||||
let mem_ok: Bool = !str_eq(node_mem_phil, "") && !str_eq(node_mem_phil, "null")
|
||||
|
||||
let intel_content: String = if intel_ok { json_get(node_intel, "content") } else { "" }
|
||||
let values_content: String = if values_ok { json_get(node_values, "content") } else { "" }
|
||||
let mem_content: String = if mem_ok { json_get(node_mem_phil, "content") } else { "" }
|
||||
|
||||
// Condense each: take first 600 chars
|
||||
let intel_short: String = if str_len(intel_content) > 600 { str_slice(intel_content, 0, 600) } else { intel_content }
|
||||
let values_short: String = if str_len(values_content) > 600 { str_slice(values_content, 0, 600) } else { values_content }
|
||||
let mem_short: String = if str_len(mem_content) > 600 { str_slice(mem_content, 0, 600) } else { mem_content }
|
||||
|
||||
let parts_count: Int = 0
|
||||
let parts_count = if intel_ok { parts_count + 1 } else { parts_count }
|
||||
let parts_count = if values_ok { parts_count + 1 } else { parts_count }
|
||||
let parts_count = if mem_ok { parts_count + 1 } else { parts_count }
|
||||
|
||||
if parts_count == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
let ctx: String = ""
|
||||
let ctx = if intel_ok { ctx + "[INTELLECTUAL-DNA]\n" + intel_short + "\n\n" } else { ctx }
|
||||
let ctx = if values_ok { ctx + "[VALUES]\n" + values_short + "\n\n" } else { ctx }
|
||||
let ctx = if mem_ok { ctx + "[MEMORY-PHILOSOPHY]\n" + mem_short } else { ctx }
|
||||
|
||||
state_set("soul_identity_context", ctx)
|
||||
println("[soul] identity context loaded (" + int_to_str(str_len(ctx)) + " chars, " + int_to_str(parts_count) + " nodes)")
|
||||
}
|
||||
|
||||
let soul_cgi_id_raw: String = env("SOUL_CGI_ID")
|
||||
let soul_cgi_id: String = if str_eq(soul_cgi_id_raw, "") { "ntn-genesis" } else { soul_cgi_id_raw }
|
||||
let port_raw: String = env("NEURON_PORT")
|
||||
@@ -130,6 +171,11 @@ if using_http_engram {
|
||||
println("[soul] loaded - nodes=" + int_to_str(engram_node_count()) + " edges=" + int_to_str(engram_edge_count()))
|
||||
}
|
||||
|
||||
load_identity_context()
|
||||
let boot_num: Int = mem_boot_count_inc()
|
||||
state_set("soul_boot_count", int_to_str(boot_num))
|
||||
println("[soul] boot #" + int_to_str(boot_num))
|
||||
|
||||
let identity_raw: String = env("SOUL_IDENTITY")
|
||||
let soul_identity: String = if str_eq(identity_raw, "") { "You are " + soul_cgi_id + ", a CGI." } else { identity_raw }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user