mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
* fix(mcp): delegate tool carries the collision surface the B1a gate demands
TASK_AT_DELEGATE (5fc85419) requires intends_to_touch on code delegations,
but the MCP delegate tool never gained the parameter — PMs were rejected
with incomplete_input and could never comply (live fleet-wide delegation
wall, 2026-07-02). Adds intends_to_touch / adds_migration / touches_shared /
depends_on to the tool and forwards them; parity test locks the invariant.
* fix(git): assembly-integrity guard accepts squash-merged children
git cherry patch-matches each child commit individually, so a squash merge
(N patches -> one commit, new patch-id) read as 'work missing' and the #11
guard refused every legitimate submit_up (live 2026-07-02: S6 cell, three
squash-merged children at the branch tip). A parent commit carrying the
child's [taskid8] prefix now proves the child landed; children with no
marker stay flagged — the original incident the guard exists for.
* fix(git): diff head prefers origin when the local ref is behind it
Assembled branches advance on ORIGIN as child PRs squash-merge on GitHub,
but _resolve_head_ref preferred the inspecting clone's parked local ref —
the PR-gate reviewer's evidence diff was built from a pre-merge snapshot
and re-flagged work that had already landed (two false pr_fail verdicts
on the S6 cell PR, live 2026-07-02). When both refs exist and the local
ref is strictly behind origin, resolve to origin/<branch>; local-ahead
(unpushed) and diverged refs keep priority, single-ref cases unchanged.
* test(mcp): plan-gate fields must be tool parameters (parity class lock)
Extends the delegate parity test to every choreographer plan-depth gate:
a gate that can reject with missing=[field] must name only fields the
corresponding MCP tool can send, else the agent can never comply.
* perf(api): wire TaskSummaryResponse into a bounded /tasks/summary route
The panel fetched /api/tasks unbounded and full-fat — 2MB per refresh
measured live (2026-07-02), ~21KB/task, and the trimmed
TaskSummaryResponse was dead code. /tasks/summary returns exactly the
fields list views render (~50x lighter); the status-only branch of
/tasks now honors its limit, and the eleven unbounded task list routes
are capped.
* perf(panel): kill the per-page request flood and fat payloads
Every page load funneled ~85 default-prefetch RSC requests + 665KB of
images + the 2MB task list through the browser's six HTTP/1.1
connections — real data calls queued ~2s before being sent (measured
via Playwright resource timing, 2026-07-02).
- prefetch={false} on all 59 Links (sidebar, task rows, kanban cards,
list rows) — ~85 requests/refresh down to a handful
- icon/apple-icon/logo resized to render size: 665KB -> 54KB; unused
219KB PNG removed
- task list fetches the trimmed /tasks/summary (2MB -> ~100KB),
normalized into the Task shape so list consumers keep their types
- ReactQueryDevtools rendered only in development
* fix(api): Annotated limit defaults so direct-call tests get real ints
Query(...) positional defaults arrive as Query objects when a route
function is invoked outside the HTTP layer (integration tests call
handlers directly) and broke the new [:limit] slices.
* fix(api,panel): summary carries completed_at + board_review_complete
The metrics page computes velocity client-side from completed_at and the
CEO approval queue gates on board_review_complete — both were nulled by
the summary normalizer, so Completed Today/Week read 0 against 63 real
completions and approved-board tasks could vanish from the queue. The
queue also renders quick_context, so it fetches the full list (small,
status-scoped) via tasksApi.listFull instead of the summary.
* fix(runtime): spawn manifest workspace_path follows the task's project
_build_manifest_for_agent hardcoded the roboco project workspace for
every agent; a guard-core task's manifest claimed /data/workspaces/roboco
while the container cwd sat in the task worktree. The manifest now takes
the same _resolve_workspace_cwd the container -w uses — one resolver,
both surfaces agree by construction.
* fix(runtime): respawn breaker catches status ping-pong loops
Any status CHANGE fully reset the strike counter, so a blocked <->
in_progress oscillation — which changes status on every spawn while
advancing nothing — never tripped the gate (live 2026-07-02: 8 spawns
over two hours). A status never seen on the (agent, task) still fully
resets; a REVISITED status gets a bounded reset budget mirroring
tracing_resets, after which strikes accrue and the gate fires.
* fix(runtime): unassigned-QA dispatch spawns without pre-claiming
The transitioning pre-claim moved awaiting_qa -> claimed before the QA
agent existed; the spawned agent's claim_review/pass_review both demand
awaiting_qa, so it bounced twice and unclaimed (live 2026-07-02,
ba7b751c). Matches _spawn_assigned_qa and the external-PR reviewer
dispatch: no pre-claim, the agent claims itself via claim_review.
* fix(tests): narrow await_args before kwargs access (mypy union-attr)
* Minor upgrades
* fix(policy): team-match gate gains org-wide exemption; resume/unblock/activate now team-matched
needs_team_match sat in its permissive fallback since shipping (no
caller supplied Context.agent_team) and three PM verbs opted out
entirely — a misrouted frontend cell PM blocked, escalated, and held a
backend task through exactly that gap (live 2026-07-02). Org-wide roles
(main_pm, board, CEO, PR reviewer) are exempt so escalation handling
and root-PR gating keep working; cell-scoped roles are now enforced
wherever the caller supplies the team.
---------
Co-authored-by: Renn F <rennf93@users.noreply.github.com>
261 lines
11 KiB
Python
261 lines
11 KiB
Python
"""Tests for orchestrator spawn-manifest mounting (Phase 1)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
from typing import TYPE_CHECKING
|
|
from unittest.mock import patch
|
|
|
|
from roboco.agents_config import ALL_AGENTS, get_agent_role
|
|
from roboco.runtime.orchestrator import GATEWAY_ENABLED_ROLES, _build_manifest_for_agent
|
|
from roboco.seeds.initial_data import AGENT_UUIDS
|
|
|
|
if TYPE_CHECKING:
|
|
from pathlib import Path
|
|
|
|
# Roles the orchestrator never spawns as containerized delivery agents, so they
|
|
# legitimately get no spawn manifest: the human-only chat agents (prompter,
|
|
# secretary), the human CEO, and the orchestrator's own `system` sentinel. Every
|
|
# OTHER seeded role must be gateway-enabled or it boots with no flow verbs.
|
|
NON_SPAWNED_ROLES = {"prompter", "secretary", "ceo", "system"}
|
|
|
|
|
|
class TestGatewayEnabledRoles:
|
|
def test_all_roles_enabled(self) -> None:
|
|
"""Phase 4: every role gets the gateway manifest."""
|
|
assert "developer" in GATEWAY_ENABLED_ROLES
|
|
assert "qa" in GATEWAY_ENABLED_ROLES
|
|
assert "documenter" in GATEWAY_ENABLED_ROLES
|
|
assert "cell_pm" in GATEWAY_ENABLED_ROLES
|
|
assert "main_pm" in GATEWAY_ENABLED_ROLES
|
|
|
|
def test_board_roles_enabled_in_phase4(self) -> None:
|
|
"""Phase 4: board roles included."""
|
|
assert "product_owner" in GATEWAY_ENABLED_ROLES
|
|
assert "head_marketing" in GATEWAY_ENABLED_ROLES
|
|
assert "auditor" in GATEWAY_ENABLED_ROLES
|
|
|
|
def test_pr_reviewer_enabled(self) -> None:
|
|
"""The PR reviewer is a spawned delivery agent — it must be enabled.
|
|
|
|
Without this it gets ROBOCO_GATEWAY_ENABLED=false and no manifest, so
|
|
none of its flow verbs (claim_pr_review/post_pr_review) are registered;
|
|
it can never claim its task and the dispatcher respawns it forever.
|
|
"""
|
|
assert "pr_reviewer" in GATEWAY_ENABLED_ROLES
|
|
|
|
def test_every_spawnable_agent_role_is_gateway_enabled(self) -> None:
|
|
"""Invariant: every seeded agent the orchestrator spawns has a manifest.
|
|
|
|
Guards against the regression where a new spawnable role is added to the
|
|
roster but forgotten here — that role would spawn with no flow verbs and
|
|
loop. Only the never-spawned roles (prompter/secretary/ceo/system) may be
|
|
absent.
|
|
"""
|
|
missing = {
|
|
agent_id: role
|
|
for agent_id in ALL_AGENTS
|
|
if (role := get_agent_role(agent_id)) not in NON_SPAWNED_ROLES
|
|
and role not in GATEWAY_ENABLED_ROLES
|
|
}
|
|
assert not missing, (
|
|
f"spawnable agents missing from GATEWAY_ENABLED_ROLES "
|
|
f"(would loop with no flow verbs): {missing}"
|
|
)
|
|
|
|
|
|
class TestBuildManifestForAgent:
|
|
def test_developer_writes_file(self, tmp_path: Path) -> None:
|
|
"""Developer role produces a manifest JSON file at the expected host path."""
|
|
with patch("roboco.runtime.orchestrator.settings") as mock_settings:
|
|
mock_settings.manifest_host_dir = str(tmp_path)
|
|
mock_settings.workspaces_root = str(tmp_path / "workspaces")
|
|
|
|
result = _build_manifest_for_agent("be-dev-1", "claude-sonnet-5")
|
|
|
|
assert result is not None
|
|
assert result.exists()
|
|
assert result.name == "be-dev-1.json"
|
|
data = json.loads(result.read_text())
|
|
assert data["role"] == "developer"
|
|
assert data["team"] == "backend"
|
|
|
|
def test_developer_returns_path_inside_manifest_host_dir(
|
|
self, tmp_path: Path
|
|
) -> None:
|
|
"""The returned path is inside manifest_host_dir."""
|
|
with patch("roboco.runtime.orchestrator.settings") as mock_settings:
|
|
mock_settings.manifest_host_dir = str(tmp_path)
|
|
mock_settings.workspaces_root = str(tmp_path / "workspaces")
|
|
|
|
result = _build_manifest_for_agent("fe-dev-2", "claude-sonnet-5")
|
|
|
|
assert result is not None
|
|
assert result.parent == tmp_path
|
|
|
|
def test_developer_manifest_content_valid(self, tmp_path: Path) -> None:
|
|
"""Written manifest has required top-level keys."""
|
|
with patch("roboco.runtime.orchestrator.settings") as mock_settings:
|
|
mock_settings.manifest_host_dir = str(tmp_path)
|
|
mock_settings.workspaces_root = str(tmp_path / "workspaces")
|
|
|
|
result = _build_manifest_for_agent("be-dev-1", "claude-opus-4-6")
|
|
|
|
assert result is not None
|
|
data = json.loads(result.read_text())
|
|
for key in (
|
|
"agent_id",
|
|
"role",
|
|
"team",
|
|
"workspace_path",
|
|
"flow_tools",
|
|
"do_tools",
|
|
"bash_allowed",
|
|
):
|
|
assert key in data, f"missing key: {key}"
|
|
|
|
def test_developer_agent_id_in_manifest_matches_seed_uuid(
|
|
self, tmp_path: Path
|
|
) -> None:
|
|
"""agent_id field in the manifest matches the seeded UUID for be-dev-1."""
|
|
with patch("roboco.runtime.orchestrator.settings") as mock_settings:
|
|
mock_settings.manifest_host_dir = str(tmp_path)
|
|
mock_settings.workspaces_root = str(tmp_path / "workspaces")
|
|
|
|
result = _build_manifest_for_agent("be-dev-1", "claude-sonnet-5")
|
|
|
|
assert result is not None
|
|
data = json.loads(result.read_text())
|
|
assert data["agent_id"] == AGENT_UUIDS["be-dev-1"]
|
|
|
|
def test_qa_writes_file(self, tmp_path: Path) -> None:
|
|
"""Phase 2: QA role now produces a manifest JSON file (same as developer)."""
|
|
with patch("roboco.runtime.orchestrator.settings") as mock_settings:
|
|
mock_settings.manifest_host_dir = str(tmp_path)
|
|
mock_settings.workspaces_root = str(tmp_path / "workspaces")
|
|
|
|
result = _build_manifest_for_agent("be-qa", "claude-sonnet-5")
|
|
|
|
assert result is not None
|
|
assert result.exists()
|
|
assert result.name == "be-qa.json"
|
|
data = json.loads(result.read_text())
|
|
assert data["role"] == "qa"
|
|
assert data["team"] == "backend"
|
|
|
|
def test_documenter_writes_file(self, tmp_path: Path) -> None:
|
|
"""Phase 3: Documenter role produces a manifest JSON file."""
|
|
with patch("roboco.runtime.orchestrator.settings") as mock_settings:
|
|
mock_settings.manifest_host_dir = str(tmp_path)
|
|
mock_settings.workspaces_root = str(tmp_path / "workspaces")
|
|
|
|
result = _build_manifest_for_agent("be-doc", "claude-haiku-4-5-20251001")
|
|
|
|
assert result is not None
|
|
assert result.exists()
|
|
assert result.name == "be-doc.json"
|
|
data = json.loads(result.read_text())
|
|
assert data["role"] == "documenter"
|
|
assert data["team"] == "backend"
|
|
|
|
def test_cell_pm_writes_file(self, tmp_path: Path) -> None:
|
|
"""Phase 3: Cell PM role produces a manifest JSON file."""
|
|
with patch("roboco.runtime.orchestrator.settings") as mock_settings:
|
|
mock_settings.manifest_host_dir = str(tmp_path)
|
|
mock_settings.workspaces_root = str(tmp_path / "workspaces")
|
|
|
|
result = _build_manifest_for_agent("be-pm", "claude-sonnet-5")
|
|
|
|
assert result is not None
|
|
assert result.exists()
|
|
assert result.name == "be-pm.json"
|
|
data = json.loads(result.read_text())
|
|
assert data["role"] == "cell_pm"
|
|
assert data["team"] == "backend"
|
|
|
|
def test_main_pm_writes_file(self, tmp_path: Path) -> None:
|
|
"""Phase 3: Main PM role produces a manifest JSON file."""
|
|
with patch("roboco.runtime.orchestrator.settings") as mock_settings:
|
|
mock_settings.manifest_host_dir = str(tmp_path)
|
|
mock_settings.workspaces_root = str(tmp_path / "workspaces")
|
|
|
|
result = _build_manifest_for_agent("main-pm", "claude-sonnet-5")
|
|
|
|
assert result is not None
|
|
assert result.exists()
|
|
assert result.name == "main-pm.json"
|
|
data = json.loads(result.read_text())
|
|
assert data["role"] == "main_pm"
|
|
|
|
def test_pr_reviewer_writes_file_with_review_verbs(self, tmp_path: Path) -> None:
|
|
"""pr-reviewer-1 produces a manifest carrying its review flow verbs.
|
|
|
|
Regression guard for the respawn loop: if this returns None (role not
|
|
gateway-enabled) the reviewer spawns with no task tools.
|
|
"""
|
|
with patch("roboco.runtime.orchestrator.settings") as mock_settings:
|
|
mock_settings.manifest_host_dir = str(tmp_path)
|
|
mock_settings.workspaces_root = str(tmp_path / "workspaces")
|
|
|
|
result = _build_manifest_for_agent("pr-reviewer-1", "claude-sonnet-5")
|
|
|
|
assert result is not None, "pr-reviewer-1 must produce a manifest"
|
|
assert result.exists()
|
|
assert result.name == "pr-reviewer-1.json"
|
|
data = json.loads(result.read_text())
|
|
assert data["role"] == "pr_reviewer"
|
|
assert "claim_pr_review" in data["flow_tools"]
|
|
assert "post_pr_review" in data["flow_tools"]
|
|
|
|
def test_manifest_dir_created_if_absent(self, tmp_path: Path) -> None:
|
|
"""manifest_host_dir is created automatically when it doesn't exist."""
|
|
nested = tmp_path / "new" / "nested" / "dir"
|
|
assert not nested.exists()
|
|
|
|
with patch("roboco.runtime.orchestrator.settings") as mock_settings:
|
|
mock_settings.manifest_host_dir = str(nested)
|
|
mock_settings.workspaces_root = str(tmp_path / "workspaces")
|
|
|
|
result = _build_manifest_for_agent("be-dev-1", "claude-sonnet-5")
|
|
|
|
assert result is not None
|
|
assert nested.exists()
|
|
assert result.exists()
|
|
|
|
|
|
class TestManifestWorkspacePath:
|
|
"""workspace_path must be the TASK-resolved workspace, not the roboco default.
|
|
|
|
Live 2026-07-02: be-dev-2's manifest said /data/workspaces/roboco/... while
|
|
its task lived in guard-core-saas-backend — an agent trusting the manifest
|
|
hunts for its files in the wrong repository.
|
|
"""
|
|
|
|
def test_workspace_override_reaches_manifest(self, tmp_path: Path) -> None:
|
|
worktree = (
|
|
"/data/workspaces/guard-core-saas-backend/backend/be-dev-1"
|
|
"/.worktrees/abc12345"
|
|
)
|
|
with patch("roboco.runtime.orchestrator.settings") as mock_settings:
|
|
mock_settings.manifest_host_dir = str(tmp_path)
|
|
mock_settings.workspaces_root = str(tmp_path / "workspaces")
|
|
|
|
result = _build_manifest_for_agent(
|
|
"be-dev-1", "claude-sonnet-5", workspace_path=worktree
|
|
)
|
|
|
|
assert result is not None
|
|
data = json.loads(result.read_text())
|
|
assert data["workspace_path"] == worktree
|
|
|
|
def test_no_override_keeps_roboco_default(self, tmp_path: Path) -> None:
|
|
with patch("roboco.runtime.orchestrator.settings") as mock_settings:
|
|
mock_settings.manifest_host_dir = str(tmp_path)
|
|
mock_settings.workspaces_root = str(tmp_path / "workspaces")
|
|
|
|
result = _build_manifest_for_agent("be-dev-1", "claude-sonnet-5")
|
|
|
|
assert result is not None
|
|
data = json.loads(result.read_text())
|
|
assert data["workspace_path"].endswith("workspaces/roboco/backend/be-dev-1")
|