feat(missing-precedents): עמודת "צוטט ע"י" מציגה provenance לפי discovery_source (#148)
All checks were successful
G12 Leak-Guard / leak-guard (pull_request) Successful in 5s
Lint — undefined names / undefined-names (pull_request) Successful in 11s

362 רשומות שהובאו מ-cited_only (גרף-הציטוטים) ומיומונים הציגו "—" ב"צוטט ע"י",
כי העמודה קראה רק מ-cited_in_case_id (ערר חי) + cited_by_party, וה-provenance
נשמר ב-notes בלבד. אושר ע"י חיים דרך שער Claude Design (mockup 09-missing-precedents).

- db.list_missing_precedents + get_missing_precedent: שדות-provenance מחושבים
  (_MP_PROVENANCE_COLS משותף, G2): cited_by_precedents (array_agg מ-
  precedent_internal_citations עבור cited_only — מי-מצטט את ה-stub) +
  yomon_number (substring מ-notes עבור digest). discovery_source כבר הוחזר.
- web-ui: MissingPrecedent type + תא "צוטט ע"י" מסתעף לפי discovery_source:
  cited_only→chip "פסיקה בקורפוס" + "מצוטט ע"י: <מספרים>"; digest→chip "יומון" +
  "מס' X"; manual→SourceChip+צד (כמו היום). טוקני plum/teal ב-globals.css
  (מה-mockup המאושר).

אומת מול ה-DB החי: cited_only→מצטטים (רע"א 1054/21→8047-23,8126-03-25),
digest→מס'-יומון (306 רשומות). tsc נקי, eslint נקי, 360 בדיקות mcp עוברות.

Invariants: G2 (שדה-provenance יחיד משותף ל-list+detail), G1 (נגזר במקור),
INV-IA*/UI (שינוי-עמוד דרך שער Claude Design), G12.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-16 07:37:29 +00:00
parent 9a7c1c4148
commit fc02ccaeff
4 changed files with 65 additions and 9 deletions

View File

@@ -7311,6 +7311,21 @@ async def create_missing_precedent(
return _row_to_missing_precedent(row)
# Provenance columns for the "צוטט ע״י" display (#148): for a non-appeal gap the
# cited_in_case_id is NULL, so we surface where it actually surfaced from —
# cited_by_precedents (corpus precedents that cite a cited_only stub, via the
# citation graph) and yomon_number (parsed from a digest gap's notes). Shared by
# the list and detail queries so both render identically (G2).
_MP_PROVENANCE_COLS = """,
(SELECT array_agg(DISTINCT src.case_number ORDER BY src.case_number)
FROM precedent_internal_citations pic
JOIN case_law src ON src.id = pic.source_case_law_id
WHERE pic.cited_case_law_id = mp.linked_case_law_id
AND COALESCE(src.case_number, '') <> ''
) AS cited_by_precedents,
substring(mp.notes from 'מס''?\\s*([0-9]+)') AS yomon_number"""
async def list_missing_precedents(
status: str | None = None,
case_id: UUID | None = None,
@@ -7355,7 +7370,7 @@ async def list_missing_precedents(
SELECT mp.*,
c.case_number AS cited_in_case_number,
cl.case_number AS linked_case_law_number,
cl.case_name AS linked_case_law_name
cl.case_name AS linked_case_law_name{_MP_PROVENANCE_COLS}
FROM missing_precedents mp
LEFT JOIN cases c ON c.id = mp.cited_in_case_id
LEFT JOIN case_law cl ON cl.id = mp.linked_case_law_id
@@ -7379,11 +7394,11 @@ async def get_missing_precedent(mp_id: UUID) -> dict | None:
pool = await get_pool()
async with pool.acquire() as conn:
row = await conn.fetchrow(
"""
f"""
SELECT mp.*,
c.case_number AS cited_in_case_number,
cl.case_number AS linked_case_law_number,
cl.case_name AS linked_case_law_name
cl.case_name AS linked_case_law_name{_MP_PROVENANCE_COLS}
FROM missing_precedents mp
LEFT JOIN cases c ON c.id = mp.cited_in_case_id
LEFT JOIN case_law cl ON cl.id = mp.linked_case_law_id