feat(digests): יומון-לא-מקושר → "פסיקה חסרה" — סוף לבליעה-שקטה (#136)
All checks were successful
G12 Leak-Guard / leak-guard (pull_request) Successful in 4s
Lint — undefined names / undefined-names (pull_request) Successful in 11s

צינור-היומונים (X12) קישר אוטומטית רק לפסיקה שכבר בקורפוס; ציטוט שלא נמצא נבלע
בשקט אלא אם היה פס"ד בית-משפט בר-אחזור. כך 369 עררים + 21 לא-מסווגים שהוזכרו
ביומונים מעולם לא הופיעו כפער.

תיקון (G2 — מסווג יחיד + נתיב-MP יחיד; INV-DIG3/CF2 — אין בליעה-שקטה):
- digest_library: ה-gap branch (try_autolink ללא-התאמה) קורא כעת
  _handle_unlinked_citation — ניתוב דרך court_citation.classify: supreme/admin →
  court_fetch_job (כקודם; האורקסטרטור פותח MP משלו בכשל), skip(ערר/בל"מ)/unknown →
  missing_precedent (discovery_source='digest', provenance=מס'-יומון+digest_id),
  deduped designator-aware דרך citation_norm (#143).
- court_fetch_orchestrator._open_gap: הוקשח ל-dedup אמיתי (find לפני create) +
  discovery_source='court_fetch' — התגובה הבטיחה "deduped" אך create לא דידאפ.
- scripts/backfill_digest_missing_precedents.py: מריץ try_autolink על 461 הקיימים
  (dry-run: 71 fetchable + 390 gap). אידמפוטנטי. יורץ אחרי הפריסה.

תלוי-הקשר #143 (citation_norm + נתיב-יצירה). השפעת-UI: דף "פסיקה חסרה" יגדל
מ-207 ל-~597 פתוחים (אושר ע"י חיים).

בדיקות: test_digest_unlinked_citation (ערר→MP, פס"ד→fetch, dedup, unknown→MP).
כל 360 עוברות. guards נקיים.

Invariants: G2 (מסווג+נתיב-MP יחיד), INV-DIG3/INV-CF2 (פער גלוי, לא נבלע),
INV-DIG1 (יומון מצביע, לא מצוטט), G1 (dedup מנורמל), G12.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-15 09:06:12 +00:00
parent ea8712ecff
commit 9fd506ff2b
5 changed files with 204 additions and 21 deletions

View File

@@ -314,10 +314,14 @@ async def _record_failure(
async def _open_gap(citation: str, *, reason: str) -> None:
"""Open a missing_precedent gap so the chair sees it (INV-CF2/CF3).
Best-effort + de-duplicated by the missing_precedents layer; a failure
here is logged, never raised (it must not mask the original outcome).
Best-effort + de-duplicated (designator-aware via citation_norm, #143); a
failure here is logged, never raised (it must not mask the original outcome).
"""
try:
await db.create_missing_precedent(citation=citation, notes=reason)
if await db.find_missing_precedent_by_citation(citation):
return
await db.create_missing_precedent(
citation=citation, notes=reason, discovery_source="court_fetch",
)
except Exception:
logger.warning("could not open missing_precedent for %s", citation)

View File

@@ -83,38 +83,60 @@ async def try_autolink(digest_id: UUID | str, underlying_citation: str) -> str |
logger.warning("digest try_autolink lookup failed for %r: %s", citation, e)
return None
if not match:
# Gap (INV-DIG3): the underlying ruling isn't in the corpus. If it's a
# court verdict (not ועדת-ערר), enqueue an X13 auto-fetch job so the gap
# is actionable instead of silently dropped (INV-CF2). Never raises.
await _enqueue_court_fetch(digest_id, citation)
# Gap (INV-DIG3): the underlying ruling isn't in the corpus. Surface it —
# never drop silently (INV-CF2). Court verdicts (supreme/admin) get an X13
# auto-fetch job; ועדת-ערר / unknown — which נט-המשפט can't serve — get a
# missing_precedent the chair sees on /missing-precedents (#136). Never
# raises.
await _handle_unlinked_citation(digest_id, citation)
return None
await db.link_digest_to_case_law(digest_id, match["id"])
return str(match["id"])
async def _enqueue_court_fetch(digest_id: UUID | str, citation: str) -> None:
"""Queue an X13 court-verdict fetch for an unlinked digest citation.
async def _handle_unlinked_citation(digest_id: UUID | str, citation: str) -> None:
"""Surface an unlinked digest citation — auto-fetch if possible, else record
a missing_precedent. Closes the silent-drop gap (#136, INV-DIG3/CF2).
Court rulings (supreme/admin) → a ``court_fetch_jobs`` row drained later by
``court_fetch_drain``. ועדת-ערר (skip) is left alone — it needs Nevo and is
surfaced through the normal missing-precedent path, not auto-fetch.
Routing via the ONE canonical classifier (``court_citation.classify``):
* supreme/admin → ``court_fetch_jobs`` (drained by X13; on fetch failure the
orchestrator opens its own missing_precedent, so no double-record here).
* skip (ערר/בל"מ) / unknown → ``missing_precedents`` (needs Nevo / manual;
נט-המשפט can't serve it). Deduped designator-aware via citation_norm
(#143) so re-runs and overlaps don't pile up.
"""
try:
from legal_mcp.services import court_citation
cit = court_citation.classify(citation)
if cit.tier not in ("supreme", "admin"):
if cit.tier in ("supreme", "admin"):
await db.court_fetch_job_upsert(
case_number_norm=cit.case_number_norm,
citation_raw=citation,
tier=cit.tier,
court=cit.court_prefix,
digest_id=UUID(str(digest_id)),
)
logger.info("digest %s: enqueued court-fetch for %r (tier=%s)",
digest_id, citation, cit.tier)
return
await db.court_fetch_job_upsert(
case_number_norm=cit.case_number_norm,
citation_raw=citation,
tier=cit.tier,
court=cit.court_prefix,
digest_id=UUID(str(digest_id)),
# Non-fetchable (ערר/בל"מ/unknown) — open a missing_precedent gap so it's
# visible and actionable instead of vanishing. Dedup first (#143).
if await db.find_missing_precedent_by_citation(citation):
return
digest = await db.get_digest(digest_id)
yomon = (digest or {}).get("yomon_number") or ""
note = (f"זוהה דרך יומון מס' {yomon} (digest_id={digest_id})" if yomon
else f"זוהה דרך יומון (digest_id={digest_id})")
await db.create_missing_precedent(
citation=citation,
discovery_source="digest",
notes=note,
)
logger.info("digest %s: enqueued court-fetch for %r (tier=%s)",
logger.info("digest %s: opened missing_precedent for %r (tier=%s)",
digest_id, citation, cit.tier)
except Exception as e: # never break digest ingest
logger.warning("digest court-fetch enqueue failed for %r: %s", citation, e)
logger.warning("digest unlinked-citation handling failed for %r: %s",
citation, e)
# ── Container-safe creation (web upload) — no LLM, no embedding ──────