test: satisfy pyright strict annotations on the new supervise RPC tests
tracker-policy-pr / check-pr (pull_request) Successful in 13s
test / integration-docker (pull_request) Successful in 18s
lint / lint (push) Successful in 1m0s
test / unit (pull_request) Successful in 1m48s
test / integration-firecracker (pull_request) Successful in 3m23s
test / coverage (pull_request) Successful in 17s
test / publish-infra (pull_request) Has been skipped

Add parameter/return annotations to the fake resolver's propose_supervise /
poll_supervise, annotate the test helpers and the shared _ARGS payload, and
narrow the None-able poll result — no behavior change. pylint 9.83, pyright
clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-24 03:24:15 +00:00
parent 2c496dc3d0
commit 30d74cbf2b
4 changed files with 120 additions and 22 deletions
+21 -5
View File
@@ -277,16 +277,18 @@ class _SuperviseRpcFake:
supervise_status: "str | None" = None
propose_error: bool = False
poll_error: bool = False
@property
def propose_calls(self) -> list:
def propose_calls(self) -> list[dict[str, str]]:
if not hasattr(self, "_propose_calls"):
self._propose_calls: list = []
self._propose_calls: list[dict[str, str]] = []
return self._propose_calls
def propose_supervise(
self, source_ip, identity_token, *, tool, proposed_file, justification,
):
self, source_ip: str, identity_token: str, *,
tool: str, proposed_file: str, justification: str,
) -> str:
del proposed_file, justification
self.propose_calls.append(
{"source_ip": source_ip, "identity_token": identity_token, "tool": tool}
@@ -295,8 +297,12 @@ class _SuperviseRpcFake:
raise PolicyResolveError("orchestrator down")
return "prop-1"
def poll_supervise(self, source_ip, identity_token, proposal_id):
def poll_supervise(
self, source_ip: str, identity_token: str, proposal_id: str,
) -> dict[str, object]:
del source_ip, identity_token, proposal_id
if self.poll_error:
raise PolicyResolveError("orchestrator down")
if self.supervise_status is None:
return {"status": "pending"}
return {"status": self.supervise_status, "notes": "", "final_file": None}
@@ -583,6 +589,16 @@ class TestSuperviseBranch(unittest.TestCase):
self.assertEqual(403, flow.response.status_code)
self.assertIn("timed out", flow.response.get_text())
def test_poll_error_during_wait_times_out_and_blocks(self) -> None:
# A transient orchestrator error on each poll is retried until the
# deadline, then fails closed (blocked) — never forwarded unsupervised.
addon = self._supervised_addon("approved")
cast(Any, addon._resolver).poll_error = True
flow = _Flow(_Request(host="api.example.com", method="POST", body=f"k={_OPENAI_KEY}"))
_run_request(addon, flow)
assert flow.response is not None
self.assertEqual(403, flow.response.status_code)
# ---------------------------------------------------------------------------
# Inbound DLP on responses