feat(missing-precedents): עמודת "צוטט ע"י" — provenance לפי discovery_source (#148) #271

Merged
chaim merged 1 commits from worktree-mp-provenance-column into main 2026-06-16 07:38:31 +00:00
4 changed files with 65 additions and 9 deletions
Showing only changes of commit fc02ccaeff - Show all commits

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

View File

@@ -51,6 +51,11 @@
--color-danger-bg: #f5e6e6;
--color-info: #4e6a8c;
--color-info-bg: #e6ecf3;
/* provenance chips for missing-precedents "צוטט ע״י" (#148, approved mockup 09) */
--color-plum: #6d5191;
--color-plum-bg: #efe9f6;
--color-teal: #3f7a7a;
--color-teal-bg: #e3efef;
/* ── Typography ─────────────────────────────────────── */
--font-sans: var(--font-heebo), -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

View File

@@ -173,12 +173,44 @@ export function MissingPrecedentsTable({ status, q, legalTopic }: Props) {
)}
</TableCell>
<TableCell className="text-sm text-ink">
<SourceChip party={mp.cited_by_party} />
{mp.cited_by_party_name ? (
<div className="text-[0.7rem] text-ink-muted truncate max-w-[160px] mt-1">
{mp.cited_by_party_name}
</div>
) : null}
{mp.discovery_source === "cited_only" ? (
<>
<Badge
variant="outline"
className="rounded-full whitespace-nowrap bg-plum-bg text-plum border-transparent"
>
פסיקה בקורפוס
</Badge>
{mp.cited_by_precedents?.length ? (
<div className="text-[0.7rem] text-ink-muted truncate max-w-[180px] mt-1">
מצוטט ע״י: {mp.cited_by_precedents.join(", ")}
</div>
) : null}
</>
) : mp.discovery_source === "digest" ? (
<>
<Badge
variant="outline"
className="rounded-full whitespace-nowrap bg-teal-bg text-teal border-transparent"
>
יומון
</Badge>
{mp.yomon_number ? (
<div className="text-[0.7rem] text-ink-muted mt-1">
מס׳ {mp.yomon_number}
</div>
) : null}
</>
) : (
<>
<SourceChip party={mp.cited_by_party} />
{mp.cited_by_party_name ? (
<div className="text-[0.7rem] text-ink-muted truncate max-w-[160px] mt-1">
{mp.cited_by_party_name}
</div>
) : null}
</>
)}
</TableCell>
<TableCell>
<StatusBadge status={mp.status} />

View File

@@ -52,6 +52,10 @@ export type MissingPrecedent = {
created_at: string;
updated_at: string;
notes: string | null;
// provenance of the gap (#148) — how it surfaced, for the "צוטט ע״י" column.
discovery_source: string | null; // manual | cited_only | digest | court_fetch
cited_by_precedents: string[] | null; // corpus precedents citing a cited_only stub
yomon_number: string | null; // digest gap's source yomon number
};
export type MissingPrecedentListResponse = {