Files
roboco/tests/unit/runtime/test_self_heal_loop_dormant.py
T
Renn F a9064decb7 feat(self-heal): wire the dormant orchestrator loop
Register _self_heal_loop alongside the other background loops (created in
start, cancelled in stop). It returns immediately unless self_heal_enabled, so
a standard deployment adds zero behaviour and makes no CI call; when on it runs
one engine cycle per interval and commits any opened fix task. A test pins the
default-off dormancy (no sleep / CI / DB when disabled).
2026-06-17 21:03:27 +02:00

27 lines
937 B
Python

"""The self-heal orchestrator loop is fully dormant when disabled (the default).
With ``self_heal_enabled`` off, ``_self_heal_loop`` must return immediately —
no sleep, no CI call, no DB — so a standard deployment behaves exactly as today.
"""
from __future__ import annotations
import asyncio
import types
from typing import cast
import pytest
from roboco.config import settings as cfg
from roboco.runtime.orchestrator import AgentOrchestrator
@pytest.mark.asyncio
async def test_self_heal_loop_returns_immediately_when_disabled(
monkeypatch: pytest.MonkeyPatch,
) -> None:
monkeypatch.setattr(cfg, "self_heal_enabled", False)
stub = cast("AgentOrchestrator", types.SimpleNamespace(_running=True))
# Gated off → returns at once. If the gate were missing it would sleep the
# full interval and this wait_for would time out.
await asyncio.wait_for(AgentOrchestrator._self_heal_loop(stub), timeout=1.0)