mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
Post-audit sweep over the 135 audit-fix commits since19a474d3: 1. Stripped every # Fxxx: audit-ID token from comments AND every Fxxx token from docstring openings across 211 blocks / ~626 lines. The CEO flagged these twice: audit-issue IDs in code confuse future devs/agents. The descriptive text is preserved; only the Fxxx token is removed (and bloated narrative blocks trimmed to 1-3 lines keeping the one non-obvious invariant). 2. Trimmed bloated comments/docstrings to the concise standard (1-3 lines). 3. Added missing behavior-change docs for the audit-fix batch: prompts/roles (documenter, pr_reviewer, qa), user-facing docs (api auth, websockets, agent-gateway, megatask, merge-model, task-lifecycle, grok, resilience, conventions, panel, security, troubleshooting), and the RAG corpus (cell-pm, main-pm, pr-reviewer, qa roles; conventions; messaging-tools; escalation; megatask; task-claiming workflows). Comment/docstring/prose ONLY — zero code-line edits (verified: the diff contains no def/class/return/if/for/await/assignment/call lines). Gates green: ruff format + ruff check clean, mypy clean on roboco/. The only pytest failures are the pre-existing sync_branch tracing-decision gap (B1,250be5c2) — not sweep-caused and tracked separately.
52 lines
1.7 KiB
Python
52 lines
1.7 KiB
Python
"""``already_active_guard`` must treat a ``blocked`` task as active. A blocked
|
|
task is still owned and will resume to ``in_progress`` on unblock, so it must
|
|
block a new claim (preserves the one-active-task-per-dev invariant).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from unittest.mock import MagicMock
|
|
from uuid import uuid4
|
|
|
|
from roboco.services.gateway.claim_guards import already_active_guard
|
|
|
|
|
|
def _task(*, status: str) -> MagicMock:
|
|
t = MagicMock()
|
|
t.id = uuid4()
|
|
t.status = status
|
|
return t
|
|
|
|
|
|
def test_already_active_guard_blocks_when_agent_has_blocked_task() -> None:
|
|
"""A blocked task the dev still owns must block a new claim."""
|
|
target_id = uuid4()
|
|
blocked = _task(status="blocked")
|
|
env = already_active_guard([blocked], target_id)
|
|
assert env is not None
|
|
assert env.error == "invalid_state"
|
|
|
|
|
|
def test_already_active_guard_still_blocks_in_progress() -> None:
|
|
"""Regression: the existing in_progress case still fires."""
|
|
target_id = uuid4()
|
|
in_progress = _task(status="in_progress")
|
|
env = already_active_guard([in_progress], target_id)
|
|
assert env is not None
|
|
|
|
|
|
def test_already_active_guard_excludes_target_task_itself() -> None:
|
|
"""Re-claiming/resuming the same blocked task must not self-block."""
|
|
target_id = uuid4()
|
|
blocked_self = MagicMock(id=target_id, status="blocked")
|
|
env = already_active_guard([blocked_self], target_id)
|
|
assert env is None
|
|
|
|
|
|
def test_already_active_guard_passes_when_no_active_tasks() -> None:
|
|
"""A dev with only terminal/backlog tasks may claim."""
|
|
target_id = uuid4()
|
|
others = [_task(status="completed"), _task(status="backlog")]
|
|
env = already_active_guard(others, target_id)
|
|
assert env is None
|