feat(halacha-triage UI): wire gating + near-duplicate cluster cards (#84.2) #98

Merged
chaim merged 1 commits from worktree-task84.2-ui-clustering into main 2026-06-06 21:02:10 +00:00
Owner

מה ולמה

משלים את #84 — חושף ב-UI של היו"ר את הסינון/תיעדוף מהבקאנד (#84.1/#84.3, PR #93) ומוסיף קיבוץ near-duplicates (#84.2).

Backend

  • db.list_halachot מקבל cluster (#84.2): מוסיף cluster_id+cluster_size ע"י איחוד (union-find) הלכות מאותו פסק בתוך HALACHA_CLUSTER_COSINE (0.90, config חדש). תצוגה-בלבד — לא ממזג/מוחק. pairwise מוגבל לסט המוחזר (זול).
  • GET /api/halachot חושף את הפרמטר cluster (כבוי כברירת-מחדל).

Frontend (web-ui)

  • Halacha מקבל cluster_id/cluster_size אופציונליים (מודול ידני — אין צורך ב-api:types regen, הלכות לא מוקלדות מהסכמה האוטומטית).
  • useHalachotPending(opts): תור "נקי" (ברירת-מחדל) שולף exclude_low_quality+order_by_priority+cluster; needsFix:true מחזיר את בקט "דורש תיקון-חילוץ" (סינון client-side).
  • HalachaReviewPanel: טוגל "תור נקי / דורש תיקון-חילוץ" (#84.1); קלאסטרים של כפילויות-קרובות מתקפלים לכרטיס אחד עם "+N וריאנטים" הניתן להרחבה, ואישור/דחייה/דחייה-למועד על כרטיס מקובץ חלים על כל הוריאנטים דרך ה-batch (#84.2 + #84.4). הספירות מציגות סך-הלכות אמיתי. נוספו תוויות-דגל (application / near_duplicate / nevo_preamble_leak).

Invariants — הצהרה

  • נוגע / מקיים: G1 (סינון/קיבוץ במקור ב-SQL, לא post-hoc); G2 (אותה list_halachot); כלל-הנדסה §6 (פריט מסומן מנותב לבקט גלוי, לא נמחק).

אימות

  • Backend: list_halachot(cluster=True) על התור החי — האלגוריתם נכון (מקבץ כללים קרובים מאותו פסק ב-0.78; אין קלאסטרים ב-0.90 הייצורי כי dedup #82 כבר הסיר near-dups — המצב הרצוי).
  • Frontend: tsc --noEmit exit 0 (type-clean); אין lint errors חדשים (השגיאה היחידה קיימת מראש ב-training/learning-panel.tsx מ-#94). build מקומי של Turbopack לא רץ על symlink ה-node_modules של ה-worktree — CI בונה ב-checkout נקי.

🤖 Generated with Claude Code

## מה ולמה משלים את #84 — חושף ב-UI של היו"ר את הסינון/תיעדוף מהבקאנד (#84.1/#84.3, PR #93) ומוסיף קיבוץ near-duplicates (#84.2). **Backend** - `db.list_halachot` מקבל `cluster` (#84.2): מוסיף `cluster_id`+`cluster_size` ע"י איחוד (union-find) הלכות מאותו פסק בתוך `HALACHA_CLUSTER_COSINE` (0.90, config חדש). תצוגה-בלבד — לא ממזג/מוחק. pairwise מוגבל לסט המוחזר (זול). - `GET /api/halachot` חושף את הפרמטר `cluster` (כבוי כברירת-מחדל). **Frontend (web-ui)** - `Halacha` מקבל `cluster_id`/`cluster_size` אופציונליים (מודול ידני — **אין צורך ב-api:types regen**, הלכות לא מוקלדות מהסכמה האוטומטית). - `useHalachotPending(opts)`: תור "נקי" (ברירת-מחדל) שולף `exclude_low_quality`+`order_by_priority`+`cluster`; `needsFix:true` מחזיר את בקט "דורש תיקון-חילוץ" (סינון client-side). - `HalachaReviewPanel`: טוגל **"תור נקי / דורש תיקון-חילוץ"** (#84.1); קלאסטרים של כפילויות-קרובות מתקפלים ל**כרטיס אחד** עם **"+N וריאנטים"** הניתן להרחבה, ואישור/דחייה/דחייה-למועד על כרטיס מקובץ חלים על **כל** הוריאנטים דרך ה-batch (#84.2 + #84.4). הספירות מציגות סך-הלכות אמיתי. נוספו תוויות-דגל (application / near_duplicate / nevo_preamble_leak). ## Invariants — הצהרה - **נוגע / מקיים:** G1 (סינון/קיבוץ במקור ב-SQL, לא post-hoc); G2 (אותה `list_halachot`); כלל-הנדסה §6 (פריט מסומן מנותב לבקט גלוי, לא נמחק). ## אימות - **Backend:** `list_halachot(cluster=True)` על התור החי — האלגוריתם נכון (מקבץ כללים קרובים מאותו פסק ב-0.78; אין קלאסטרים ב-0.90 הייצורי כי dedup #82 כבר הסיר near-dups — המצב הרצוי). - **Frontend:** `tsc --noEmit` exit 0 (type-clean); אין lint errors חדשים (השגיאה היחידה קיימת מראש ב-`training/learning-panel.tsx` מ-#94). build מקומי של Turbopack לא רץ על symlink ה-node_modules של ה-worktree — CI בונה ב-checkout נקי. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
chaim added 1 commit 2026-06-06 21:02:00 +00:00
Completes #84 — surfaces the backend gating/prioritization (#84.1/#84.3, PR
#93) in the chair's review UI and adds near-duplicate clustering (#84.2).

Backend
- db.list_halachot gains `cluster` (#84.2): annotates each row with cluster_id +
  cluster_size by unioning same-precedent halachot within HALACHA_CLUSTER_COSINE
  (0.90, new config). Display-only — never merges/deletes. Pairwise is confined
  to the returned set (cheap).
- GET /api/halachot exposes the `cluster` query param (default off).

Frontend (web-ui)
- Halacha type gains optional cluster_id / cluster_size (hand-written module; no
  api:types regen needed — halachot aren't typed off the generated schema).
- useHalachotPending(opts): the default "clean" queue now fetches
  exclude_low_quality + order_by_priority + cluster; needsFix:true returns the
  flagged 'needs extraction fix' bucket (filtered client-side).
- HalachaReviewPanel: a "תור נקי / דורש תיקון-חילוץ" toggle (#84.1); near-dup
  clusters collapse into ONE card showing "+N וריאנטים" with an expandable list,
  and approve/reject/defer on a clustered card applies to all variants via the
  batch endpoint (#84.2 + #84.4). Counts show true halacha totals (pendingTotal).
  New flag labels added (application / near_duplicate / nevo_preamble_leak).

Verified:
- backend: list_halachot(cluster=True) on the live queue — algorithm correct
  (groups related same-precedent rules at 0.78; none at the production 0.90
  because dedup #82 already removed near-dups — the desired state).
- frontend: `tsc --noEmit` exits 0 (type-clean); no new lint errors (the one
  lint error is pre-existing in training/learning-panel.tsx from #94). Local
  Turbopack build can't run on the worktree node_modules symlink — CI builds in
  a clean checkout.

Invariants: G1 (gate/cluster at source in SQL, not post-hoc); G2 (same
list_halachot path); §6 (flagged items routed to a visible bucket, not dropped).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
chaim merged commit 25e0662ead into main 2026-06-06 21:02:10 +00:00
chaim deleted branch worktree-task84.2-ui-clustering 2026-06-06 21:02:10 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ezer-mishpati/legal-ai#98