feat(corroboration): approval_action decision fn + kill-switch (INV-COR2/COR4, X11 Phase 2)

- HALACHA_CORROBORATION_AUTO_APPROVE config (default ON, Dafna validated 2026-06-01)
- approval_action(agg, has_overruled): overruled→demote, corroborated→approve, else None
- 4 offline unit tests; Phase 2 plan + TaskMaster #75

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-01 04:34:23 +00:00
parent 391b025e8a
commit df007784c9
5 changed files with 385 additions and 3 deletions

View File

@@ -67,6 +67,12 @@ HALACHA_BULK_EXTRACT_EFFORT = os.environ.get("HALACHA_BULK_EXTRACT_EFFORT", "hig
HALACHA_CHUNK_CONCURRENCY = int(os.environ.get("HALACHA_CHUNK_CONCURRENCY", "3"))
HALACHA_CORROBORATION_MATCH_FLOOR = float(os.environ.get("HALACHA_CORROBORATION_MATCH_FLOOR", "0.50"))
HALACHA_CORROBORATION_MIN_CITES = int(os.environ.get("HALACHA_CORROBORATION_MIN_CITES", "2"))
# X11 Phase 2: gate corroboration → approval. Default ON (Dafna validated the
# Phase 1 signal, 2026-06-01). Set to "false" to disable the auto-approve/demote
# wiring while keeping the Phase 1 signal intact.
HALACHA_CORROBORATION_AUTO_APPROVE = os.environ.get(
"HALACHA_CORROBORATION_AUTO_APPROVE", "true"
).strip().lower() in ("1", "true", "yes", "on")
# Voyage AI
VOYAGE_API_KEY = os.environ.get("VOYAGE_API_KEY", "")

View File

@@ -52,6 +52,22 @@ def aggregate(links: list[dict], min_cites: int = config.HALACHA_CORROBORATION_M
}
def approval_action(agg: dict, has_overruled: bool) -> str | None:
"""Decide the corroboration→approval action for ONE halacha (INV-COR2/COR4).
- 'demote' : a later court overruled it → back to the chair gate (overruled
outranks any positive count, INV-COR2 strong form).
- 'approve' : corroborated (≥N distinct positives, 0 negatives — INV-COR4).
- None : leave as-is (single source, non-overruled negative, or the
uncorroborated tail — INV-COR5 keeps the chair gate).
"""
if has_overruled:
return "demote"
if agg.get("corroborated"):
return "approve"
return None
_TREATMENT_PROMPT = """אתה משפטן בכיר. נתון ציטוט של פסק/החלטה קודמים בתוך החלטה מאוחרת.
סווג כיצד ההחלטה המאוחרת **מטפלת** בתקדים המצוטט, לפי אחת מהקטגוריות:
- followed — אימצה והחילה את ההלכה.