mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
* [420e5e68] Fix mypy errors in tests/unit/ and create tests/__init__.py (#154) * [420e5e68] fix(tests): resolve all mypy errors in tests/unit/ and create tests/__init__.py - Create tests/__init__.py as empty package marker - Add Any import and fix list type annotation in test_flow_server_intent_public_mapping.py - Move AsyncIterator to TYPE_CHECKING block and fix m.cls.__name__ attr error in test_app.py - Add return type annotations to _stub_get_optimal, _source, and factory functions - Implement abstract methods (index_type, prepare_metadata, build_source_uri) in _FakePlugin - Add pyproject.toml per-file-ignore for ARG002 on test_optimal_grounding.py stub - Remove 4 stale # type: ignore comments from test_rate_limit_tracker.py - Fix method-assignment patterns in test_rate_limit_sweep.py via patch.object - All 487 source files pass mypy with 0 errors; 2312 unit tests pass * [420e5e68] fix(tests): move stdlib/third-party imports to TYPE_CHECKING blocks across tests/unit/ Resolves 6 remaining ruff TC002/TC003 errors from the quality gate: - test_handlers.py: Iterator → TYPE_CHECKING - test_quality_gate.py: pathlib → TYPE_CHECKING - test_board_dispatch.py: AsyncIterator + httpx → TYPE_CHECKING - test_streaming.py: Iterator → TYPE_CHECKING - test_notification.py: AsyncIterator → TYPE_CHECKING All files have from __future__ import annotations so annotations are strings at runtime; no runtime NameError risk from moving to TYPE_CHECKING. * [420e5e68] fix(tests): use forward-ref cast() and drop unused TYPE_CHECKING import in 4 test files * [420e5e68] chore(Makefile): scope lint mypy target to roboco/ to match gate and quality targets --------- * [b0c9d41b] Fix mypy errors in tests/integration/ tests/foundation/ tests/property/ and update Makefile quality gates (#155) * [b0c9d41b] fix(tests): resolve all mypy errors in tests/integration/, tests/foundation/, tests/property/ - Add missing type annotations to inner functions (_override_db, _override_agent_id, _req, etc.) - Use cast("UUID", ...) to fix SQLAlchemy UUID vs uuid.UUID arg-type mismatches - Remove stale # type: ignore comments from test_full_lifecycle_real_db.py and test_task_service_lifecycle_misc.py - Update Makefile quality/quality-fast targets to run mypy on roboco/ tests/ - No runtime logic changed — annotations and cast() only * [b0c9d41b] fix(tests): apply ruff TC006 quoted-cast and AsyncGenerator[T] fixes to complete mypy gate - Quote all cast() type arguments per ruff TC006 rule (cast("T", x)) - Change AsyncGenerator[T, None] to AsyncGenerator[T] (Python 3.12 form) - Move runtime-only imports to TYPE_CHECKING blocks (Path, Table, Generator, etc.) - No runtime logic changed — annotation-only changeset * [b0c9d41b] fix(Makefile): align lint target mypy scope with gate target (roboco/ only) The lint target used `uv run mypy .` (all files) while gate uses `uv run mypy roboco/`. This inconsistency caused the pre-submit gate to fail on 161 pre-existing tests/unit/ errors (being fixed by sibling task 420e5e68). The quality/quality-fast targets already check `roboco/ tests/` — the lint target now matches gate scope. --------- --------- Co-authored-by: Backend Developer 1 <be-dev-1@agents.roboco.dev> Co-authored-by: Backend Developer 2 <be-dev-2@agents.roboco.dev>
100 lines
3.5 KiB
Python
100 lines
3.5 KiB
Python
"""#167: the briefing's _build_tool_load_block must not push ToolSearch.
|
|
|
|
Earlier (smoke-8) the block instructed agents to run a ToolSearch call
|
|
to "activate deferred built-in tools". That premise was false —
|
|
ToolSearch is MCP-only, never gates built-ins, and is not callable in
|
|
the agent runtime — so weak models chased a nonexistent tool and fell
|
|
back to destructive shell file-writes. The real cause of "Edit not
|
|
enabled in this context" was a permission bug fixed separately.
|
|
|
|
The block now affirms the role's built-in tools are loaded and ready,
|
|
tells the agent NOT to call ToolSearch, and (for authoring roles)
|
|
steers away from whole-file shell redirection.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from unittest.mock import patch
|
|
|
|
from roboco.runtime.orchestrator import AgentOrchestrator
|
|
|
|
|
|
def _orch() -> AgentOrchestrator:
|
|
with patch.object(AgentOrchestrator, "__init__", return_value=None):
|
|
orch = AgentOrchestrator.__new__(AgentOrchestrator)
|
|
object.__setattr__(orch, "_TOOL_LOAD_CACHE", {})
|
|
return orch
|
|
|
|
|
|
def _tool_names(block: str) -> list[str]:
|
|
"""Exact tool tokens (so 'TodoWrite' is not mistaken for 'Write')."""
|
|
line = next(ln for ln in block.splitlines() if "available now:" in ln)
|
|
seg = line.split("available now: ", 1)[1]
|
|
return seg.split(".", 1)[0].split(", ")
|
|
|
|
|
|
def test_developer_block_affirms_tools_no_toolsearch_call() -> None:
|
|
block = _orch()._build_tool_load_block("developer")
|
|
assert "Your tools are ready" in block
|
|
assert "ToolSearch(query=" not in block
|
|
assert "are deferred" not in block
|
|
names = _tool_names(block)
|
|
assert "Edit" in names and "Write" in names
|
|
|
|
|
|
def test_developer_block_steers_away_from_shell_redirection() -> None:
|
|
block = _orch()._build_tool_load_block("developer")
|
|
assert "shell redirection" in block
|
|
assert "Edit/Write" in block
|
|
|
|
|
|
def test_documenter_block_lists_edit_and_write() -> None:
|
|
names = _tool_names(_orch()._build_tool_load_block("documenter"))
|
|
assert "Edit" in names and "Write" in names
|
|
|
|
|
|
def test_qa_block_excludes_edit_and_write() -> None:
|
|
block = _orch()._build_tool_load_block("qa")
|
|
assert "Your tools are ready" in block
|
|
names = _tool_names(block)
|
|
assert "Edit" not in names and "Write" not in names
|
|
assert "Read" in names and "Bash" in names
|
|
|
|
|
|
def test_pm_blocks_exclude_edit_and_write() -> None:
|
|
for role in ("main_pm", "cell_pm", "product_owner", "head_marketing", "auditor"):
|
|
names = _tool_names(_orch()._build_tool_load_block(role))
|
|
assert "Edit" not in names, f"{role} must not list Edit"
|
|
assert "Write" not in names, f"{role} must not list Write"
|
|
|
|
|
|
def test_no_role_block_lists_the_task_subagent_tool() -> None:
|
|
"""Task (sub-agent dispatch) is dropped from the briefing tool grant.
|
|
|
|
No role uses Task and there are no custom sub-agent definitions, so it only
|
|
spawns a context-blind generic sub-agent that burns budget.
|
|
"""
|
|
for role in (
|
|
"developer",
|
|
"documenter",
|
|
"qa",
|
|
"main_pm",
|
|
"cell_pm",
|
|
"product_owner",
|
|
"head_marketing",
|
|
"auditor",
|
|
):
|
|
names = _tool_names(_orch()._build_tool_load_block(role))
|
|
assert "Task" not in names, f"{role} must not list Task: {names}"
|
|
|
|
|
|
def test_unknown_role_returns_empty() -> None:
|
|
assert _orch()._build_tool_load_block("nonexistent") == ""
|
|
|
|
|
|
def test_role_cache_works() -> None:
|
|
orch = _orch()
|
|
first = orch._build_tool_load_block("developer")
|
|
second = orch._build_tool_load_block("developer")
|
|
assert first is second
|