From 75f40cc77850a133b790cd3bc500907eaad04536 Mon Sep 17 00:00:00 2001 From: Chaim Date: Fri, 19 Jun 2026 05:37:07 +0000 Subject: [PATCH] =?UTF-8?q?feat(halachot):=20Phase=206=20=E2=80=94=20depre?= =?UTF-8?q?cate=20equivalent=5Fhalachot=20writes=20post-V41?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - halacha_batch_reconcile.py --link now exits with error (V41 freezes equivalent_halachot; equivalences live in canonical_id instead) - link_equivalent_halachot emits DeprecationWarning (callers ≥ Python 3.2) - SCRIPTS.md already marks --link as deprecated; no further doc change needed Co-Authored-By: Claude Sonnet 4.6 --- mcp-server/src/legal_mcp/services/db.py | 16 ++++++++++--- scripts/halacha_batch_reconcile.py | 30 ++++++++++++------------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/mcp-server/src/legal_mcp/services/db.py b/mcp-server/src/legal_mcp/services/db.py index 4543fe4..e86248d 100644 --- a/mcp-server/src/legal_mcp/services/db.py +++ b/mcp-server/src/legal_mcp/services/db.py @@ -5936,11 +5936,21 @@ def _equiv_order(a: UUID, b: UUID) -> tuple[UUID, UUID]: async def link_equivalent_halachot( a: UUID, b: UUID, *, cosine: float = 0.0, note: str = "", created_by: str = "", ) -> bool: - """Record that two halachot (different precedents) state the same principle. + """[DEPRECATED since V41] Record a parallel-authority link in equivalent_halachot. + + The canonical_halachot model (V41) supersedes this table — cross-precedent + equivalence is now expressed via halachot.canonical_id. This function is kept + for historical callers only; no new code should call it. Use + ``create_canonical_halacha`` + ``nearest_canonical_halacha`` instead. Idempotent (symmetric UNIQUE). Returns False and does nothing if a == b or - the two belong to the SAME precedent (parallel authority is cross-precedent - by definition; within-precedent sameness is the dedup/cluster concern).""" + the two belong to the SAME precedent.""" + import warnings + warnings.warn( + "link_equivalent_halachot is deprecated since V41 (canonical_halachot). " + "Use create_canonical_halacha / nearest_canonical_halacha instead.", + DeprecationWarning, stacklevel=2, + ) if a == b: return False pool = await get_pool() diff --git a/scripts/halacha_batch_reconcile.py b/scripts/halacha_batch_reconcile.py index 31313f2..4a9fd4e 100644 --- a/scripts/halacha_batch_reconcile.py +++ b/scripts/halacha_batch_reconcile.py @@ -93,20 +93,20 @@ async def main(args: argparse.Namespace) -> int: w.writerows(pairs) print(f"\nreport: {out}", flush=True) - if args.link and pairs: - # #84.2 — record each pair as parallel authority (equivalent_halachot). - # Non-destructive: links only, never merges/deletes. Idempotent. - linked = 0 - for p in pairs: - if await db.link_equivalent_halachot( - p["id_a"], p["id_b"], cosine=p["cosine"], - note="cross-precedent parallel authority (halacha_batch_reconcile)", - created_by="batch_reconcile", - ): - linked += 1 - print(f"linked {linked}/{len(pairs)} pairs as equivalent_halachot", flush=True) - elif pairs: - print("(review-only — pass --link to record them as equivalent_halachot)", flush=True) + if args.link: + # V41 (canonical_halachot): equivalent_halachot is FROZEN — no new links. + # Use backfill_canonical_halachot.py --apply instead. + print( + "\nERROR: --link is deprecated since V41 (canonical_halachot model).\n" + " equivalent_halachot is read-only and frozen post-backfill.\n" + " Cross-precedent dedup is now handled by the canonical model:\n" + " mcp-server/.venv/bin/python scripts/backfill_canonical_halachot.py --apply\n" + " Exiting without writing any links.", + flush=True, + ) + return 1 + if pairs: + print("(review-only — pair report saved above)", flush=True) return 0 @@ -118,6 +118,6 @@ if __name__ == "__main__": ap.add_argument("--include-pending", action="store_true", help="also scan pending_review halachot (default: approved/published only)") ap.add_argument("--link", action="store_true", - help="record found pairs as equivalent_halachot (parallel authority, #84.2)") + help="[DEPRECATED since V41] refused at runtime — use backfill_canonical_halachot.py") args = ap.parse_args() sys.exit(asyncio.run(main(args)))