Skip to content

Commit 0860f41

Browse files
Jonathan Harrisonclaude
andcommitted
fix: scrub dangling lock-header leak + make benchmark stdout unicode-safe
Re-benchmark surfaced two issues: 1. Voice-reinforced adapters sometimes echo just the OPENING "=== PERMANENT BEHAVIORAL LOCKS (ABSOLUTE → NEVER VIOLATE) ===" header and trail off. The scrubber only matched complete open…close blocks, so the dangling header leaked into responses. Added pattern 2b: strip a lone opening LOCKS header to end-of-text (mirrors the existing CONSTRAINTS strip). 2. full_benchmark.py crashed mid-run printing a '→' to a cp1252 Windows console. Reconfigure stdout/stderr to utf-8 with errors='replace'. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent f78c275 commit 0860f41

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

benchmarks/full_benchmark.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414
from pathlib import Path
1515
from datetime import datetime
1616

17+
# Make stdout tolerant of non-cp1252 chars (responses may contain → — etc. on
18+
# Windows consoles). Without this, a single Unicode char crashes the whole run.
19+
try:
20+
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
21+
sys.stderr.reconfigure(encoding="utf-8", errors="replace")
22+
except Exception:
23+
pass
24+
1725
# Ollama API
1826
import urllib.request
1927

inference/codette_forge_bridge.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,17 @@ def _scrub_leaked_directives(text: str) -> str:
682682
flags=_re.IGNORECASE | _re.DOTALL,
683683
)
684684

685+
# 2b. Strip a DANGLING opening LOCKS header (no closing marker) to end of
686+
# text. Voice-reinforced adapters sometimes echo just the opening
687+
# "=== PERMANENT BEHAVIORAL LOCKS (ABSOLUTE → NEVER VIOLATE) ===" and
688+
# trail off — pattern 2 only matches complete (open…close) blocks.
689+
text = _re.sub(
690+
r'={2,}\s*PERMANENT BEHAVIORAL LOCKS.*',
691+
'',
692+
text,
693+
flags=_re.IGNORECASE | _re.DOTALL,
694+
)
695+
685696
# 3. Strip any remaining standalone LOCK lines (e.g. half-escaped blocks)
686697
text = _re.sub(
687698
r'\n?LOCK\s+\d+\s*[—\-]+\s+[A-Z][^\n]{0,300}',

0 commit comments

Comments
 (0)