From a8027e9c001ab72260689493e865de2b75137e18 Mon Sep 17 00:00:00 2001 From: "will.anderson" Date: Thu, 11 Jun 2026 12:13:19 -0500 Subject: [PATCH] =?UTF-8?q?feat(soul):=20wire=20steward=5Fsession=5Fcheck?= =?UTF-8?q?=20into=20layered=5Fcycle=20=E2=80=94=20continuity=20+=20behavi?= =?UTF-8?q?oral=20profiling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- soul.el | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/soul.el b/soul.el index d86c3c6..5d17150 100644 --- a/soul.el +++ b/soul.el @@ -233,10 +233,11 @@ fn emit_session_start_event() -> Void { } // 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. fn layered_cycle(raw_input: String) -> String { let history: String = state_get("conversation_history") + let session_id: String = state_get("current_session_id") // L1 in: safety screen 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") } - // L2: stewardship alignment 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. - // Return the steward's content directly (a safe refusal) and skip L3. - if str_eq(steward_action, "block") { - let block_msg: String = json_get(steward_result, "content") - 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) + // L2a: continuity + behavioral profiling (also does mission alignment internally) + let continuity: String = steward_session_check(screened, session_id) + let cont_status: String = json_get(continuity, "status") + let cont_action: String = json_get(continuity, "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. - // redirect_to holds the reframed prompt; fall through to L3 with it. - // "pass": content holds the (possibly lightly reframed) input ready for L3. - // Unknown actions: treat as pass, log a warning, use content field. - let guided: String = if str_eq(steward_action, "pass") { + // L2b: mission alignment + let imprint_id: String = imprint_current() + let steward_result: String = steward_align(guided, imprint_id) + let steward_action: String = json_get(steward_result, "action") + let aligned: String = if str_eq(steward_action, "pass") { json_get(steward_result, "content") } else { - // redirect or unknown — prefer redirect_to, fall back to content - 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 } + json_get(steward_result, "redirect_to") } // 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 return safety_validate(output, screen_action)