feat(stability): add risk tiers, audit trail, and safer restore with dry-run

This commit is contained in:
Prime Backup Bot
2026-03-11 20:45:29 +00:00
parent 2ee5cebddc
commit d85366027e
6 changed files with 91 additions and 3 deletions
+6
View File
@@ -7,6 +7,8 @@ import time
import urllib.parse
import urllib.request
from pathlib import Path
from .risk import classify, needs_approval
from .audit import log_event
OFFSET_FILE = Path('/srv/prime-core/state/telegram-offset.txt')
@@ -109,6 +111,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('/'))
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')):
return f"Command blocked pending explicit queue workflow. Risk={risk}. Use queue add ... then approve."
if raw.startswith('/start'):
return "Prime online. " + help_text()
if raw.startswith('/help') or raw == 'help':