"""Notifications and logging for orchestrator events.""" import logging logger = logging.getLogger("orchestrator") def notify_stage_change(task_id: int, old_stage: str, new_stage: str, agent: str = None): """Log stage transition.""" msg = f"Task {task_id}: {old_stage} → {new_stage}" if agent: msg += f" (launching {agent})" logger.info(msg) def notify_qg_failure(task_id: int, stage: str, check: str, reason: str): """Log QG check failure.""" logger.warning(f"Task {task_id}: QG failed at stage '{stage}', check={check}: {reason}") def notify_agent_finished(run_id: int, agent: str, exit_code: int): """Log agent completion.""" logger.info(f"Agent run {run_id} ({agent}) finished with exit code {exit_code}") def notify_error(task_id: int, error: str): """Log error for a task.""" logger.error(f"Task {task_id}: ERROR — {error}")