feat(soul): wire steward_session_check into layered_cycle — continuity + behavioral profiling
Neuron Soul CI / build (pull_request) Failing after 6m2s
Neuron Soul CI / build (pull_request) Failing after 6m2s
This commit is contained in:
@@ -233,10 +233,11 @@ fn emit_session_start_event() -> Void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// layered_cycle — routes user-facing requests through the 4-layer consciousness stack.
|
// layered_cycle — routes user-facing requests through the 4-layer consciousness stack.
|
||||||
// L0 (core) → L1 (safety screen) → L2 (stewardship) → L3 (imprint) → L1 (safety validate)
|
// L0 (core) → L1 (safety screen) → L2a (continuity + behavioral profiling) → L2b (mission alignment) → L3 (imprint) → L1 (safety validate)
|
||||||
// Internal cognition (heartbeat, proactive, memory ops) bypasses layers — use one_cycle directly.
|
// Internal cognition (heartbeat, proactive, memory ops) bypasses layers — use one_cycle directly.
|
||||||
fn layered_cycle(raw_input: String) -> String {
|
fn layered_cycle(raw_input: String) -> String {
|
||||||
let history: String = state_get("conversation_history")
|
let history: String = state_get("conversation_history")
|
||||||
|
let session_id: String = state_get("current_session_id")
|
||||||
|
|
||||||
// L1 in: safety screen
|
// L1 in: safety screen
|
||||||
let screen_result: String = safety_screen(raw_input, history)
|
let screen_result: String = safety_screen(raw_input, history)
|
||||||
@@ -258,39 +259,39 @@ fn layered_cycle(raw_input: String) -> String {
|
|||||||
return safety_validate("", "hard_bell")
|
return safety_validate("", "hard_bell")
|
||||||
}
|
}
|
||||||
|
|
||||||
// L2: stewardship alignment
|
|
||||||
let screened: String = json_get(screen_result, "content")
|
let screened: String = json_get(screen_result, "content")
|
||||||
let imprint_id: String = imprint_current()
|
|
||||||
let steward_result: String = steward_align(screened, imprint_id)
|
|
||||||
let steward_action: String = json_get(steward_result, "action")
|
|
||||||
|
|
||||||
// "block": stewardship has determined this input should not proceed.
|
// L2a: continuity + behavioral profiling (also does mission alignment internally)
|
||||||
// Return the steward's content directly (a safe refusal) and skip L3.
|
let continuity: String = steward_session_check(screened, session_id)
|
||||||
if str_eq(steward_action, "block") {
|
let cont_status: String = json_get(continuity, "status")
|
||||||
let block_msg: String = json_get(steward_result, "content")
|
let cont_action: String = json_get(continuity, "action")
|
||||||
let eff_block: String = if str_eq(block_msg, "") { "I'm not able to help with that." } else { block_msg }
|
|
||||||
return safety_validate(eff_block, screen_action)
|
// Store continuity status so imprint can adjust its response register
|
||||||
|
state_set("session_continuity", cont_status)
|
||||||
|
|
||||||
|
// Identity anomaly: add a gentle verification cue to the input before imprint
|
||||||
|
let guided: String = if str_eq(cont_action, "identity_check") {
|
||||||
|
screened + " [steward:identity_check]"
|
||||||
|
} else {
|
||||||
|
if str_eq(cont_action, "soft_check") {
|
||||||
|
screened + " [steward:continuity_concern]"
|
||||||
|
} else {
|
||||||
|
screened
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// "redirect": stewardship steers toward aligned territory.
|
// L2b: mission alignment
|
||||||
// redirect_to holds the reframed prompt; fall through to L3 with it.
|
let imprint_id: String = imprint_current()
|
||||||
// "pass": content holds the (possibly lightly reframed) input ready for L3.
|
let steward_result: String = steward_align(guided, imprint_id)
|
||||||
// Unknown actions: treat as pass, log a warning, use content field.
|
let steward_action: String = json_get(steward_result, "action")
|
||||||
let guided: String = if str_eq(steward_action, "pass") {
|
let aligned: String = if str_eq(steward_action, "pass") {
|
||||||
json_get(steward_result, "content")
|
json_get(steward_result, "content")
|
||||||
} else {
|
} else {
|
||||||
// redirect or unknown — prefer redirect_to, fall back to content
|
json_get(steward_result, "redirect_to")
|
||||||
let redir: String = json_get(steward_result, "redirect_to")
|
|
||||||
let alt: String = json_get(steward_result, "content")
|
|
||||||
let chosen: String = if str_eq(redir, "") { alt } else { redir }
|
|
||||||
if str_eq(chosen, "") {
|
|
||||||
println("[soul] warn: steward action '" + steward_action + "' returned no usable content — using original screened input")
|
|
||||||
}
|
|
||||||
if str_eq(chosen, "") { screened } else { chosen }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// L3: imprint responds
|
// L3: imprint responds
|
||||||
let output: String = imprint_respond(guided, imprint_id)
|
let output: String = imprint_respond(aligned, imprint_id)
|
||||||
|
|
||||||
// L1 out: validate output before delivery
|
// L1 out: validate output before delivery
|
||||||
return safety_validate(output, screen_action)
|
return safety_validate(output, screen_action)
|
||||||
|
|||||||
Reference in New Issue
Block a user