fix(qa): enforce critical-QA gate on export + fix neutral_background critical-but-passed (GAP-15/16, INV-QA3/EX3)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -399,6 +399,26 @@ async def export_docx(case_number: str, output_path: str = "") -> str:
|
||||
|
||||
case_id = UUID(case["id"])
|
||||
|
||||
# INV-EX3 / INV-QA3: a decision cannot be exported while critical QA gates
|
||||
# fail (or before QA has been run at all). Gate on the STORED qa_results —
|
||||
# cheap SELECT, no LLM re-run.
|
||||
if not await db.qa_run_exists(case_id):
|
||||
return json.dumps({
|
||||
"status": "error",
|
||||
"message": "ייצוא נחסם: בקרת איכות (QA) טרם רצה על התיק. "
|
||||
"הרץ validate_decision לפני ייצוא.",
|
||||
}, ensure_ascii=False, indent=2)
|
||||
|
||||
critical = await db.get_critical_qa_failures(case_id)
|
||||
if critical:
|
||||
gate_names = ", ".join(r["check_name"] for r in critical)
|
||||
return json.dumps({
|
||||
"status": "error",
|
||||
"message": f"ייצוא נחסם: שערי QA קריטיים נכשלו ({gate_names}). "
|
||||
f"תקן את הליקויים והרץ validate_decision מחדש לפני ייצוא.",
|
||||
"failed_gates": [r["check_name"] for r in critical],
|
||||
}, ensure_ascii=False, indent=2)
|
||||
|
||||
try:
|
||||
path = await docx_exporter.export_decision(case_id, output_path or None)
|
||||
# Register this export as the new source of truth
|
||||
|
||||
Reference in New Issue
Block a user