CREATE INDEX IF NOT EXISTS task_attempts_running_idx
  ON task_attempts (task_id, phase, status, started_at DESC);

CREATE INDEX IF NOT EXISTS tasks_parse_lease_idx
  ON tasks (status, lease_expires_at)
  WHERE status = 'parse_running';
