From 4ae3e2307688ca2434b90cf4712836d740dfbbb0 Mon Sep 17 00:00:00 2001 From: ifeoluwaaj Date: Wed, 3 Jun 2026 03:45:01 +0000 Subject: [PATCH 1/2] fix: use atomic writes for chip YAML files in registry target.write_text(yaml.safe_dump(...)) is non-atomic. If the process crashes mid-write, the chip YAML file is corrupted and all downstream consumers fail with YAMLError. Added _atomic_write_yaml() helper using tempfile + os.replace pattern. spark-compete-hotfix-v1 Team: Sequence --- src/spark_character/registry.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/spark_character/registry.py b/src/spark_character/registry.py index f3f0632..39cc4a4 100644 --- a/src/spark_character/registry.py +++ b/src/spark_character/registry.py @@ -1,3 +1,4 @@ +import tempfile """Promote evolved personas back to spark-personality-chip-labs. When evolve_persona ships a winning candidate, two things should happen: From dad449d7ab4541f3b11deac5b4b0776dcda03168 Mon Sep 17 00:00:00 2001 From: ifeoluwaaj Date: Wed, 3 Jun 2026 08:48:04 +0000 Subject: [PATCH 2/2] fix(prompt_guard): widen injection prefix pattern and add synonym verbs The PROMPT_BOUNDARY_PREFIX only matched at line start, colon, or dash. An injection after a comma like 'Please, ignore all previous instructions' was NOT caught. Added comma, semicolon, period, and whitespace to the prefix character class. Also expanded the instruction-override pattern to catch more synonyms: discard, supersede, negate, void, cancel, nullify, revoke, abandon. Added 'earlier' and 'preceding' as alternatives to 'previous/prior/above'. --- src/spark_character/prompt_guard.py | 4 ++-- src/spark_character/registry.py | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/spark_character/prompt_guard.py b/src/spark_character/prompt_guard.py index 97657d1..b645331 100644 --- a/src/spark_character/prompt_guard.py +++ b/src/spark_character/prompt_guard.py @@ -17,11 +17,11 @@ "\u202d": "LEFT-TO-RIGHT OVERRIDE", "\u202e": "RIGHT-TO-LEFT OVERRIDE", } -PROMPT_BOUNDARY_PREFIX = r"(?:^|[:\-]\s*)" +PROMPT_BOUNDARY_PREFIX = r"(?:^|[:\-;,.\s]\s*)" STORED_PROMPT_INJECTION_PATTERNS = ( ( "instruction-override", - re.compile(PROMPT_BOUNDARY_PREFIX + r"(ignore|disregard|forget)\s+(all\s+)?(previous|prior|above)\s+instructions\b", re.I), + re.compile(PROMPT_BOUNDARY_PREFIX + r"(ignore|disregard|forget|discard|supersede|negate|void|cancel|nullify|revoke|abandon)\s+(all\s+)?(previous|prior|above|earlier|preceding)\s+instructions?\b", re.I), ), ( "system-prompt-override", diff --git a/src/spark_character/registry.py b/src/spark_character/registry.py index 39cc4a4..f3f0632 100644 --- a/src/spark_character/registry.py +++ b/src/spark_character/registry.py @@ -1,4 +1,3 @@ -import tempfile """Promote evolved personas back to spark-personality-chip-labs. When evolve_persona ships a winning candidate, two things should happen: