Files
roboco/tests/unit/gateway/test_spine_cap_remediate.py
T
Renn F 87b18bc64f fix(gateway): spine-cap remediate forbids task_type workaround
Smoke-7: be-pm got the expected spine-cap rejection on a second
delegate. The remediate said "drive the existing sibling to
completion / cancel it, OR split this parent into two sibling
parents". The model read that, decided neither applied, and
"adapted" by re-delegating with task_type='documentation' as a
"verification subtask". The gateway accepted it (different type =
no cap collision) but the orphan subtask had no claimant — it
blocked submit_up forever with "subtasks not all terminal".

Two-layer fix:

1. _spine_type_dup_envelope remediate now explicitly forbids the
   workaround: "DO NOT work around this by delegating again with a
   different task_type (e.g. 'documentation' or 'research' as a
   'verification' subtask). The lifecycle handles QA, documentation,
   and PM-review automatically after the code subtask finishes —
   you do not create auxiliary subtasks for those roles. Call
   i_am_idle() now and wait for the existing child to come back."

2. cell_pm.md workflow step 6 strengthened to name the anti-pattern
   explicitly: no verification subtask (QA is the verification step);
   never re-delegate with a different task_type as a workaround.

3 new tests pin the remediate text: forbids workaround, names the
verification anti-pattern, retains invalid_state error kind.
2026-05-15 03:26:04 +02:00

62 lines
2.3 KiB
Python

"""Smoke-7: spine-cap rejection's remediate forbids the workaround pattern.
Original behavior: cell-PM gets the spine-cap rejection on a second
delegate (parent already has non-terminal task_type='code' subtask).
The model "adapts" by delegating again with task_type='research' or
'documentation' as a "verification" subtask. That works around the
gateway but creates a permanently-stuck orphan subtask that no agent
will ever claim — blocks submit_up forever with
`subtasks not all terminal`.
Fix: remediate explicitly forbids the workaround and tells the agent
to call i_am_idle() instead.
"""
from __future__ import annotations
from unittest.mock import MagicMock
from roboco.services.gateway.choreographer._impl import Choreographer
def test_spine_cap_remediate_forbids_task_type_workaround() -> None:
"""The spine-cap rejection's remediate must say 'do not work around with
different task_type'."""
sibling = MagicMock(id="abc12345-...", status="pending")
env = Choreographer._spine_type_dup_envelope(
new_type="code",
sibling=sibling,
sib_assignee="be-dev-1",
)
remediate = env.remediate or ""
assert "DO NOT work around" in remediate, (
f"Spine-cap remediate must forbid the task_type workaround. Got:\n{remediate}"
)
assert "different task_type" in remediate
assert "i_am_idle" in remediate
def test_spine_cap_remediate_warns_about_verification_subtasks() -> None:
"""The remediate must name the specific 'verification subtask' anti-pattern."""
sibling = MagicMock(id="abc12345-...", status="pending")
env = Choreographer._spine_type_dup_envelope(
new_type="code",
sibling=sibling,
sib_assignee="be-dev-1",
)
remediate = env.remediate or ""
# Anti-pattern names — must appear so the model pattern-matches its own behavior.
assert "verification" in remediate.lower() or "research" in remediate.lower()
def test_spine_cap_envelope_is_invalid_state() -> None:
"""The envelope keeps the invalid_state error kind (so the agent knows
it's a state issue, not authorization or input shape)."""
sibling = MagicMock(id="abc12345-...", status="pending")
env = Choreographer._spine_type_dup_envelope(
new_type="code",
sibling=sibling,
sib_assignee="be-dev-1",
)
assert env.error == "invalid_state"