Files
legal-ai/mcp-server/src/legal_mcp/services/principles.py
Chaim 4ca907b97f
All checks were successful
G12 Leak-Guard / leak-guard (pull_request) Successful in 4s
Lint — undefined names / undefined-names (pull_request) Successful in 11s
feat(principles): retroactive cull (Phase C) + source-derived terminology (Phase D, #152)
Phase C — scripts/cull_principles.py: re-adjudicates every existing 'original'
principle with the SAME panel regime (panel_keep_score → classify → apply_cap),
reversible (CSV backup + rejected canonical recoverable), usage-throttled.
panel_extraction.panel_keep_score + apply_cap (shared, G2). Dry-run on 3
decisions: 37→15 survive.

Phase D — services/principles.py: source-derived label הלכה (binding court) /
כלל פרשני (committee) / עיקרון (persuasive); umbrella עקרונות משפטיים. Wired into
canonical_halacha_get/list (principle_class+principle_label). UI string changes
deferred to the Claude Design gate. spec INV-LRN7; SCRIPTS.md; 7 new tests; 428 green.

Phase E needs no new code — synthesis already targets pending_synthesis, which the
cull leaves only on survivors (rejected canonicals → 'rejected').

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 11:14:59 +00:00

46 lines
1.8 KiB
Python

"""Legal-principles terminology — the single source for what a principle is CALLED (#152).
chaim 2026-06-19: "הלכה" was the wrong umbrella. The corpus holds **עקרונות
משפטיים** (legal principles); the term for one depends on its SOURCE:
• binding higher court (מחוזי/עליון) → "הלכה" (binding precedent)
• appeals committee (internal_committee) → "כלל פרשני" (interpretive rule —
the committee applies law, never makes it)
• non-binding external (persuasive) → "עיקרון" (persuasive principle)
The class is derived from where a principle was FIRST established
(canonical_halachot.first_established_in → case_law.source_kind/is_binding), so no
new column is needed. UI/tools call :func:`label` instead of hardcoding "הלכה".
"""
from __future__ import annotations
UMBRELLA = "עקרונות משפטיים"
CLASS_HALACHA = "halacha"
CLASS_INTERPRETIVE_RULE = "interpretive_rule"
CLASS_PRINCIPLE = "principle"
_LABEL = {
CLASS_HALACHA: "הלכה",
CLASS_INTERPRETIVE_RULE: "כלל פרשני",
CLASS_PRINCIPLE: "עיקרון",
}
def principle_class(source_kind: str | None, is_binding: bool | None) -> str:
"""Map a source to its principle class (stable key, not display text)."""
if source_kind == "internal_committee":
return CLASS_INTERPRETIVE_RULE
if is_binding:
return CLASS_HALACHA
return CLASS_PRINCIPLE
def label(source_kind: str | None, is_binding: bool | None) -> str:
"""Hebrew display term for a principle from this source (#152)."""
return _LABEL[principle_class(source_kind, is_binding)]
def label_for_class(cls: str) -> str:
return _LABEL.get(cls, _LABEL[CLASS_PRINCIPLE])