From b0fb2bf0853615d932fe25bd9f8545476dc0b707 Mon Sep 17 00:00:00 2001 From: Will Anderson Date: Tue, 14 Jul 2026 14:21:45 -0500 Subject: [PATCH] safety/sessions: fix malformed string literals that crash elc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three unescaped-quote typos produced malformed El string literals that broke compilation: - safety.el:282 stray extra double-quote at the tail of safety_soft_phrases (\"having a breakdown\""]") closed the string early, desyncing the lexer's string/code phase for the rest of the file and shattering later apostrophe text (can't, i'm) into bare identifiers -> invalid C. - sessions.el:517 str_replace(topic_snip, """, ...) — the bare """ is an empty string plus an unterminated string that swallowed the closing ) and }; with the current elc this triggers the parser overrun -> ~700GB OOM. - sessions.el:520 unescaped nested quotes in the topic_tags literal. All three now use escaped inner quotes. Verified: both files compile clean under the current elc (safety.c and sessions.c well-formed, brace-balanced). --- safety.el | 2 +- sessions.el | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/safety.el b/safety.el index 446c5c6..0590916 100644 --- a/safety.el +++ b/safety.el @@ -279,7 +279,7 @@ fn safety_threat_to_others_phrases() -> String { } fn safety_soft_phrases() -> String { - return "[\"stressed\",\"overwhelmed\",\"can't cope\",\"cannot cope\",\"struggling\",\"anxious\",\"anxiety\",\"depressed\",\"depression\",\"lonely\",\"isolated\",\"hopeless\",\"hopelessness\",\"exhausted\",\"burnt out\",\"burned out\",\"burnout\",\"panic\",\"panicking\",\"falling apart\",\"breaking down\",\"can't handle\",\"cannot handle\",\"losing it\",\"nothing matters\",\"don't care anymore\",\"given up\",\"giving up\",\"helpless\",\"worthless\",\"useless\",\"hate myself\",\"no one cares\",\"nobody cares\",\"no one understands\",\"nobody understands\",\"empty inside\",\"can't stop crying\",\"breaking point\",\"at my limit\",\"having a breakdown\""]" + return "[\"stressed\",\"overwhelmed\",\"can't cope\",\"cannot cope\",\"struggling\",\"anxious\",\"anxiety\",\"depressed\",\"depression\",\"lonely\",\"isolated\",\"hopeless\",\"hopelessness\",\"exhausted\",\"burnt out\",\"burned out\",\"burnout\",\"panic\",\"panicking\",\"falling apart\",\"breaking down\",\"can't handle\",\"cannot handle\",\"losing it\",\"nothing matters\",\"don't care anymore\",\"given up\",\"giving up\",\"helpless\",\"worthless\",\"useless\",\"hate myself\",\"no one cares\",\"nobody cares\",\"no one understands\",\"nobody understands\",\"empty inside\",\"can't stop crying\",\"breaking point\",\"at my limit\",\"having a breakdown\"]" } // ISSUE 5 TODO: phrase lists are rebuilt from JSON literals on every call. diff --git a/sessions.el b/sessions.el index 2f77980..c5c57e9 100644 --- a/sessions.el +++ b/sessions.el @@ -514,10 +514,10 @@ fn session_hist_save(session_id: String, hist: String) -> Void { let last_role: String = json_get(last_entry, "role") let last_content: String = json_get(last_entry, "content") let topic_snip: String = if str_len(last_content) > 200 { str_slice(last_content, 0, 200) } else { last_content } - let safe_topic: String = str_replace(topic_snip, """, "'") + let safe_topic: String = str_replace(topic_snip, "\"", "'") let ts_now: String = int_to_str(time_now()) let topic_content: String = "last-session-topic | ts:" + ts_now + " | session:" + session_id + " | topic:" + safe_topic - let topic_tags: String = "["last-session-topic","conv:history","Conversation","session:topic"]" + let topic_tags: String = "[\"last-session-topic\",\"conv:history\",\"Conversation\",\"session:topic\"]" let topic_label: String = "last-session-topic:" + session_id // Delete old last-session-topic node for this session before writing fresh let old_topic: String = engram_search_json("last-session-topic:" + session_id, 2)