diff --git a/mcp-server/src/legal_mcp/services/citation_extractor.py b/mcp-server/src/legal_mcp/services/citation_extractor.py index f59688b..323f5d8 100644 --- a/mcp-server/src/legal_mcp/services/citation_extractor.py +++ b/mcp-server/src/legal_mcp/services/citation_extractor.py @@ -236,7 +236,18 @@ async def extract_and_store(case_law_id: UUID) -> dict: if not row: return {"extracted": 0, "linked": 0, "new": 0, "skipped": 0, "error": "not_found"} - text = row["full_text"] or "" + # A citation counts as the DECIDING body's reliance ONLY when it appears in + # the discussion/ruling sections — never where a party cites a ruling in its + # own arguments (block ז). Reuse the halacha extractor's section selection + # (G2: a single definition of "reasoning sections" — legal_analysis/ruling/ + # conclusion + the discussion-anchor, excluding facts/claims/intro) so a + # ruling cited only in appellant_claims/parties_claims is never attributed to + # the chair. Fall back to full_text only for un-chunked rows. + from legal_mcp.services import halacha_extractor as _hx + disc_chunks, _used_fallback = await _hx._select_extractable_chunks(case_law_id) + text = "\n".join((c.get("content") or "") for c in disc_chunks).strip() + if not text: + text = row["full_text"] or "" own_norm = _normalize_case_number(row["case_number"] or "") extracted = 0