fix(operations): disabling the halacha drain stops a running process immediately #241

Merged
chaim merged 1 commits from worktree-drain-disable-stop into main 2026-06-13 09:03:33 +00:00
Owner

הבעיה

הטוגל disabled ב-/operations כתב רק את drain_controls.disabled — דגל שהדריינר בודק רק בעלייה. דריינר שכבר באמצע ריצה המשיך עד שהתור התרוקן או עד שחלון-הלילה נסגר. כיבוי לא עצר דריינר רץ.

התיקון — 3 שכבות (מיידי + גיבויים)

  1. web/app.py (operations_drain_toggle): בעת כיבוי, עוצר גם את התהליך הרץ מיד דרך ה-pm2 bridge של ה-host (_ops_pm2_control). best-effort — כשל-bridge לא מפיל את הטוגל.
  2. halacha_drain_supervisor.py: כל טיק קורא את דגל-הכיבוי (נוסף ל-db_snapshot); כשכבוי → עוצר את הדריינר ולא מצית, ללא תלות ב-burst/חלון. גיבוי אם מסלול ה-UI נכשל (≤ טיק אחד).
  3. drain_halacha_queue.py: בדיקת is_drain_disabled בתחילת כל סבב → דריינר שכובה באמצע נעצר בגבול-הסבב הבא. per-chunk checkpoints = התיק שבעיבוד לא מאבד כלום.

SCRIPTS.md עודכן לדריינר ולסופרוייזר.

אימות

  • בדיקות חיות בוצעו לפני התיקון: skip מחוץ-לחלון ✓, שער-כיבוי-בעלייה ✓, bridge /pm2/control קיים+עובד.
  • שלושת הקבצים עוברים ast.parse.
  • בדיקה-בפועל מלאה תתבצע אחרי deploy + עדכון סקריפטי-ה-host.

Invariants

  • G1 — שליטת-הכיבוי מכובדת בכל מסלול (לא רק בעלייה).
  • G2 — אותו דגל drain_controls, בלי מסלול-בקרה מקביל.

🤖 Generated with Claude Code

## הבעיה הטוגל `disabled` ב-`/operations` כתב רק את `drain_controls.disabled` — דגל שהדריינר בודק **רק בעלייה**. דריינר שכבר באמצע ריצה המשיך עד שהתור התרוקן או עד שחלון-הלילה נסגר. **כיבוי לא עצר דריינר רץ.** ## התיקון — 3 שכבות (מיידי + גיבויים) 1. **`web/app.py` (`operations_drain_toggle`):** בעת כיבוי, עוצר גם את התהליך הרץ **מיד** דרך ה-pm2 bridge של ה-host (`_ops_pm2_control`). best-effort — כשל-bridge לא מפיל את הטוגל. 2. **`halacha_drain_supervisor.py`:** כל טיק קורא את דגל-הכיבוי (נוסף ל-`db_snapshot`); כשכבוי → עוצר את הדריינר ולא מצית, ללא תלות ב-burst/חלון. גיבוי אם מסלול ה-UI נכשל (≤ טיק אחד). 3. **`drain_halacha_queue.py`:** בדיקת `is_drain_disabled` בתחילת **כל סבב** → דריינר שכובה באמצע נעצר בגבול-הסבב הבא. per-chunk checkpoints = התיק שבעיבוד לא מאבד כלום. `SCRIPTS.md` עודכן לדריינר ולסופרוייזר. ## אימות - בדיקות חיות בוצעו לפני התיקון: skip מחוץ-לחלון ✓, שער-כיבוי-בעלייה ✓, bridge `/pm2/control` קיים+עובד. - שלושת הקבצים עוברים `ast.parse`. - בדיקה-בפועל מלאה תתבצע אחרי deploy + עדכון סקריפטי-ה-host. ## Invariants - **G1** — שליטת-הכיבוי מכובדת בכל מסלול (לא רק בעלייה). - **G2** — אותו דגל `drain_controls`, בלי מסלול-בקרה מקביל. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
chaim added 1 commit 2026-06-13 09:03:28 +00:00
fix(operations): disabling the halacha drain now stops a running process immediately
All checks were successful
G12 Leak-Guard / leak-guard (pull_request) Successful in 6s
a44827c3dd
The /operations "disabled" toggle only wrote drain_controls.disabled, which the
drain checks at STARTUP — so a drain already mid-run kept going until the queue
emptied or the night window closed. Disabling did not stop a running drain.

Three layers, immediate + backstops:
- web/app.py operations_drain_toggle: on disable, also stop the running process
  immediately via the host pm2 bridge (_ops_pm2_control). Best-effort — a bridge
  failure doesn't fail the toggle.
- halacha_drain_supervisor.py: each tick now reads the disabled flag (added to
  db_snapshot) and, when set, stops the drain and never re-triggers it —
  regardless of burst/window. Backstop if the UI path failed (≤ one tick).
- drain_halacha_queue.py: re-check is_drain_disabled at the top of every round,
  so a drain disabled mid-run halts at the next round boundary. Per-chunk
  checkpoints mean the in-flight case loses nothing.

SCRIPTS.md updated for both drain and supervisor.

Invariants: G1 (fix at source — the disable control honoured along every path,
not just at startup); G2 (no parallel control path — same drain_controls flag).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
chaim merged commit 96a1144f43 into main 2026-06-13 09:03:33 +00:00
chaim deleted branch worktree-drain-disable-stop 2026-06-13 09:03:33 +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#241