From b1cfac1fd8a83fc61456efd41011719830125cd9 Mon Sep 17 00:00:00 2001 From: Calvin Grunewald Date: Tue, 30 Jun 2026 14:18:30 -0700 Subject: [PATCH 1/2] feat(harness): add register_stream_scenario to the Python HarnessServiceClient MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The generated SSE stream contract tests call `harness.register_stream_scenario(...)`, but the hand-written Python HarnessServiceClient only had `register_scenario` (channels) — so the tests failed with AttributeError. Add the SSE counterpart, POSTing to `/stream-scenarios` (the TS client's `registerStreamScenario` equivalent; the endpoint shipped in channel-harness 0.3.0/0.4.0). Verified: with channel-harness 0.4.0 + this method, the regenerated tests/contract/streams/test_ai.py passes 2/2 against the live harness. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/archastro/phx_channel/harness.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/archastro/phx_channel/harness.py b/src/archastro/phx_channel/harness.py index 76d68c5..f7f914a 100644 --- a/src/archastro/phx_channel/harness.py +++ b/src/archastro/phx_channel/harness.py @@ -81,6 +81,18 @@ async def register_scenario(self, scenario: dict[str, Any]) -> None: if r.status_code != 201: raise HarnessServiceError(f"register_scenario failed: {r.status_code} {r.text}") + async def register_stream_scenario(self, scenario: dict[str, Any]) -> None: + """Register a scenario for an SSE streaming route (``"METHOD /path"``). + + See the TS ``StreamScenarioRequest`` / ``StreamAction`` types for the + JSON shape — the server validates and returns 400 on invalid bodies. + """ + r = await self._http.post(f"{self.control_url}/stream-scenarios", json=scenario) + if r.status_code != 201: + raise HarnessServiceError( + f"register_stream_scenario failed: {r.status_code} {r.text}" + ) + async def observations( self, topic: str | None = None, event: str | None = None ) -> list[dict[str, Any]]: From 9454213b73a95d2617a7ffbd1e1ed724e466889f Mon Sep 17 00:00:00 2001 From: Calvin Grunewald Date: Tue, 30 Jun 2026 14:22:04 -0700 Subject: [PATCH 2/2] style: ruff-format register_stream_scenario (single-line raise) --- src/archastro/phx_channel/harness.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/archastro/phx_channel/harness.py b/src/archastro/phx_channel/harness.py index f7f914a..629e629 100644 --- a/src/archastro/phx_channel/harness.py +++ b/src/archastro/phx_channel/harness.py @@ -89,9 +89,7 @@ async def register_stream_scenario(self, scenario: dict[str, Any]) -> None: """ r = await self._http.post(f"{self.control_url}/stream-scenarios", json=scenario) if r.status_code != 201: - raise HarnessServiceError( - f"register_stream_scenario failed: {r.status_code} {r.text}" - ) + raise HarnessServiceError(f"register_stream_scenario failed: {r.status_code} {r.text}") async def observations( self, topic: str | None = None, event: str | None = None