feat(halachot): canonical lookup-before-insert + MCP tools (Phase 3+4, V41)
All checks were successful
G12 Leak-Guard / leak-guard (pull_request) Successful in 4s
Lint — undefined names / undefined-names (pull_request) Successful in 10s

store_halachot_for_chunk: לפני כל INSERT — חיפוש cosine ב-canonical_halachot (≥0.85).
  עיקרון קיים → instance_type='citation' (אין canonical חדש).
  עיקרון חדש → instance_type='original' + יצירת canonical אוטומטית + עדכון instance_count.

config: HALACHA_CANONICAL_LOOKUP_ENABLED=true, HALACHA_CANONICAL_THRESHOLD=0.85.

db.list_halachot: פרמטר instance_type חדש לסינון.
db.list_canonical_halachot: שאילתת רשימה לפי practice_area/status.
db.update_canonical_statement: עדכון ניסוח קנוני ע"י היו"ר.

tools/precedent_library.py:
  halachot_pending: ברירת-מחדל instance_type='original' (תור ריאלי).
  halacha_review: פרמטר canonical_statement חדש (עריכת ניסוח העיקרון).
  canonical_halacha_list: כלי MCP חדש — רשימת עקרונות קנוניים.
  canonical_halacha_get: כלי MCP חדש — עיקרון + אינסטנסים.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-17 17:36:09 +00:00
parent aba87737e3
commit 7c39c685e5
4 changed files with 203 additions and 10 deletions

View File

@@ -205,6 +205,11 @@ HALACHA_CONSOLIDATE_ENABLED = os.environ.get("HALACHA_CONSOLIDATE_ENABLED", "tru
HALACHA_CONSOLIDATE_MODEL = os.environ.get("HALACHA_CONSOLIDATE_MODEL", HALACHA_EXTRACT_MODEL)
HALACHA_CONSOLIDATE_EFFORT = os.environ.get("HALACHA_CONSOLIDATE_EFFORT", "high")
# V41 canonical lookup-before-insert: cosine gate for reusing an existing canonical
# instead of creating a new one. 0.85 is tuned to the embedding space (1024-dim voyage).
HALACHA_CANONICAL_LOOKUP_ENABLED = os.environ.get("HALACHA_CANONICAL_LOOKUP_ENABLED", "true").lower() == "true"
HALACHA_CANONICAL_THRESHOLD = float(os.environ.get("HALACHA_CANONICAL_THRESHOLD", "0.85"))
# Google Cloud Vision (OCR for scanned PDFs)
GOOGLE_CLOUD_VISION_API_KEY = os.environ.get("GOOGLE_CLOUD_VISION_API_KEY", "")