/ db / migrations / 112-gather-evidence-cron.sql
112-gather-evidence-cron.sql
 1  -- Migration 112: Move gather_evidence from inline orchestrator call to standalone cron job
 2  --
 3  -- Context: gather_evidence runs as a blocking inline call inside the orchestrator's
 4  -- process_all_batches(), stalling classify_replies, reply_responses, and outreach
 5  -- for 40-120s per cycle. Moving to a 5-minute cron job decouples it from the
 6  -- orchestrator loop while maintaining the same proposals gate (evidence_json IS NOT NULL).
 7  --
 8  -- The stage already has a CLI entry point (src/stages/gather-evidence.js) so it
 9  -- works directly as a command-type cron job.
10  
11  INSERT OR IGNORE INTO cron_jobs (
12      name, task_key, description, handler_type, handler_value,
13      interval_value, interval_unit, enabled, critical
14  ) VALUES (
15      '3.1 Gather Evidence',
16      'gatherEvidence',
17      'Two-pass evidence collection for enriched sites before proposal generation. Fetches live HTML + Haiku LLM per site. Runs independently of orchestrator.',
18      'command',
19      'node src/stages/gather-evidence.js',
20      5,
21      'minutes',
22      1,
23      0
24  );