fix(corpus): re-link orphan citations when a cited ruling is uploaded (G1) #309
Reference in New Issue
Block a user
Delete Branch "worktree-citation-relink"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
מה
precedent_internal_citationsפותרcited_case_law_idרק בזמן-חילוץ. כשהחלטה מצטטת פסיקה שעדיין לא בקורפוס — הקצה נשמר עםNULL. הפסיקה מועלית לרוב ימים אחר-כך, אך הקצה היתום לא נפתר-מחדש לעולם → גרף-הציטוטים מתחת-סופר את הקישוריות (אותו דפוס ערך-נגזר-מיושן כמוsearchable).מחמיר: פסיקה חיצונית נשמרת בלי תחילית-ערכאה (
3213/97) בעוד הציטוט נושא אותה (ע"א 3213/97) — ולכן חלק גדול מה"חסרים" היה בעצם קיים-אך-לא-מקושר.שינוי
citation_extractor.relink_orphan_citations(case_law_id=None)— פותרת-מחדש קצוות-יתומים דרך הפותר הקנוני_resolve_case_law_id(אפס לוגיקת-התאמה מקבילה, G2); ממוקדת-שורה או סריקה-מלאה כש-None. idempotent.ingest_documentקורא לה בכל העלאה (non-fatal) → הגרף מרפא את עצמו.נתונים קיימים (backfill חד-פעמי מול ה-DB החי)
חוברו 128 קצוות → ייחודיים-בקורפוס 67→178, נותרים-חסרים ייחודיים 262→143. כלומר "בשימוש וטרם הועלה" האמיתי ≈ 143 (לא 262 שהגרף-המיושן רמז).
Invariants
G1 (פתרון-מחדש של הקישור-הנגזר בכתיבה) · G2 (פותר יחיד)
🤖 Generated with Claude Code
precedent_internal_citations resolves cited_case_law_id only at extraction time. When a decision cites a ruling that isn't in the corpus yet, the edge is stored with cited_case_law_id=NULL. The ruling is often uploaded days later — but the orphan edge was never re-resolved, so the citation graph permanently under-counted real connectivity (same stale-derived-value pattern as the searchable flag). Worse, external rulings store case_number WITHOUT the court prefix ("3213/97") while citations carry it ("ע\"א 3213/97"), so a large share of "missing" citations were actually present-but-unlinked. Fix: - new citation_extractor.relink_orphan_citations(case_law_id=None): re-resolves orphan edges via the canonical _resolve_case_law_id (no parallel matching, G2); scoped to one row, or full sweep when None. Idempotent. - ingest_document calls it on every upload (non-fatal) so the graph self-heals. Existing backlog already re-linked via a one-off sweep against the live DB: linked 128 edges → in-corpus distinct rulings 67→178, unlinked distinct 262→143. So real "cited but not uploaded" ≈ 143, not the 262 the stale graph implied. Invariants: G1 (re-resolve the derived link at the write) · G2 (single resolver). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>