feat(corroboration): aggregator — distinct positive + negative-flag (INV-COR4, X11)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-31 19:00:16 +00:00
parent dbc176ae66
commit 33f955e372
2 changed files with 37 additions and 0 deletions

View File

@@ -33,6 +33,23 @@ def accept_match(best: tuple[str, float] | None, floor: float = config.HALACHA_C
return halacha_id if sim >= floor else None
def aggregate(links: list[dict], min_cites: int = config.HALACHA_CORROBORATION_MIN_CITES) -> dict:
"""Aggregate per-halacha corroboration (INV-COR4/COR2).
links: [{"source_id": str, "treatment": str}, ...] already matched to ONE halacha.
positive_sources = count of DISTINCT source_id whose treatment is positive.
has_negative = any negative treatment present.
corroborated = positive_sources >= min_cites AND not has_negative.
"""
positive = {l["source_id"] for l in links if is_positive(l["treatment"])}
has_negative = any(is_negative(l["treatment"]) for l in links)
return {
"positive_sources": len(positive),
"has_negative": has_negative,
"corroborated": len(positive) >= min_cites and not has_negative,
}
_TREATMENT_PROMPT = """אתה משפטן בכיר. נתון ציטוט של פסק/החלטה קודמים בתוך החלטה מאוחרת.
סווג כיצד ההחלטה המאוחרת **מטפלת** בתקדים המצוטט, לפי אחת מהקטגוריות:
- followed — אימצה והחילה את ההלכה.