Linting/Formatting

This commit is contained in:
Renn F
2026-05-03 17:51:33 +02:00
parent 95c96d4ce3
commit 9bae446cbe
5 changed files with 14 additions and 31 deletions
+6 -16
View File
@@ -36,9 +36,7 @@ _TERMINAL_STATUSES: frozenset[str] = frozenset({"completed", "cancelled"})
# claim policy: developers do code-like work; QA reviews; documenters # claim policy: developers do code-like work; QA reviews; documenters
# document. PMs cannot claim code (see pm_cannot_execute_code). # document. PMs cannot claim code (see pm_cannot_execute_code).
_ROLE_TASK_TYPE_ALLOW: dict[str, frozenset[str]] = { _ROLE_TASK_TYPE_ALLOW: dict[str, frozenset[str]] = {
"developer": frozenset( "developer": frozenset({"code", "research", "design"}),
{"code", "research", "design"}
),
"qa": frozenset(), # QA never enters via i_will_work_on "qa": frozenset(), # QA never enters via i_will_work_on
"documenter": frozenset(), # Doc never enters via i_will_work_on "documenter": frozenset(), # Doc never enters via i_will_work_on
} }
@@ -65,8 +63,7 @@ def already_active_guard(
"finish or pause it before claiming new work." "finish or pause it before claiming new work."
), ),
remediate=( remediate=(
f"finish or pause {blocker.id} first via i_am_done(...) " f"finish or pause {blocker.id} first via i_am_done(...) or i_am_idle()"
"or i_am_idle()"
), ),
) )
@@ -85,8 +82,7 @@ def paused_tasks_guard(paused_tasks: list[Any]) -> Envelope | None:
"claiming new work." "claiming new work."
), ),
remediate=( remediate=(
f"resume {paused.id} (call i_will_work_on again) before starting " f"resume {paused.id} (call i_will_work_on again) before starting new work"
"new work"
), ),
) )
@@ -103,8 +99,7 @@ def pm_cannot_execute_code_guard(role: str, task_type: str) -> Envelope | None:
nice_role = role.replace("_", " ").title() nice_role = role.replace("_", " ").title()
return Envelope.not_authorized( return Envelope.not_authorized(
message=( message=(
f"{nice_role} cannot claim code tasks. " f"{nice_role} cannot claim code tasks. PMs coordinate, never execute code."
"PMs coordinate, never execute code."
), ),
remediate=( remediate=(
"PMs coordinate, never execute code. Delegate this to a " "PMs coordinate, never execute code. Delegate this to a "
@@ -136,10 +131,7 @@ def role_typed_claim_guard(role: str, task_type: str) -> Envelope | None:
if task_type in allowed: if task_type in allowed:
return None return None
return Envelope.not_authorized( return Envelope.not_authorized(
message=( message=(f"role {role!r} cannot claim a {task_type!r} task via i_will_work_on"),
f"role {role!r} cannot claim a {task_type!r} task via "
"i_will_work_on"
),
remediate=( remediate=(
"developer claims code/research/design; qa uses claim_review; " "developer claims code/research/design; qa uses claim_review; "
"documenter uses claim_doc_task" "documenter uses claim_doc_task"
@@ -147,9 +139,7 @@ def role_typed_claim_guard(role: str, task_type: str) -> Envelope | None:
) )
def sibling_sequence_guard( def sibling_sequence_guard(target_task: Any, siblings: list[Any]) -> Envelope | None:
target_task: Any, siblings: list[Any]
) -> Envelope | None:
"""Refuse claim if any earlier-sequence sibling is non-terminal. """Refuse claim if any earlier-sequence sibling is non-terminal.
Pre-gateway: claim.py:_validate_sibling_sequence 121-180. Pre-gateway: claim.py:_validate_sibling_sequence 121-180.
+1 -3
View File
@@ -1826,9 +1826,7 @@ class MessagingService(BaseService):
agent_id=str(agent_id), agent_id=str(agent_id),
channel_slug=channel_slug, channel_slug=channel_slug,
action="write", action="write",
message=( message=(f"agent {agent_id} not found; cannot validate channel access"),
f"agent {agent_id} not found; cannot validate channel access"
),
) )
return await self.send_message( return await self.send_message(
MessageCreateRequest( MessageCreateRequest(
@@ -305,9 +305,10 @@ async def test_cell_pm_cannot_claim_code_task_via_i_will_work_on() -> None:
body = env.as_dict() body = env.as_dict()
assert body["error"] == "not_authorized" assert body["error"] == "not_authorized"
assert "PM" in body["message"] or "code" in body["message"].lower() assert "PM" in body["message"] or "code" in body["message"].lower()
assert "delegate" in body["remediate"].lower() or "developer" in body[ assert (
"remediate" "delegate" in body["remediate"].lower()
].lower() or "developer" in body["remediate"].lower()
)
task_svc.claim.assert_not_awaited() task_svc.claim.assert_not_awaited()
@@ -201,9 +201,7 @@ async def test_i_am_done_proceeds_when_all_gates_pass() -> None:
journal_svc.has_reflect_for_task.return_value = True journal_svc.has_reflect_for_task.return_value = True
work_svc = AsyncMock() work_svc = AsyncMock()
work_svc.files_changed.return_value = ["foo.py"] work_svc.files_changed.return_value = ["foo.py"]
deps = _make_deps( deps = _make_deps(task=task_svc, journal=journal_svc, work_session=work_svc)
task=task_svc, journal=journal_svc, work_session=work_svc
)
c = Choreographer(deps) c = Choreographer(deps)
env = await c.i_am_done(agent_id, task_id, "all done") env = await c.i_am_done(agent_id, task_id, "all done")
@@ -234,9 +232,7 @@ async def test_i_am_done_with_catchup_runs_full_chain() -> None:
after_pr_refresh = MagicMock( after_pr_refresh = MagicMock(
**{**after_verify.__dict__, "pr_number": 8, "pr_url": "https://x/pr/8"} **{**after_verify.__dict__, "pr_number": 8, "pr_url": "https://x/pr/8"}
) )
after_submit = MagicMock( after_submit = MagicMock(**{**after_pr_refresh.__dict__, "status": "awaiting_qa"})
**{**after_pr_refresh.__dict__, "status": "awaiting_qa"}
)
task_svc = AsyncMock() task_svc = AsyncMock()
task_svc.get.side_effect = [initial, after_pr_refresh] task_svc.get.side_effect = [initial, after_pr_refresh]
task_svc.submit_verification.return_value = after_verify task_svc.submit_verification.return_value = after_verify
@@ -83,9 +83,7 @@ async def test_reap_stale_claims_swallows_unclaim_errors() -> None:
orch._claim_heartbeat_ttl = 300 orch._claim_heartbeat_ttl = 300
svc = AsyncMock() svc = AsyncMock()
svc.list_in_progress_or_claimed.return_value = [task_a, task_b] svc.list_in_progress_or_claimed.return_value = [task_a, task_b]
svc.unclaim_for_reaper = AsyncMock( svc.unclaim_for_reaper = AsyncMock(side_effect=[RuntimeError("transient"), None])
side_effect=[RuntimeError("transient"), None]
)
await orch._reap_with_service(svc) await orch._reap_with_service(svc)