diff --git a/mcp-server/src/legal_mcp/services/db.py b/mcp-server/src/legal_mcp/services/db.py index 7e2455e..c1c51c5 100644 --- a/mcp-server/src/legal_mcp/services/db.py +++ b/mcp-server/src/legal_mcp/services/db.py @@ -3406,9 +3406,23 @@ async def list_halachot( h.cites, h.confidence, h.quote_verified, h.review_status, h.reviewer, h.reviewed_at, h.created_at, h.updated_at, cl.case_number, cl.case_name, cl.court, cl.date AS decision_date, - cl.precedent_level + cl.precedent_level, + COALESCE(cor.corroboration_count, 0)::int AS corroboration_count, + COALESCE(cor.corroboration_negative, false) AS corroboration_negative FROM halachot h LEFT JOIN case_law cl ON cl.id = h.case_law_id + LEFT JOIN ( + SELECT halacha_id, + count(DISTINCT COALESCE(citing_case_law_id::text, + citing_decision_id::text, source_citation_id::text)) + FILTER (WHERE treatment IN ('followed','explained')) + AS corroboration_count, + bool_or(treatment IN + ('distinguished','criticized','questioned','overruled')) + AS corroboration_negative + FROM halacha_citation_corroboration + GROUP BY halacha_id + ) cor ON cor.halacha_id = h.id {where_sql} ORDER BY h.case_law_id, h.halacha_index LIMIT ${idx} OFFSET ${idx + 1} diff --git a/web-ui/src/components/precedents/corroboration-badge.tsx b/web-ui/src/components/precedents/corroboration-badge.tsx new file mode 100644 index 0000000..dd37b0f --- /dev/null +++ b/web-ui/src/components/precedents/corroboration-badge.tsx @@ -0,0 +1,51 @@ +import { Scale, AlertTriangle } from "lucide-react"; +import { Badge } from "@/components/ui/badge"; +import type { Halacha } from "@/lib/api/precedent-library"; + +/* X11 — citation corroboration signal for a halacha. + * + * Shows how many distinct later courts/committees adopted this halacha + * (positive treatment). ≥2 distinct positive sources = "מתוקף" (the + * auto-approve threshold, INV-COR4); a single citation is shown more + * softly. A negative treatment (distinguished/criticized/overruled) is + * surfaced as a warning — those never auto-approve and an overruled one + * is sent back to the chair gate (INV-COR2). Renders nothing when there + * is no citation signal at all. */ +export function CorroborationBadge({ halacha }: { halacha: Halacha }) { + const count = halacha.corroboration_count ?? 0; + const negative = halacha.corroboration_negative ?? false; + + if (negative) { + return ( + + טיפול שלילי בציטוט + + ); + } + + if (count <= 0) return null; + + const corroborated = count >= 2; + return ( + + + {corroborated ? `מתוקף · ${count} ציטוטים` : "ציטוט מאמת · 1"} + + ); +} diff --git a/web-ui/src/components/precedents/extracted-halachot.tsx b/web-ui/src/components/precedents/extracted-halachot.tsx index 3d1040e..cdcafeb 100644 --- a/web-ui/src/components/precedents/extracted-halachot.tsx +++ b/web-ui/src/components/precedents/extracted-halachot.tsx @@ -2,6 +2,7 @@ import { useMemo, useState } from "react"; import { Badge } from "@/components/ui/badge"; +import { CorroborationBadge } from "@/components/precedents/corroboration-badge"; import type { Halacha } from "@/lib/api/precedent-library"; const RULE_TYPE_LABELS: Record = { @@ -148,6 +149,7 @@ export function ExtractedHalachotSection({ halachot }: { halachot: Halacha[] }) ביטחון {h.confidence.toFixed(2)} + {h.page_reference ? ( {h.page_reference} diff --git a/web-ui/src/components/precedents/halacha-review-panel.tsx b/web-ui/src/components/precedents/halacha-review-panel.tsx index 52e8f0f..a8de818 100644 --- a/web-ui/src/components/precedents/halacha-review-panel.tsx +++ b/web-ui/src/components/precedents/halacha-review-panel.tsx @@ -7,6 +7,7 @@ import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { Skeleton } from "@/components/ui/skeleton"; import { Textarea } from "@/components/ui/textarea"; +import { CorroborationBadge } from "./corroboration-badge"; import { practiceAreaLabel } from "./practice-area"; import { useHalachotPending, useUpdateHalacha, type Halacha, @@ -115,6 +116,7 @@ function HalachaCard({ {ruleTypeLabel(h.rule_type)} + diff --git a/web-ui/src/lib/api/precedent-library.ts b/web-ui/src/lib/api/precedent-library.ts index 70131dc..f52fc97 100644 --- a/web-ui/src/lib/api/precedent-library.ts +++ b/web-ui/src/lib/api/precedent-library.ts @@ -83,6 +83,11 @@ export type Halacha = { court?: string; decision_date?: string | null; precedent_level?: string; + /* X11 citation corroboration — how many distinct later courts/committees + * adopted this halacha (positive treatment), and whether any cited it + * negatively (distinguished/criticized/overruled). */ + corroboration_count?: number; + corroboration_negative?: boolean; }; export type RelatedCase = {