From cddc7c8d24452ae9fd843fa6fc40d3cb294888b5 Mon Sep 17 00:00:00 2001 From: Chaim Date: Sun, 17 May 2026 11:02:30 +0000 Subject: [PATCH] fix: start-workflow wakeup failure now returns 502 instead of silent success MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If pc_wake_ceo fails, the endpoint now raises HTTP 502 and skips the case_update to processing — preventing cases from silently getting stuck with no CEO running. Also adds `processing` to CEO routing table and updates case_list docstring with full status list. Co-Authored-By: Claude Sonnet 4.6 --- .claude/agents/legal-ceo.md | 1 + mcp-server/src/legal_mcp/tools/cases.py | 5 ++++- web/app.py | 11 +++++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.claude/agents/legal-ceo.md b/.claude/agents/legal-ceo.md index 142f9c9..84db590 100644 --- a/.claude/agents/legal-ceo.md +++ b/.claude/agents/legal-ceo.md @@ -585,6 +585,7 @@ Paperclip חוסם אוטומטית כל issue ב-`in_progress` שאין לו ru | סטטוס | מי שינה לזה | פעולה הבאה | |--------|-------------|------------| +| `processing` | start-workflow (ממשק) | → בדוק אם כבר קיים issue פעיל לסוכן משנה. אם לא → המשך ל-§A כרגיל (בדוק documents + claims) | | `new` | (יצירת תיק) | → בדוק extraction_status של מסמכים. אם יש `pending` → צור issue למגיה (410c0167). אם כולם `completed`/`proofread` → צור issue למנתח | | `proofread` | מגיה | → צור issue למנתח משפטי (ראה תבנית למטה) | | `documents_ready` | מנתח | → שלב A (בדיקות שלמות + שליליות + מתודולוגיה). אם עובר → עדכן ל-`analyst_verified` | diff --git a/mcp-server/src/legal_mcp/tools/cases.py b/mcp-server/src/legal_mcp/tools/cases.py index 874ee35..0b6fea4 100644 --- a/mcp-server/src/legal_mcp/tools/cases.py +++ b/mcp-server/src/legal_mcp/tools/cases.py @@ -237,7 +237,10 @@ async def case_list(status: str = "", limit: int = 50) -> str: """רשימת תיקי ערר עם אפשרות סינון לפי סטטוס. Args: - status: סינון לפי סטטוס (new, in_progress, drafted, reviewed, final). ריק = הכל + status: סינון לפי סטטוס (new, processing, proofread, documents_ready, analyst_verified, + research_complete, outcome_set, direction_pending, direction_approved, + analysis_enriched, ready_for_writing, drafted, qa_passed, qa_failed, + exported, done). ריק = הכל limit: מספר תוצאות מקסימלי """ cases = await db.list_cases(status=status or None, limit=limit) diff --git a/web/app.py b/web/app.py index dd44f65..eb714bf 100644 --- a/web/app.py +++ b/web/app.py @@ -2588,14 +2588,17 @@ async def api_start_workflow(case_number: str): except Exception as e: raise HTTPException(502, f"שגיאת Paperclip: {e}") - # 3. Wake the CEO agent + # 3. Wake the CEO agent — must succeed before marking case as processing try: wakeup = await pc_wake_ceo(issue["issue_id"], case_number, issue.get("company_id", "")) except Exception as e: - logger.warning("CEO wakeup failed for case %s: %s", case_number, e) - wakeup = {"error": str(e)} + logger.error("CEO wakeup failed for case %s: %s", case_number, e) + raise HTTPException( + 502, + f"נוצר issue {issue['identifier']} אך עירור ה-CEO נכשל: {e}. ניתן לנסות שנית.", + ) - # 4. Update case status to processing + # 4. Update case status to processing (only after wakeup confirmed) await cases_tools.case_update(case_number, status="processing") return {