mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
* chore(compose): pass research key/provider + provisioning token/org through to the orchestrator ROBOCO_RESEARCH_API_KEY / ROBOCO_RESEARCH_PROVIDER and ROBOCO_PROVISIONING_TOKEN / ROBOCO_PROVISIONING_ORG were absent from every compose environment stanza, so .env values never reached the container: research silently ran on the NullProvider (empty results forever) and any approved pitch died on ProvisioningDisabledError. .env.example also falsely claimed the provisioning creds are panel-managed. * feat(board): pitch CEO notification + auditor playbook-draft surfacing A proposed pitch now nudges the CEO (APPROVAL notification + Telegram link to the Pitches tab, best-effort — a send failure never fails the verb). auditor_triage surfaces the oldest pending playbook draft once anomalies are clear — the curation verbs were granted but nothing ever pointed the Auditor at the review queue; the scheduled audit prompt names the discovery path. * docs(prompts): pitch doctrine section + auditor reply-only-dm drift fix board.md never mentioned the pitch verb, so no board agent ever had a reason to call it — it gets a dedicated section mirroring the roadmap/spotlight ones, plus a roadmap-exploration escape hatch (needs-its-own-repo ideas pitch instead). product-owner.md gains its missing propose_roadmap + pitch entries. The flat 'Auditor has no dm' claims are corrected to the real grant: never initiates, reply-only in a CEO-opened thread. Doctrine guarded by a prompt-content test. --------- Co-authored-by: Renn F <rennf93@users.noreply.github.com>
132 lines
4.6 KiB
Python
132 lines
4.6 KiB
Python
"""Tests for Auditor Choreographer methods.
|
|
|
|
Covers: auditor_triage (read-only anomaly surfacing).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from datetime import UTC, datetime
|
|
from typing import Any
|
|
from unittest.mock import AsyncMock, MagicMock, patch
|
|
from uuid import uuid4
|
|
|
|
import pytest
|
|
from roboco.services.gateway.choreographer import Choreographer, ChoreographerDeps
|
|
|
|
|
|
def _make_deps(**overrides: Any) -> ChoreographerDeps:
|
|
base: dict[str, Any] = {
|
|
"task": AsyncMock(),
|
|
"work_session": AsyncMock(),
|
|
"git": AsyncMock(),
|
|
"a2a": AsyncMock(),
|
|
"journal": AsyncMock(),
|
|
"audit": AsyncMock(),
|
|
"evidence_repo": AsyncMock(),
|
|
}
|
|
base.update(overrides)
|
|
repo = base["evidence_repo"]
|
|
for method in (
|
|
"list_unread_a2a",
|
|
"list_unread_mentions",
|
|
"list_pending_notifications",
|
|
"task_metadata_gaps",
|
|
"recent_team_activity",
|
|
"blockers_in_lane",
|
|
"journal_highlights_for_task",
|
|
):
|
|
getattr(repo, method).return_value = []
|
|
# C8: default-fresh journal:decision so PM-decision gate passes.
|
|
# Tests that exercise the gate boundary stub their own value.
|
|
# The check matches MagicMock and AsyncMock (the two default sentinel
|
|
# types pytest's unittest.mock leaves on un-stubbed return_values).
|
|
_ldef = base["journal"].latest_decision_at.return_value
|
|
if type(_ldef).__name__ in ("MagicMock", "AsyncMock"):
|
|
base["journal"].latest_decision_at.return_value = datetime.now(UTC)
|
|
return ChoreographerDeps(**base)
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_auditor_triage_returns_anomaly_when_present() -> None:
|
|
auditor_id = uuid4()
|
|
anomaly = MagicMock(
|
|
id=uuid4(),
|
|
status="blocked",
|
|
title="long-running blocked",
|
|
team="backend",
|
|
)
|
|
task_svc = AsyncMock()
|
|
task_svc.agent_for.return_value = MagicMock(role="auditor", team="board")
|
|
task_svc.list_long_running_blocked.return_value = [anomaly]
|
|
deps = _make_deps(task=task_svc)
|
|
c = Choreographer(deps)
|
|
|
|
env = await c.auditor_triage(auditor_id)
|
|
body = env.as_dict()
|
|
assert body["task_id"] == str(anomaly.id)
|
|
assert "reflect" in body["next"].lower()
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_auditor_triage_returns_idle_when_no_anomalies() -> None:
|
|
auditor_id = uuid4()
|
|
task_svc = AsyncMock()
|
|
task_svc.agent_for.return_value = MagicMock(role="auditor", team="board")
|
|
task_svc.list_long_running_blocked.return_value = []
|
|
deps = _make_deps(task=task_svc)
|
|
c = Choreographer(deps)
|
|
|
|
playbook_svc = AsyncMock()
|
|
playbook_svc.list_drafts.return_value = []
|
|
with patch(
|
|
"roboco.services.playbook.get_playbook_service", return_value=playbook_svc
|
|
):
|
|
env = await c.auditor_triage(auditor_id)
|
|
body = env.as_dict()
|
|
assert body["status"] == "idle"
|
|
assert body["task_id"] is None
|
|
assert "i_am_idle" in body["next"]
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_auditor_triage_surfaces_playbook_draft_when_no_anomalies() -> None:
|
|
"""No anomalies, but a pending playbook draft — surfaced instead of idle
|
|
so the Auditor's approve_playbook/reject_playbook duty is discoverable."""
|
|
auditor_id = uuid4()
|
|
task_svc = AsyncMock()
|
|
task_svc.agent_for.return_value = MagicMock(role="auditor", team="board")
|
|
task_svc.list_long_running_blocked.return_value = []
|
|
deps = _make_deps(task=task_svc)
|
|
c = Choreographer(deps)
|
|
|
|
draft = MagicMock(id=uuid4(), title="Rebase onto a live rung before cutting")
|
|
playbook_svc = AsyncMock()
|
|
playbook_svc.list_drafts.return_value = [draft]
|
|
with patch(
|
|
"roboco.services.playbook.get_playbook_service", return_value=playbook_svc
|
|
):
|
|
env = await c.auditor_triage(auditor_id)
|
|
body = env.as_dict()
|
|
assert body["status"] == "draft"
|
|
assert body["task_id"] is None
|
|
assert str(draft.id)[:8] in body["next"]
|
|
assert "approve_playbook" in body["next"]
|
|
assert "reject_playbook" in body["next"]
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_auditor_triage_only_first_anomaly_surfaces() -> None:
|
|
"""Auditor gets the most-stale blocked task; others wait until next call."""
|
|
auditor_id = uuid4()
|
|
first = MagicMock(id=uuid4(), status="blocked", title="oldest", team="backend")
|
|
second = MagicMock(id=uuid4(), status="blocked", title="newer", team="frontend")
|
|
task_svc = AsyncMock()
|
|
task_svc.agent_for.return_value = MagicMock(role="auditor", team="board")
|
|
task_svc.list_long_running_blocked.return_value = [first, second]
|
|
deps = _make_deps(task=task_svc)
|
|
c = Choreographer(deps)
|
|
|
|
env = await c.auditor_triage(auditor_id)
|
|
body = env.as_dict()
|
|
assert body["task_id"] == str(first.id)
|