feat(graph): halacha (rule) layer (corpus graph — closes Phase 2)

Enables the previously-disabled "הלכות" toggle. Each approved/published halacha
of a displayed precedent becomes a hal:<id> node linked to its parent
precedent (extracted_from); two cross-rule edges when both endpoints are in
view: corroborates (a later ruling cites the rule —
halacha_citation_corroboration) and equivalent (same principle from another
committee — equivalent_halachot). Node size = corroboration in-degree.

Backend (web/graph_api.py — read-only, G2):
- _halacha_nodes_and_edges(): halachot WHERE case_law_id in view AND
  review_status IN (approved, published), LIMIT 600; rule_type carried in the
  source_kind slot, rule_statement in note. Wired into both build functions
  (gated via node_types). Metrics still exclude halacha edges (only cites/
  precedent-typed feed PageRank). Validated: 185 halachot on the top-30
  precedents; 20 corroboration + 5 equivalent edges in the corpus.

Frontend:
- graph.ts: GraphEdgeType += extracted_from.
- graph-filter-panel: "הלכות" toggle enabled (was disabled "שלב ב׳").
- graph-canvas: amber halacha nodes; edge colours — extracted_from (faint
  amber), corroborates (amber), equivalent (violet).
- graph-node-panel: halacha branch — אזכורים + סוג כלל + rule text; "open in
  library" deep-links to the parent precedent.
- graph-view: halacha added to node + edge legends.

web-ui build + lint pass. Invariants: G2 (SELECT-only), UI2 (no model change —
reuses note/source_kind/case_law_id slots).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-08 05:13:09 +00:00
parent cc9adc5c1f
commit ef21cb93e5
6 changed files with 159 additions and 7 deletions

View File

@@ -401,6 +401,7 @@ function RankList({
const LEGENDS: Record<ColorBy, { color: string; label: string }[]> = {
type: [
{ color: "#1e3a5f", label: "פסיקה" },
{ color: "#b45309", label: "הלכה" },
{ color: "#a97d3a", label: "נושא" },
{ color: "#475569", label: "תחום" },
],
@@ -429,6 +430,7 @@ const EDGE_LEGEND: { color: string; label: string }[] = [
{ color: "rgba(80,90,110,0.7)", label: "ציטוט" },
{ color: "rgba(169,125,58,0.5)", label: "נושא/תחום" },
{ color: "rgba(47,111,122,0.7)", label: "יומון מסכם" },
{ color: "rgba(180,83,9,0.6)", label: "כלל/אזכור" },
];
function Legend({ colorBy }: { colorBy: ColorBy }) {