fix(soul): address review issues in feat/layer-imprint
Neuron Soul CI / build (pull_request) Failing after 5m44s

This commit is contained in:
2026-06-11 11:46:31 -05:00
parent 6fec93ff7f
commit 749b60c6e8
+25 -16
View File
@@ -12,13 +12,20 @@ fn imprint_current() -> String {
// imprint_load activate an imprint by ID.
// Searches engram for a node labelled "imprint:<id>".
// Verifies the returned node's label matches before accepting the match.
// On success: sets active_imprint_id state and returns {"ok":true,"id":"<id>"}.
// On miss: returns {"ok":false,"error":"imprint not found: <id>"}.
fn imprint_load(imprint_id: String) -> String {
let label: String = "imprint:" + imprint_id
let results: String = engram_search_json(label, 1)
let found: Bool = !str_eq(results, "") && !str_eq(results, "[]")
if found {
if str_eq(results, "") {
return "{\"ok\":false,\"error\":\"imprint not found: " + imprint_id + "\"}"
}
if str_eq(results, "[]") {
return "{\"ok\":false,\"error\":\"imprint not found: " + imprint_id + "\"}"
}
let found_label: String = json_get(results, "label")
if str_eq(found_label, label) {
state_set("active_imprint_id", imprint_id)
return "{\"ok\":true,\"id\":\"" + imprint_id + "\"}"
}
@@ -27,20 +34,21 @@ fn imprint_load(imprint_id: String) -> String {
// imprint_respond route steward-aligned input through the active imprint's voice/domain context.
// If imprint_id is "base" or empty: pass input through unchanged (base Neuron, no suit).
// If the imprint node is found: annotate the input with imprint context.
// If the node is missing: graceful fallback to base never hard-fail at L3.
// If the imprint is confirmed loaded in state: annotate the input with imprint context.
// If the state does not match: graceful fallback to base never hard-fail at L3.
fn imprint_respond(input: String, imprint_id: String) -> String {
let is_base: Bool = str_eq(imprint_id, "base") || str_eq(imprint_id, "")
if is_base {
if str_eq(imprint_id, "base") {
return input
}
let label: String = "imprint:" + imprint_id
let results: String = engram_search_json(label, 1)
let found: Bool = !str_eq(results, "") && !str_eq(results, "[]")
if found {
if str_eq(imprint_id, "") {
return input
}
// Cross-check imprint_id against loaded state rather than re-querying engram
let current: String = imprint_current()
if str_eq(current, imprint_id) {
return input + " [imprint:" + imprint_id + " active]"
}
// Graceful fallback: imprint node missing, return input unchanged
// Graceful fallback: imprint not loaded in state, return input unchanged
return input
}
@@ -49,12 +57,13 @@ fn imprint_respond(input: String, imprint_id: String) -> String {
// For "base" imprint: full query, no scope restriction.
// For named imprints: query is narrowed to "domain:<imprint_id>" scope.
fn imprint_surface_knowledge(query: String, imprint_id: String) -> String {
let is_base: Bool = str_eq(imprint_id, "base") || str_eq(imprint_id, "")
let scoped_query: String = if is_base {
query
} else {
query + " domain:" + imprint_id
if str_eq(imprint_id, "base") {
return engram_search_json(query, 10)
}
if str_eq(imprint_id, "") {
return engram_search_json(query, 10)
}
let scoped_query: String = query + " domain:" + imprint_id
return engram_search_json(scoped_query, 10)
}