From 532bef04a7a60f655e115a3740134e00f18a05d1 Mon Sep 17 00:00:00 2001 From: Chaim Date: Fri, 19 Jun 2026 10:09:14 +0000 Subject: [PATCH] fix(halacha-queue): only true defects go to 'needs re-extraction', not all flags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The pending review queue split items into 'להכרעתך' (chair judgment) vs 'דורש תיקון-חילוץ' (needs re-extraction) by a too-blunt predicate: ANY quality flag + no panel round → re-extraction. That misfiled fact-specific 'application' items (extraction is fine; the open question is whether the rule generalizes) as extraction defects, contradicting the backend, which treats only quote_unverified/truncated_quote/thin_restatement/near_duplicate as defects and routes 'application' to chair judgment. Now isExtractionFixItem checks the backend's DEFECT set, so 'application' (and any other non-defect flag) lands in 'להכרעתך'. For 8508-03-24 this moves 21 application items judgment→correct and leaves 6 thin_restatement as the only re-extraction items. Logic-only fix (predicate), no visual change — design-gate exempt per web-ui/AGENTS.md. tsc + eslint clean. Co-Authored-By: Claude Opus 4.8 (1M context) --- web-ui/src/lib/api/precedent-library.ts | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/web-ui/src/lib/api/precedent-library.ts b/web-ui/src/lib/api/precedent-library.ts index 9e0c723..50f4720 100644 --- a/web-ui/src/lib/api/precedent-library.ts +++ b/web-ui/src/lib/api/precedent-library.ts @@ -646,11 +646,26 @@ export function useHalachotPending(opts: { limit?: number; search?: string } = { }); } +/** Genuine extraction defects — the rule TEXT is malformed, so it needs re-extraction + * (not a chair keep/drop judgment). Mirrors the backend's DEFECT set in + * scripts/halacha_panel_approve.py; other flags (e.g. `application` = fact-specific + * application) are judgment signals, NOT defects, and the panel deliberately skips them. */ +const EXTRACTION_DEFECT_FLAGS = new Set([ + "quote_unverified", + "truncated_quote", + "thin_restatement", + "near_duplicate", +]); + /** A pending item belongs in the "needs extraction fix" segment when it carries a - * quality flag AND the panel never deliberated it (no round). Everything else — - * deliberated items and clean items — is a chair-judgment item. (#133 unified queue) */ + * genuine extraction-DEFECT flag AND the panel never deliberated it (no round). + * Everything else — deliberated items, clean items, and items flagged only for + * chair judgment (e.g. `application`) — is a chair-judgment item. (#133 unified queue) */ export function isExtractionFixItem(h: Halacha): boolean { - return !h.panel_round && (h.quality_flags?.length ?? 0) > 0; + return ( + !h.panel_round && + (h.quality_flags ?? []).some((f) => EXTRACTION_DEFECT_FLAGS.has(f)) + ); } export function useHalachotByStatus(status: string, limit = 300) {