feat(halacha-triage): quality-gated + prioritized review queue + metrics (#84) #93

Merged
chaim merged 1 commits from worktree-task84-halacha-triage into main 2026-06-06 20:01:28 +00:00
Owner

מה ולמה

Backend לטריאז' תור-אישור ההלכות (#84). ה-UI מונע-המקלדת, פעולות-batch, ו-defer/reject (#84.4–6) כבר נפרסו; כאן מתווספים הסינון, התיעדוף והמדדים שחסרו.

db.list_halachot — שני בקרי-טריאז' opt-in:

  • exclude_low_quality (#84.1): מסיר פריטים עם דגל-איכות כלשהו (application / quote_unverified / truncated / non_decision / thin / nli_unsupported / near_duplicate) — שייכים ל'דורש תיקון-חילוץ', לא לתור-האישור.
  • order_by_priority (#84.3): סדר active-learning — טופלו-לרעה תחילה, אז הכי לא-ודאיים (confidence נמוך), אז ישנים — במקום FIFO.

halachot_pending (MCP) — כעת מסונן+ממוין כברירת-מחדל; include_low_quality=true חושף את בקט ה'תיקון'. מסלול-הסוכן נהנה מיידית.

GET /api/halachot — אותם שני params, ברירת-מחדל כבויה (לא-שובר; ה-UI מצטרף ב-opt-in).

metrics.halacha_backlog (#84.7) — מפצל pending ל-clean מול flagged, מוסיף deferred / reviewed_total / approve_ratio / pending_by_flag — כך שה-backlog מבחין בין עבודת-סקירה אמיתית לרעש-חילוץ.

נדחה (מתועד)

  • #84.2 (cluster cards של near-duplicates) + חיווט ה-UI ל-params החדשים דורשים עבודת-frontend + npm run api:types regen אחרי שזה נפרס (ה-params החדשים לא ב-OpenASPI של prod עד אז) — follow-up נקי. ה-backend תומך בשניהם כבר עכשיו.

Invariants — הצהרה

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

אימות (מול ה-DB החי, read-only)

  • pending 177 → gated-clean 110, 0 פריטים מסומנים דלפו לתור הנקי.
  • סדר-עדיפות מציג קודם את ה-confidence הנמוך ביותר (0.55, 0.55, ...).
  • backlog: pending_clean=110 / pending_flagged=67 / approve_ratio=0.916, pending_by_flag={nli_unsupported:59, quote_unverified:3, thin:3, truncated:2}.
  • pytest tests/test_halacha_quality.py — 52 passed (ללא רגרסיה).

🤖 Generated with Claude Code

## מה ולמה Backend לטריאז' תור-אישור ההלכות (#84). ה-UI מונע-המקלדת, פעולות-batch, ו-defer/reject (#84.4–6) כבר נפרסו; כאן מתווספים הסינון, התיעדוף והמדדים שחסרו. **db.list_halachot** — שני בקרי-טריאז' opt-in: - `exclude_low_quality` (**#84.1**): מסיר פריטים עם דגל-איכות כלשהו (application / quote_unverified / truncated / non_decision / thin / nli_unsupported / near_duplicate) — שייכים ל'דורש תיקון-חילוץ', לא לתור-האישור. - `order_by_priority` (**#84.3**): סדר active-learning — טופלו-לרעה תחילה, אז הכי לא-ודאיים (confidence נמוך), אז ישנים — במקום FIFO. **halachot_pending (MCP)** — כעת מסונן+ממוין **כברירת-מחדל**; `include_low_quality=true` חושף את בקט ה'תיקון'. מסלול-הסוכן נהנה מיידית. **GET /api/halachot** — אותם שני params, ברירת-מחדל **כבויה** (לא-שובר; ה-UI מצטרף ב-opt-in). **metrics.halacha_backlog (#84.7)** — מפצל pending ל-clean מול flagged, מוסיף deferred / reviewed_total / approve_ratio / pending_by_flag — כך שה-backlog מבחין בין עבודת-סקירה אמיתית לרעש-חילוץ. ## נדחה (מתועד) - **#84.2** (cluster cards של near-duplicates) + חיווט ה-UI ל-params החדשים דורשים עבודת-frontend + `npm run api:types` regen **אחרי** שזה נפרס (ה-params החדשים לא ב-OpenASPI של prod עד אז) — follow-up נקי. ה-backend תומך בשניהם כבר עכשיו. ## Invariants — הצהרה - **נוגע / מקיים:** G1 (סינון-במקור — SQL filter, לא post-hoc); G2 (אין מסלול מקביל — אותה `list_halachot`); כלל-הנדסה §6 (פריט מסומן מנותב לבקט, לא נמחק). ## אימות (מול ה-DB החי, read-only) - pending 177 → gated-clean **110**, **0** פריטים מסומנים דלפו לתור הנקי. - סדר-עדיפות מציג קודם את ה-confidence הנמוך ביותר (0.55, 0.55, ...). - backlog: pending_clean=110 / pending_flagged=67 / approve_ratio=0.916, pending_by_flag={nli_unsupported:59, quote_unverified:3, thin:3, truncated:2}. - `pytest tests/test_halacha_quality.py` — 52 passed (ללא רגרסיה). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
chaim added 1 commit 2026-06-06 20:01:21 +00:00
Backend for the halacha approval-queue triage (#84). The keyboard UI, batch
actions and defer/reject (#84.4–6) already shipped; this adds the gating,
prioritization and metrics the queue was missing.

db.list_halachot — two opt-in triage controls:
  * exclude_low_quality (#84.1): drop items carrying ANY quality_flag
    (application / quote_unverified / truncated / non_decision / thin /
    nli_unsupported / near_duplicate) — they belong in a 'needs extraction fix'
    bucket, not the chair's approve queue.
  * order_by_priority (#84.3): active-learning order — negatively-treated
    first, then most-uncertain (lowest confidence), then oldest — instead of
    FIFO, so the highest-value decisions surface first.

halachot_pending (MCP) — now gated + prioritized BY DEFAULT; include_low_quality=
true reveals the needs-fix bucket. The agent review path benefits immediately.

GET /api/halachot — same two params, default OFF (non-breaking; the UI opts in).

metrics.halacha_backlog (#84.7) — splits pending into clean vs flagged, adds
deferred, reviewed_total, approve_ratio, and a pending_by_flag breakdown, so the
backlog distinguishes real review work from extraction noise.

Deferred (documented): #84.2 near-duplicate cluster cards and wiring the UI
fetch to the new params require frontend work + an api:types regen AFTER this
deploys (the new query params aren't in prod's OpenAPI until then) — a clean
follow-up. The backend fully supports both now.

Verified against the live DB (read-only):
- pending 177 → gated-clean 110, 0 flagged items leak into the clean queue.
- priority order surfaces the lowest-confidence items first (0.55, 0.55, ...).
- backlog: pending_clean=110 / pending_flagged=67 / approve_ratio=0.916,
  pending_by_flag={nli_unsupported:59, quote_unverified:3, thin:3, truncated:2}.
- pytest tests/test_halacha_quality.py — 52 passed (no regression).

Invariants: G1 (gate at source — SQL filter, not post-hoc); G2 (no parallel
path — same list_halachot); §6 (flagged items routed to a bucket, never dropped).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
chaim merged commit 85c5a4aacb into main 2026-06-06 20:01:28 +00:00
chaim deleted branch worktree-task84-halacha-triage 2026-06-06 20:01:28 +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#93