From c44cfd4f3d9529898617fc9d11b354c48bd658cc Mon Sep 17 00:00:00 2001 From: Prime Backup Bot Date: Wed, 11 Mar 2026 21:39:12 +0000 Subject: [PATCH] fix(control): allow help/start/read-only commands through guardrails --- prime_core/risk.py | 4 ++-- prime_core/telegram_control.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/prime_core/risk.py b/prime_core/risk.py index 612f6b3..f40d389 100644 --- a/prime_core/risk.py +++ b/prime_core/risk.py @@ -1,7 +1,7 @@ from __future__ import annotations TIERS = { - 'tier1_read': ['status', 'queue list', 'goals show'], + 'tier1_read': ['status', 'help', '/help', 'start', '/start', 'blocked', 'guardrails show', 'allowlist show', 'queue list', 'goals show'], 'tier2_safe_write': ['queue add', 'queue approve', 'queue deny', 'goals add', 'mode autonomous'], } @@ -12,7 +12,7 @@ HIGH_RISK_KEYWORDS = [ def classify(text: str) -> str: - t = text.lower().strip() + t = text.lower().lstrip('/').strip() if any(t.startswith(cmd) for cmd in TIERS['tier1_read']): return 'tier1_read' if any(t.startswith(cmd) for cmd in TIERS['tier2_safe_write']): diff --git a/prime_core/telegram_control.py b/prime_core/telegram_control.py index 46c8feb..609bae4 100644 --- a/prime_core/telegram_control.py +++ b/prime_core/telegram_control.py @@ -148,9 +148,10 @@ def set_autonomous(enabled: bool): def parse_and_handle(chat_id: int, msg_id: int, text: str) -> str: raw = text.strip() - risk = classify(raw.lstrip('/')) + normalized = raw.lstrip('/').strip() + risk = classify(normalized) log_event({'event':'telegram_command','chat_id':chat_id,'msg_id':msg_id,'text':raw,'risk':risk}) - if needs_approval(raw.lstrip('/')) and not raw.lower().startswith(('queue add','/queue add')): + if needs_approval(normalized) and not normalized.lower().startswith('queue add'): return f"Command blocked pending explicit queue workflow. Risk={risk}. Use queue add ... then approve." if raw.startswith('/start'): return "Prime online. " + help_text()