mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
Fix: Make main_pm + task_type=code impossible
This commit is contained in:
@@ -206,6 +206,49 @@ def test_findings_single_dict_coerced_to_list() -> None:
|
||||
assert len(c.findings) == 1
|
||||
|
||||
|
||||
def test_pr_review_issues_carry_free_text_change_requests() -> None:
|
||||
# The in-path gate fails on free-text issues (not structured Finding
|
||||
# objects, which require file/severity/expected/actual). Those issues now
|
||||
# land in the additive `issues` slot instead of being flattened into the
|
||||
# summary string alone — so a reader of notes_structured.pr_review gets the
|
||||
# concrete change-requests, and the rendered TEXT mirror gains an Issues
|
||||
# section.
|
||||
c = validate_content(
|
||||
"pr_review",
|
||||
{
|
||||
"summary": "PR review needs changes before this can merge.",
|
||||
"verdict": "changes_requested",
|
||||
"issues": ["seam mismatch on the rebase path", "docs lag the diff"],
|
||||
},
|
||||
)
|
||||
assert isinstance(c, PrReviewContent)
|
||||
assert c.issues == ["seam mismatch on the rebase path", "docs lag the diff"]
|
||||
rendered = c.render_markdown()
|
||||
assert "## Issues" in rendered
|
||||
assert "seam mismatch on the rebase path" in rendered
|
||||
assert "docs lag the diff" in rendered
|
||||
|
||||
|
||||
def test_pr_review_issues_default_empty_and_single_scalar_coerced() -> None:
|
||||
c = validate_content(
|
||||
"pr_review",
|
||||
{"summary": "Clean PR, no free-text issues to raise.", "verdict": "approved"},
|
||||
)
|
||||
assert isinstance(c, PrReviewContent)
|
||||
assert c.issues == []
|
||||
assert "## Issues" not in c.render_markdown()
|
||||
|
||||
coerced = validate_content(
|
||||
"pr_review",
|
||||
{
|
||||
"summary": "One free-text issue passed as a bare string here.",
|
||||
"verdict": "changes_requested",
|
||||
"issues": "lone issue string",
|
||||
},
|
||||
)
|
||||
assert coerced.issues == ["lone issue string"]
|
||||
|
||||
|
||||
def test_where_to_look_single_string_coerced() -> None:
|
||||
c = validate_content(
|
||||
"resumption",
|
||||
|
||||
@@ -10,7 +10,9 @@ from roboco.foundation.policy.batch import (
|
||||
is_batch_umbrella,
|
||||
is_branchless_coordination,
|
||||
is_valid_batch_shape,
|
||||
main_pm_cannot_own_code,
|
||||
)
|
||||
from roboco.models.base import TaskType, Team
|
||||
|
||||
|
||||
def test_umbrella_is_batch_id_set_and_top_level() -> None:
|
||||
@@ -163,3 +165,27 @@ def test_valid_batch_shape_denies_cell_map_alongside_another_target() -> None:
|
||||
product_id=uuid4(),
|
||||
has_cell_projects=True,
|
||||
)
|
||||
|
||||
|
||||
def test_main_pm_cannot_own_code_predicate() -> None:
|
||||
"""``main_pm`` + ``code`` must never coexist — the single invariant behind
|
||||
the intake coercion, the create backstop, the reassign/escalation diversion,
|
||||
and the claim guard. Accepts ORM enums or their .value strings."""
|
||||
# The forbidden combo, in both enum and string form.
|
||||
assert main_pm_cannot_own_code(team=Team.MAIN_PM, task_type=TaskType.CODE)
|
||||
assert main_pm_cannot_own_code(
|
||||
team=Team.MAIN_PM.value, task_type=TaskType.CODE.value
|
||||
)
|
||||
# A Main PM coordinating (planning / research / etc.) is fine.
|
||||
assert not main_pm_cannot_own_code(team=Team.MAIN_PM, task_type=TaskType.PLANNING)
|
||||
assert not main_pm_cannot_own_code(team=Team.MAIN_PM, task_type=TaskType.RESEARCH)
|
||||
assert not main_pm_cannot_own_code(
|
||||
team=Team.MAIN_PM, task_type=TaskType.DOCUMENTATION
|
||||
)
|
||||
# Code owned by any non-main_pm team (a cell dev, the board pre-approval) is fine.
|
||||
assert not main_pm_cannot_own_code(team=Team.BACKEND, task_type=TaskType.CODE)
|
||||
assert not main_pm_cannot_own_code(team=Team.FRONTEND, task_type=TaskType.CODE)
|
||||
assert not main_pm_cannot_own_code(team=Team.BOARD, task_type=TaskType.CODE)
|
||||
# Missing team or type cannot satisfy the invariant.
|
||||
assert not main_pm_cannot_own_code(team=None, task_type=TaskType.CODE)
|
||||
assert not main_pm_cannot_own_code(team=Team.MAIN_PM, task_type=None)
|
||||
|
||||
Reference in New Issue
Block a user