Prevent status regression in case_update
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 1m32s
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 1m32s
CEO agent was reverting case status from "processing" to "new" when updating metadata fields. Added ordered status list — case_update now silently ignores status changes that would move backwards. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -277,13 +277,27 @@ async def case_update(
|
|||||||
"""
|
"""
|
||||||
from datetime import date as date_type
|
from datetime import date as date_type
|
||||||
|
|
||||||
|
# Ordered workflow statuses — regression protection
|
||||||
|
STATUS_ORDER = [
|
||||||
|
"new", "uploading", "processing", "documents_ready",
|
||||||
|
"analyst_verified", "research_complete", "outcome_set",
|
||||||
|
"brainstorming", "direction_approved", "analysis_enriched", "ready_for_writing",
|
||||||
|
"drafting", "qa_review", "drafted",
|
||||||
|
"exported", "reviewed", "final",
|
||||||
|
]
|
||||||
|
|
||||||
case = await db.get_case_by_number(case_number)
|
case = await db.get_case_by_number(case_number)
|
||||||
if not case:
|
if not case:
|
||||||
return f"תיק {case_number} לא נמצא."
|
return f"תיק {case_number} לא נמצא."
|
||||||
|
|
||||||
fields = {}
|
fields = {}
|
||||||
if status:
|
if status:
|
||||||
fields["status"] = status
|
current = case.get("status", "")
|
||||||
|
cur_idx = STATUS_ORDER.index(current) if current in STATUS_ORDER else -1
|
||||||
|
new_idx = STATUS_ORDER.index(status) if status in STATUS_ORDER else -1
|
||||||
|
# Only update if advancing or status is unknown to the order
|
||||||
|
if new_idx >= cur_idx or new_idx == -1:
|
||||||
|
fields["status"] = status
|
||||||
if title:
|
if title:
|
||||||
fields["title"] = title
|
fields["title"] = title
|
||||||
if subject:
|
if subject:
|
||||||
|
|||||||
Reference in New Issue
Block a user