fix(halacha): rate-limit refusal ≠ empty answer — לא checkpoint chunk בכשל (#144)
תיקון-ליבה (b): כש-claude CLI מחזיר exit=0 עם הודעת-מגבלה/שגיאה כ-result, query זיהה אותה כהצלחה → _extract_chunk קיבל []/non-list וסימן chunk כ-done-ריק; resume דילג עליו לתמיד → תת-חילוץ קבוע (3→1→0). עכשיו is_error/_looks_like_limit_notice הופכים אותה לכשל-חולף → retry → raise → chunk נשאר un-checkpointed → resume משחזר (כך force-delete כבר לא הרסני-לצמיתות). + churn-detect במתזמר (Δdone<0 / Δhal<-2 → אזהרה+churn_ok ב-JSON). + scripts/reconcile_under_extracted_halacha.py — שחזור completed-עם-0-הלכות-ו≥3 מקטעי-נימוק (dry-run הראה 15 מועמדים); נתיב-הזמנה קנוני (G2), שמרני (לא remand). הערה: אטומיות-מלאה (staging_run_id) נדחתה — PR #257 מיתן את ה-trigger, ו-(b)+resume מונעים אובדן-קבוע (force-delete מתאושש דרך resume). בדיקות: test_claude_session_limit_notice. כל 354 עוברות. guards נקיים. Invariants: G1, INV-G3/X16 (checkpoint=הושלם-באמת), INV-G4 (churn לא-שקט), G12. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -527,6 +527,16 @@ def tick():
|
||||
if not staging_ok:
|
||||
notes.append("⚠️ תיקים הושלמו אך checkpoints לא התקדמו — לבדוק staging.")
|
||||
|
||||
# Churn guard (#144): a precedent regressing completed→pending (Δdone<0) or a
|
||||
# net loss of halachot beyond consolidation noise (Δhal<-2) means a re-extract
|
||||
# is DEGRADING the corpus (the 3→1 incident). Surface it loudly — never silent.
|
||||
churn_ok = not (d_done < 0 or d_hal < -2)
|
||||
if not churn_ok:
|
||||
notes.append(
|
||||
f"⚠️ churn: Δהלכות={d_hal} Δתיקים={d_done} — חילוץ-מחדש מדרדר "
|
||||
"(completed→pending / אובדן-הלכות); לבדוק לפני המשך."
|
||||
)
|
||||
|
||||
if mode in ("ratelimited", "weekly_exhausted") and cd_dt:
|
||||
next_wake = max(300, min(int((cd_dt - now).total_seconds()) + 180, 3600))
|
||||
elif mode in ("done", "idle_off_window"):
|
||||
@@ -562,7 +572,8 @@ def tick():
|
||||
"halachot_total": hal, "checkpointed_chunks": ck,
|
||||
"delta_halachot": d_hal, "delta_checkpoints": d_ck, "delta_done": d_done,
|
||||
"pm2": status, "progress_age_sec": int(progress_age),
|
||||
"staging_ok": staging_ok, "rate_limited": in_cooldown, "cooldown_until": cooldown_until,
|
||||
"staging_ok": staging_ok, "churn_ok": churn_ok,
|
||||
"rate_limited": in_cooldown, "cooldown_until": cooldown_until,
|
||||
}, ensure_ascii=False))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user