soul loop-2: session events, conversation persistence, richer health + inbox
- soul.el: emit_session_start_event() logs structured InternalStateEvent on every boot; pre-serve snapshot saves boot-time graph mutations before any requests arrive - routes.el: /health now returns boot count, node/edge counts, pulse; /api/sessions endpoint surfaces session-start history - awareness.el: perceive() tries soul-inbox-pending then soul-inbox fallback, catches both tagging conventions - chat.el: conv_history_persist/load provide cross-restart conversation continuity via engram
This commit is contained in:
@@ -22,7 +22,18 @@ fn err_405(method: String, path: String) -> String {
|
||||
|
||||
fn route_health() -> String {
|
||||
let cgi_id: String = state_get("soul_cgi_id")
|
||||
return "{\"status\":\"alive\",\"cgi_id\":\"" + cgi_id + "\"}"
|
||||
let boot: String = state_get("soul_boot_count")
|
||||
let boot_num: String = if str_eq(boot, "") { "0" } else { boot }
|
||||
let node_ct: Int = engram_node_count()
|
||||
let edge_ct: Int = engram_edge_count()
|
||||
let pulse: String = state_get("soul.pulse")
|
||||
let pulse_num: String = if str_eq(pulse, "") { "0" } else { pulse }
|
||||
return "{\"status\":\"alive\""
|
||||
+ ",\"cgi_id\":\"" + cgi_id + "\""
|
||||
+ ",\"boot\":" + boot_num
|
||||
+ ",\"node_count\":" + int_to_str(node_ct)
|
||||
+ ",\"edge_count\":" + int_to_str(edge_ct)
|
||||
+ ",\"pulse\":" + pulse_num + "}"
|
||||
}
|
||||
|
||||
fn route_lineage() -> String {
|
||||
@@ -184,6 +195,13 @@ fn handle_dharma_recv(body: String) -> String {
|
||||
return "{\"error\":\"unknown event_type\",\"event_type\":\"" + eff_event + "\"}"
|
||||
}
|
||||
|
||||
fn route_sessions() -> String {
|
||||
let results: String = engram_search_json("session-start", 20)
|
||||
if str_eq(results, "") { return "[]" }
|
||||
if str_eq(results, "[]") { return "[]" }
|
||||
return results
|
||||
}
|
||||
|
||||
fn handle_request(method: String, path: String, body: String) -> String {
|
||||
let clean: String = strip_query(path)
|
||||
|
||||
@@ -195,6 +213,9 @@ fn handle_request(method: String, path: String, body: String) -> String {
|
||||
if str_eq(clean, "/health") {
|
||||
return route_health()
|
||||
}
|
||||
if str_eq(clean, "/api/sessions") {
|
||||
return route_sessions()
|
||||
}
|
||||
if str_eq(clean, "/lineage") {
|
||||
return route_lineage()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user