// safety.el — L1 Safety layer (stub — full implementation in feat/layer-safety) // Provides safety screening and validation for the consciousness stack. // This stub allows soul.el to compile while feat/layer-safety is pending merge. // // Contract for safety_screen(input, history) -> String (JSON): // {"action": "pass" | "hard_bell", "content": "", "reason": ""} // // Contract for safety_validate(output, screen_action) -> String: // Second param is the original screen_action ("pass") or the sentinel "hard_bell". // Returns the validated output string, or a safe refusal if validation fails. // // Contract for safety_log_bell(severity, reason, excerpt) -> Void: // Logs a bell event to engram. severity = "hard" | "soft". Hard bell events are // intentionally NOT added to conversation_history (security isolation by design). fn safety_screen(input: String, history: String) -> String { return "{\"action\":\"pass\",\"content\":\"" + json_safe(input) + "\"}" } fn safety_validate(output: String, screen_action: String) -> String { return output } fn safety_log_bell(severity: String, reason: String, excerpt: String) -> Void { let tags: String = "[\"safety\",\"bell\",\"" + severity + "-bell\"]" let payload: String = "{\"severity\":\"" + severity + "\",\"reason\":\"" + json_safe(reason) + "\",\"excerpt\":\"" + json_safe(excerpt) + "\"}" let discard: String = engram_node_full( payload, "InternalStateEvent", "safety:bell", el_from_float(0.95), el_from_float(0.95), el_from_float(1.0), "Episodic", tags ) println("[safety] bell logged severity=" + severity + " reason=" + reason) }