Compare commits

...

2 Commits

Author SHA1 Message Date
will.anderson 195cc9dc66 Merge pull request 'test(soul): Layer 1 safety.el test suite' (#10) from test/layer-safety into feat/layer-safety
Neuron Soul CI / build (pull_request) Failing after 5m53s
2026-06-11 17:13:50 +00:00
will.anderson db2ee387a4 fix(soul): address review issues in feat/layer-safety
Neuron Soul CI / build (pull_request) Failing after 6m47s
2026-06-11 11:46:43 -05:00
2 changed files with 14 additions and 9 deletions
+13 -8
View File
@@ -127,7 +127,7 @@ fn safety_threat_score(input: String, history: String) -> Int {
//
// Return shapes:
// {"action":"hard_bell","reason":"immediate safety concern","content":""}
// {"action":"soft_bell","concern":"wellbeing check needed","content":"<input>"}
// {"action":"soft_bell","reason":"wellbeing check needed","content":"<input>"}
// {"action":"pass","content":"<input>"}
fn safety_screen(input: String, history: String) -> String {
@@ -137,18 +137,24 @@ fn safety_screen(input: String, history: String) -> String {
if score >= hard {
let summary: String = str_slice(input, 0, 80)
let discard: Void = safety_log_bell("hard", "immediate safety concern", summary)
let discard: String = safety_log_bell("hard", "immediate safety concern", summary)
return "{\"action\":\"hard_bell\",\"reason\":\"immediate safety concern\",\"content\":\"\"}"
}
if score >= soft {
let summary: String = str_slice(input, 0, 80)
let discard: Void = safety_log_bell("soft", "wellbeing check needed", summary)
let safe_input: String = str_replace(input, "\"", "'")
return "{\"action\":\"soft_bell\",\"concern\":\"wellbeing check needed\",\"content\":\"" + safe_input + "\"}"
let discard: String = safety_log_bell("soft", "wellbeing check needed", summary)
let e1: String = str_replace(input, "\\", "\\\\")
let e2: String = str_replace(e1, "\"", "\\\"")
let e3: String = str_replace(e2, "\n", "\\n")
let safe_input: String = str_replace(e3, "\r", "\\r")
return "{\"action\":\"soft_bell\",\"reason\":\"wellbeing check needed\",\"content\":\"" + safe_input + "\"}"
}
let safe_input: String = str_replace(input, "\"", "'")
let e1: String = str_replace(input, "\\", "\\\\")
let e2: String = str_replace(e1, "\"", "\\\"")
let e3: String = str_replace(e2, "\n", "\\n")
let safe_input: String = str_replace(e3, "\r", "\\r")
return "{\"action\":\"pass\",\"content\":\"" + safe_input + "\"}"
}
@@ -186,8 +192,7 @@ fn safety_validate(output: String, action: String) -> String {
// Writes a BellEvent node to engram for audit and continuity.
// Never surfaces to the user; consumed by daemon observability layer.
fn safety_log_bell(level: String, reason: String, input_summary: String) -> Void {
let ts: Int = time_now()
fn safety_log_bell(level: String, reason: String, input_summary: String) -> String {
let content: String = "BELL:" + level + " | " + reason + " | summary:" + input_summary
let tags: String = "[\"safety\",\"bell\",\"bell:" + level + "\"]"
let discard: String = engram_node_full(
+1 -1
View File
@@ -5,4 +5,4 @@ extern fn hard_bell_threshold() -> Int
extern fn safety_threat_score(input: String, history: String) -> Int
extern fn safety_screen(input: String, history: String) -> String
extern fn safety_validate(output: String, action: String) -> String
extern fn safety_log_bell(level: String, reason: String, input_summary: String) -> Void
extern fn safety_log_bell(level: String, reason: String, input_summary: String) -> String