Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4b648f3291 | |||
| 749b60c6e8 |
+25
-16
@@ -12,13 +12,20 @@ fn imprint_current() -> String {
|
|||||||
|
|
||||||
// imprint_load — activate an imprint by ID.
|
// imprint_load — activate an imprint by ID.
|
||||||
// Searches engram for a node labelled "imprint:<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 success: sets active_imprint_id state and returns {"ok":true,"id":"<id>"}.
|
||||||
// On miss: returns {"ok":false,"error":"imprint not found: <id>"}.
|
// On miss: returns {"ok":false,"error":"imprint not found: <id>"}.
|
||||||
fn imprint_load(imprint_id: String) -> String {
|
fn imprint_load(imprint_id: String) -> String {
|
||||||
let label: String = "imprint:" + imprint_id
|
let label: String = "imprint:" + imprint_id
|
||||||
let results: String = engram_search_json(label, 1)
|
let results: String = engram_search_json(label, 1)
|
||||||
let found: Bool = !str_eq(results, "") && !str_eq(results, "[]")
|
if str_eq(results, "") {
|
||||||
if found {
|
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)
|
state_set("active_imprint_id", imprint_id)
|
||||||
return "{\"ok\":true,\"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.
|
// 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 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 imprint is confirmed loaded in state: annotate the input with imprint context.
|
||||||
// If the node is missing: graceful fallback to base — never hard-fail at L3.
|
// If the state does not match: graceful fallback to base — never hard-fail at L3.
|
||||||
fn imprint_respond(input: String, imprint_id: String) -> String {
|
fn imprint_respond(input: String, imprint_id: String) -> String {
|
||||||
let is_base: Bool = str_eq(imprint_id, "base") || str_eq(imprint_id, "")
|
if str_eq(imprint_id, "base") {
|
||||||
if is_base {
|
|
||||||
return input
|
return input
|
||||||
}
|
}
|
||||||
let label: String = "imprint:" + imprint_id
|
if str_eq(imprint_id, "") {
|
||||||
let results: String = engram_search_json(label, 1)
|
return input
|
||||||
let found: Bool = !str_eq(results, "") && !str_eq(results, "[]")
|
}
|
||||||
if found {
|
// 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]"
|
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
|
return input
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,12 +57,13 @@ fn imprint_respond(input: String, imprint_id: String) -> String {
|
|||||||
// For "base" imprint: full query, no scope restriction.
|
// For "base" imprint: full query, no scope restriction.
|
||||||
// For named imprints: query is narrowed to "domain:<imprint_id>" scope.
|
// For named imprints: query is narrowed to "domain:<imprint_id>" scope.
|
||||||
fn imprint_surface_knowledge(query: String, imprint_id: String) -> String {
|
fn imprint_surface_knowledge(query: String, imprint_id: String) -> String {
|
||||||
let is_base: Bool = str_eq(imprint_id, "base") || str_eq(imprint_id, "")
|
if str_eq(imprint_id, "base") {
|
||||||
let scoped_query: String = if is_base {
|
return engram_search_json(query, 10)
|
||||||
query
|
|
||||||
} else {
|
|
||||||
query + " domain:" + imprint_id
|
|
||||||
}
|
}
|
||||||
|
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)
|
return engram_search_json(scoped_query, 10)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user