mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
fix(gateway): reject PM-created documentation subtasks (#163)
Smoke-12: be-pm delegated TWO subtasks under one cell parent — a code subtask (be-dev-1, spawned) and a documentation subtask (be-dev-2). The orchestrator dev-dispatch refuses to spawn a developer for task_type=documentation, so the doc subtask became a permanent orphan that loops dev-dispatch forever and would deadlock submit_up (all subtasks must be terminal). The spine-cap is per-type so code + documentation both passed sibling-dedup — the PM never saw the anti-pattern warning. _delegate_static_guards now rejects task_type='documentation' with a remediate explaining the lifecycle auto-creates the documentation phase (awaiting_documentation → documenter spawned) after the code subtask passes QA, and that the PM should delegate ONLY the code subtask.
This commit is contained in:
@@ -2754,6 +2754,32 @@ class Choreographer:
|
|||||||
),
|
),
|
||||||
context_briefing=await self._briefing_for(pm_agent_id, parent_task_id),
|
context_briefing=await self._briefing_for(pm_agent_id, parent_task_id),
|
||||||
)
|
)
|
||||||
|
if str(inputs.task_type) == "documentation":
|
||||||
|
# Task #163: the lifecycle auto-handles documentation. After a
|
||||||
|
# `code` subtask passes QA it transitions to
|
||||||
|
# awaiting_documentation and a *documenter* is spawned
|
||||||
|
# automatically. A PM-created `documentation` subtask assigned
|
||||||
|
# to a developer can never be spawned (dev-dispatch rejects
|
||||||
|
# role/task_type mismatch) — it becomes a permanent orphan
|
||||||
|
# that deadlocks submit_up (all subtasks must be terminal).
|
||||||
|
# The spine-cap is per-type so this slips past the
|
||||||
|
# code-vs-code dedup; reject it explicitly here.
|
||||||
|
return Envelope.invalid_state(
|
||||||
|
message=(
|
||||||
|
"task_type='documentation' subtasks are not PM-"
|
||||||
|
"delegatable: the lifecycle creates the documentation "
|
||||||
|
"phase automatically after the code subtask passes QA."
|
||||||
|
),
|
||||||
|
remediate=(
|
||||||
|
"Delegate ONLY the code subtask (task_type='code'). "
|
||||||
|
"Once it passes QA the gateway transitions it to "
|
||||||
|
"awaiting_documentation and spawns a documenter for "
|
||||||
|
"you — do NOT create a separate documentation subtask "
|
||||||
|
"or assign docs to a developer. Re-issue delegate(...) "
|
||||||
|
"with task_type='code' and i_am_idle when done."
|
||||||
|
),
|
||||||
|
context_briefing=await self._briefing_for(pm_agent_id, parent_task_id),
|
||||||
|
)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
_CELL_PM_SLUGS: ClassVar[frozenset[str]] = frozenset({"be-pm", "fe-pm", "ux-pm"})
|
_CELL_PM_SLUGS: ClassVar[frozenset[str]] = frozenset({"be-pm", "fe-pm", "ux-pm"})
|
||||||
|
|||||||
@@ -0,0 +1,135 @@
|
|||||||
|
"""Task #163: delegate() rejects PM-created documentation subtasks.
|
||||||
|
|
||||||
|
Smoke-12: be-pm delegated TWO subtasks under one cell parent — a
|
||||||
|
`code` subtask (be-dev-1, spawned) and a `documentation` subtask
|
||||||
|
(be-dev-2). The orchestrator's dev-dispatch refuses to spawn a
|
||||||
|
developer for a documentation task_type, so the doc subtask became a
|
||||||
|
permanent orphan that would deadlock submit_up (all subtasks must be
|
||||||
|
terminal). The spine-cap is per-type so code+documentation both passed
|
||||||
|
the sibling-dedup. Fix: _delegate_static_guards rejects
|
||||||
|
task_type='documentation' with a remediate explaining the lifecycle
|
||||||
|
auto-handles docs after the code subtask passes QA.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from datetime import UTC, datetime
|
||||||
|
from typing import Any
|
||||||
|
from unittest.mock import AsyncMock, MagicMock
|
||||||
|
from uuid import uuid4
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from roboco.services.gateway.choreographer import Choreographer, ChoreographerDeps
|
||||||
|
from roboco.services.gateway.choreographer._impl import DelegateInputs
|
||||||
|
|
||||||
|
|
||||||
|
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(),
|
||||||
|
"messaging": AsyncMock(),
|
||||||
|
}
|
||||||
|
base.update(overrides)
|
||||||
|
repo = base["evidence_repo"]
|
||||||
|
for m 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, m).return_value = []
|
||||||
|
_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)
|
||||||
|
|
||||||
|
|
||||||
|
def _parent(parent_id: object) -> MagicMock:
|
||||||
|
return MagicMock(
|
||||||
|
id=parent_id,
|
||||||
|
project_id=uuid4(),
|
||||||
|
team="backend",
|
||||||
|
status="in_progress",
|
||||||
|
task_type="planning",
|
||||||
|
sequence=0,
|
||||||
|
assigned_to=uuid4(),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _inputs(task_type: str) -> DelegateInputs:
|
||||||
|
return DelegateInputs(
|
||||||
|
title="Doc the change",
|
||||||
|
description="Write documentation for the README change",
|
||||||
|
acceptance_criteria=["doc created", "doc linked"],
|
||||||
|
assigned_to="be-dev-2",
|
||||||
|
team="backend",
|
||||||
|
task_type=task_type,
|
||||||
|
nature="technical",
|
||||||
|
estimated_complexity="medium",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_delegate_rejects_documentation_task_type() -> None:
|
||||||
|
"""A documentation-typed subtask is rejected with a lifecycle hint."""
|
||||||
|
pm_id = uuid4()
|
||||||
|
parent_id = uuid4()
|
||||||
|
deps = _make_deps()
|
||||||
|
c = Choreographer(deps)
|
||||||
|
|
||||||
|
env = await c._delegate_static_guards(
|
||||||
|
pm_id, parent_id, _parent(parent_id), _inputs("documentation")
|
||||||
|
)
|
||||||
|
assert env is not None, "documentation subtask must be rejected"
|
||||||
|
body = env.as_dict()
|
||||||
|
assert body["error"] == "invalid_state", body
|
||||||
|
remediate = (body["remediate"] or "").lower()
|
||||||
|
assert "task_type='code'" in remediate or "task_type=code" in remediate
|
||||||
|
assert "awaiting_documentation" in remediate or "automatically" in remediate
|
||||||
|
# Must NOT tell the PM to just retry documentation.
|
||||||
|
assert "documenter" in remediate
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_delegate_allows_code_task_type() -> None:
|
||||||
|
"""The code subtask (the only thing the PM should delegate) passes
|
||||||
|
the static guard."""
|
||||||
|
pm_id = uuid4()
|
||||||
|
parent_id = uuid4()
|
||||||
|
deps = _make_deps()
|
||||||
|
c = Choreographer(deps)
|
||||||
|
|
||||||
|
env = await c._delegate_static_guards(
|
||||||
|
pm_id, parent_id, _parent(parent_id), _inputs("code")
|
||||||
|
)
|
||||||
|
assert env is None, f"code subtask must pass static guards, got {env}"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_delegate_still_allows_planning_for_cell_pm() -> None:
|
||||||
|
"""Main PM delegating planning to a cell PM is unaffected."""
|
||||||
|
pm_id = uuid4()
|
||||||
|
parent_id = uuid4()
|
||||||
|
deps = _make_deps()
|
||||||
|
c = Choreographer(deps)
|
||||||
|
|
||||||
|
inputs = DelegateInputs(
|
||||||
|
title="Backend slice",
|
||||||
|
description="Own the backend slice end to end",
|
||||||
|
acceptance_criteria=["slice done"],
|
||||||
|
assigned_to="be-pm",
|
||||||
|
team="backend",
|
||||||
|
task_type="planning",
|
||||||
|
nature="technical",
|
||||||
|
estimated_complexity="medium",
|
||||||
|
)
|
||||||
|
env = await c._delegate_static_guards(pm_id, parent_id, _parent(parent_id), inputs)
|
||||||
|
assert env is None, f"planning→cell-PM must pass, got {env}"
|
||||||
Reference in New Issue
Block a user