fix(pipeline): resolve SafeToAutoRun deadlock and sync freezing (v0.5.20) (#589)

This commit is contained in:
Variet Worker
2026-04-08 07:28:48 +09:00
parent 13f13ee243
commit 2eb1fbb6b7
16 changed files with 821 additions and 61 deletions

33
bot.py
View File

@@ -650,6 +650,39 @@ class GravityBot(commands.Bot):
if req.conversation_id and req.conversation_id != '__global__':
self.conv_to_project[req.conversation_id] = project
# ── SafeToAutoRun: approve immediately and quietly ──
if getattr(req, "safe_to_auto_run", False):
self._cap_dict(self._sent_approval_ids)
self._sent_approval_ids[req.request_id] = True
# Generate approve response back to extension
approve_btn_index = 0
pending_file = self.bridge.pending_dir / f"{req.request_id}.json"
if pending_file.exists():
try:
pdata = json.loads(pending_file.read_text(encoding="utf-8-sig"))
btns = pdata.get("buttons")
if btns and len(btns) > 1:
reject_words = {"deny", "reject", "cancel", "reject all", "decline", "dismiss", "stop"}
for b in btns:
txt = b.get("text", "").lower().strip()
if txt not in reject_words:
approve_btn_index = b.get("index", 0)
break
except (json.JSONDecodeError, OSError):
pass
self.bridge.write_response(UserResponse(
request_id=req.request_id,
approved=True,
button_index=approve_btn_index,
step_type=getattr(req, 'step_type', ''),
project_name=project,
))
logger.info(f"SafeToAutoRun (Quietly Auto-approved): {req.request_id[:12]} project={project}")
phase1_processed += 1
continue
# ── Auto-approve: if project has auto enabled, approve immediately ──
if project in self.auto_approve_projects:
# Defence: reject-word commands should NEVER be auto-approved