fix(halacha): re-extraction preserves chair-approved halachot (INV-G10, #108)
תיקון data-loss: reset_halacha_extraction ביצע DELETE ללא-תנאי לפני חילוץ-מחדש;
קריסה בין המחיקה לאחסון הראשון מחקה את כל אישורי-היו"ר והשאירה את הרשומה תקועה
status='processing' עם 0 שורות (תקרית עמיאל 8126-03-25, 2026-06-08).
עכשיו המחיקה מחריגה review_status IN ('approved','published') — אישור אנושי לא
נמחק בשקט (INV-G10). ה-dedup-on-insert של store_halachot_for_chunk מדלג על חילוץ
טרי שמשכפל מאושרת שנשמרה, כך שאין כפילות. reset מחזיר {deleted, preserved},
וה-extractor מתעד כמה מאושרות נשמרו (provenance, G9).
עמידות מלאה מול מוות-תהליך (OOM) נשארת ל-X16/#114 (durable resume) — זה תנאי-מקדים.
בדיקה: test_halacha_reextract_preserves_approved.py (offline SQL-capture) מאמת
שה-DELETE מחריג approved/published; 64 בדיקות-הלכה קיימות עוברות.
Invariants: G10 (שער-יו"ר — אישור לא נמחק), G1 (תיקון במקור), G9 (provenance).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -138,6 +138,10 @@ async def reextract_halachot(
|
||||
) -> dict:
|
||||
"""Re-run the halacha extractor on an existing precedent. Idempotent.
|
||||
|
||||
Chair-approved / published halachot are PRESERVED across the re-extract
|
||||
(INV-G10) — only un-reviewed rows are replaced. See
|
||||
``db.reset_halacha_extraction`` / TaskMaster #108.
|
||||
|
||||
**MCP-tool-only path.** This function calls into ``halacha_extractor``,
|
||||
which calls ``claude_session`` — the local CLI is required. Invoking
|
||||
this from the FastAPI container will raise ``Claude CLI not found``.
|
||||
@@ -157,9 +161,10 @@ async def reextract_halachot(
|
||||
# bad data. See note in db.request_metadata_extraction.
|
||||
|
||||
await progress("extracting_halachot", 50, "מחלץ הלכות מחדש")
|
||||
# Explicit re-extraction = clean slate (force): wipe prior halachot +
|
||||
# per-chunk checkpoints and redo all. (Queue draining / resume uses the
|
||||
# default force=False so an interrupted run continues where it stopped.)
|
||||
# Explicit re-extraction = clean slate (force): drop un-reviewed halachot +
|
||||
# clear per-chunk checkpoints and redo all, but PRESERVE chair-approved /
|
||||
# published rows (INV-G10; dedup-on-insert avoids duplicating them). (Queue
|
||||
# draining / resume uses force=False so an interrupted run continues.)
|
||||
result = await halacha_extractor.extract(case_law_id, force=True)
|
||||
# Clear the queue timestamp on completion so the UI badge / worker queue
|
||||
# don't keep showing this row. The queue worker (process_pending_extractions)
|
||||
|
||||
Reference in New Issue
Block a user