/** * pm2 ecosystem entry for legal-halacha-drain — scheduled drain of the precedent * halacha-extraction queue. Halacha extraction stays on claude_session (local * CLI, high reasoning quality for holding/ratio) — unlike metadata which moved * to Gemini. Extracted halachot land 'pending_review' for the chair's approval * gate (INV-G10); this drainer only produces them, it never approves. * * The drain self-heals orphaned 'processing' rows (precedent_library) and is * serialised by a global advisory lock, so overlapping ticks are safe. * * Pattern: cron_restart fires the script; autorestart:false → one-shot per tick * (pm2 shows "stopped" between ticks). Cheap no-op when the queue is empty. * Cadence is conservative (every 2h) because Claude extraction is slow/rate- * limited and each run adds to the chair's review queue. * * Requires the local ``claude`` CLI + host ~/.env (POSTGRES_URL, etc.). * * Install (once): * pm2 start /home/chaim/legal-ai/scripts/legal-halacha-drain.config.cjs * pm2 save * Run now (manual): mcp-server/.venv/bin/python scripts/drain_halacha_queue.py * Schedule override: HALACHA_DRAIN_CRON (default every 2 hours at :47). */ const cron = process.env.HALACHA_DRAIN_CRON || "47 */2 * * *"; module.exports = { apps: [ { name: "legal-halacha-drain", cwd: "/home/chaim/legal-ai", script: "/home/chaim/legal-ai/mcp-server/.venv/bin/python", args: "scripts/drain_halacha_queue.py", env: { HOME: "/home/chaim", PYTHONUNBUFFERED: "1" }, autorestart: false, // one-shot per cron tick cron_restart: cron, max_memory_restart: "800M", }, ], };