mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
* feat(release): add release-manager feature flag (default off) * feat(release): change classification + semver-bump derivation * feat(release): readiness audit (changelog/version-ref/docs/migration/gate) * feat(release): release-manager engine proposes a gated release * feat(release): fail-closed release executor (bump, gate, publish) * feat(release): CEO approve/reject release-proposal surface * docs(release): document the gated release manager * feat(memory): add org-memory feature flags (default off) * feat(memory): add playbooks table + status enum + migration * feat(memory): playbook service with auditor curation transitions * feat(memory): playbooks RAG index plugin * feat(memory): index a playbook into RAG on approval * feat(memory): distill a high-signal lesson at task completion * feat(memory): keep private journal reflections out of the shared RAG corpus * feat(memory): draft_playbook verb + auditor curation verbs * fix(ci): resolve mypy tests/ errors blocking the gate (UUID casts, annotations) * feat(memory): auto-inject similar lessons/playbooks into the briefing * feat(memory): auditor playbook review queue (api + panel) * docs(memory): document the org-memory loop + playbook verbs * fix(provisioning): idempotent pitch provisioning (reuse product/project by slug on re-approval) * fix(memory): add chunks_playbooks to the chunk schema + isolate release route tests - Migration 030's CHUNK_TABLES was missing chunks_playbooks, breaking the IndexType<->migration parity guard once the PLAYBOOKS index landed. The upgrade is ALTER ... IF EXISTS so adding it is safe on any DB shape. - The release-route fixture's approve/reject paths call db.commit() (real behavior), so a held proposal outlived the per-test rollback and leaked into engine tests that read the global list_open_release_proposals(). Tear down source=release_manager rows after each test. - Make the gather_snapshot real-repo smoke version-agnostic (semver match) so it stops pinning the literal repo version. * chore(release): 0.13.0 * ++ --------- Co-authored-by: Renn F <rennf93@users.noreply.github.com>
88 lines
3.0 KiB
Python
88 lines
3.0 KiB
Python
"""The orchestrator CI-watch loop: dormant when off, runs the engine when on.
|
|
|
|
Dormant unless ``ci_watch_enabled``; loads the watch set (opted-in projects, one
|
|
per repo), warns when enabled-but-empty, and runs CiWatchEngine.run_cycle each
|
|
interval. Separate from the single-repo self-heal loop.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from contextlib import asynccontextmanager
|
|
from typing import Any
|
|
from unittest.mock import AsyncMock, MagicMock, patch
|
|
|
|
import pytest
|
|
from roboco.config import settings
|
|
from roboco.runtime.orchestrator import AgentOrchestrator
|
|
|
|
|
|
def _orch() -> AgentOrchestrator:
|
|
return AgentOrchestrator.__new__(AgentOrchestrator)
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_loop_noop_when_disabled(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
monkeypatch.setattr(settings, "ci_watch_enabled", False)
|
|
orch = _orch()
|
|
cycle = AsyncMock()
|
|
orch._run_ci_watch_cycle = cycle # type: ignore[method-assign]
|
|
await orch._ci_watch_loop() # must return immediately, no infinite loop
|
|
cycle.assert_not_awaited()
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_load_watch_set_filters_enabled_one_per_repo() -> None:
|
|
orch = _orch()
|
|
on_a = MagicMock(slug="be", git_url="https://x/a.git", ci_watch_enabled=True)
|
|
on_a2 = MagicMock(slug="fe", git_url="https://x/a.git", ci_watch_enabled=True)
|
|
off = MagicMock(slug="c", git_url="https://x/c.git", ci_watch_enabled=False)
|
|
svc = MagicMock()
|
|
svc.list_all = AsyncMock(return_value=[on_a, on_a2, off])
|
|
with patch("roboco.services.project.get_project_service", return_value=svc):
|
|
watch = await orch._load_ci_watch_set(MagicMock())
|
|
assert len(watch) == 1 # opt-out excluded; same-repo cell-projects collapsed
|
|
assert watch[0].git_url == "https://x/a.git"
|
|
|
|
|
|
def _db_ctx(db: Any) -> Any:
|
|
@asynccontextmanager
|
|
async def _ctx() -> Any:
|
|
yield db
|
|
|
|
return _ctx
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_cycle_warns_and_skips_engine_when_empty() -> None:
|
|
orch = _orch()
|
|
orch._load_ci_watch_set = AsyncMock(return_value=[]) # type: ignore[method-assign]
|
|
get_eng = MagicMock()
|
|
with (
|
|
patch("roboco.db.get_db_context", _db_ctx(MagicMock())),
|
|
patch("roboco.services.ci_watch_engine.get_ci_watch_engine", get_eng),
|
|
):
|
|
await orch._run_ci_watch_cycle()
|
|
get_eng.assert_not_called() # empty watch set → no engine run
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_cycle_runs_engine_when_watch_set_present() -> None:
|
|
orch = _orch()
|
|
watch = [MagicMock()]
|
|
orch._load_ci_watch_set = AsyncMock(return_value=watch) # type: ignore[method-assign]
|
|
db = MagicMock()
|
|
db.commit = AsyncMock()
|
|
engine = MagicMock()
|
|
engine.run_cycle = AsyncMock(return_value=[])
|
|
with (
|
|
patch("roboco.db.get_db_context", _db_ctx(db)),
|
|
patch(
|
|
"roboco.services.ci_watch_engine.get_ci_watch_engine",
|
|
return_value=engine,
|
|
) as get_eng,
|
|
):
|
|
await orch._run_ci_watch_cycle()
|
|
get_eng.assert_called_once()
|
|
engine.run_cycle.assert_awaited_once_with(watch)
|
|
db.commit.assert_awaited_once()
|