From 75b4ec3996ced42259fc88e75c7530ea7ff5f651 Mon Sep 17 00:00:00 2001 From: Rohit Kushwaha Date: Mon, 13 Apr 2026 12:35:37 +0530 Subject: [PATCH] style: apply ruff format to paw-print + decision trace files Co-Authored-By: Claude Opus 4.6 (1M context) --- ee/instinct/correction_soul_bridge.py | 4 +--- ee/instinct/trace_collector.py | 2 +- ee/paw_print/router.py | 4 +--- ee/paw_print/store.py | 18 +++++++++--------- tests/cloud/test_decision_traces.py | 4 +--- tests/cloud/test_decision_traces_wiring.py | 12 +++--------- tests/cloud/test_paw_print_backend.py | 4 +--- tests/cloud/test_paw_print_ingest.py | 18 +++++++++--------- 8 files changed, 26 insertions(+), 40 deletions(-) diff --git a/ee/instinct/correction_soul_bridge.py b/ee/instinct/correction_soul_bridge.py index 97e0a129..00290019 100644 --- a/ee/instinct/correction_soul_bridge.py +++ b/ee/instinct/correction_soul_bridge.py @@ -81,9 +81,7 @@ class CorrectionSoulBridge: except Exception: logger.exception("Failed to observe correction — continuing without soul record") - async def _maybe_promote_to_procedural( - self, soul: object, correction: Correction - ) -> None: + async def _maybe_promote_to_procedural(self, soul: object, correction: Correction) -> None: """When a path has been corrected _PROMOTION_THRESHOLD times, synthesize a rule.""" if not hasattr(soul, "remember"): return diff --git a/ee/instinct/trace_collector.py b/ee/instinct/trace_collector.py index d2132d0e..7347fa95 100644 --- a/ee/instinct/trace_collector.py +++ b/ee/instinct/trace_collector.py @@ -116,7 +116,7 @@ class TraceCollector: args_hash = _hash_args(args) preview = str(result) if len(preview) > _PREVIEW_CHARS: - preview = preview[:_PREVIEW_CHARS - 3] + "..." + preview = preview[: _PREVIEW_CHARS - 3] + "..." # Dedupe identical tool+args pairs within a single trace. for existing in self.trace.tool_calls: diff --git a/ee/paw_print/router.py b/ee/paw_print/router.py index 06d1e520..fb7a5095 100644 --- a/ee/paw_print/router.py +++ b/ee/paw_print/router.py @@ -327,9 +327,7 @@ async def _pass_through_guardian(event: PawPrintEvent) -> bool: return not getattr(verdict, "blocked", False) -async def _apply_event_mapping( - widget: PawPrintWidget, event: PawPrintEvent -) -> str | None: +async def _apply_event_mapping(widget: PawPrintWidget, event: PawPrintEvent) -> str | None: """Turn a PawPrintEvent into a Fabric object when a mapping exists.""" mapping = widget.event_mapping.get(event.type) if mapping is None: diff --git a/ee/paw_print/store.py b/ee/paw_print/store.py index e9cb7989..001e417f 100644 --- a/ee/paw_print/store.py +++ b/ee/paw_print/store.py @@ -102,7 +102,8 @@ class PawPrintStore: async with self._conn() as db: db.row_factory = aiosqlite.Row async with db.execute( - "SELECT * FROM paw_print_widgets WHERE id = ?", (widget_id,), + "SELECT * FROM paw_print_widgets WHERE id = ?", + (widget_id,), ) as cur: row = await cur.fetchone() return self._row_to_widget(row) if row else None @@ -130,9 +131,7 @@ class PawPrintStore: ) as cur: return [self._row_to_widget(row) async for row in cur] - async def update_spec( - self, widget_id: str, spec: PawPrintSpec - ) -> PawPrintWidget | None: + async def update_spec(self, widget_id: str, spec: PawPrintSpec) -> PawPrintWidget | None: existing = await self.get_widget(widget_id) if existing is None: return None @@ -163,7 +162,8 @@ class PawPrintStore: await self._ensure_schema() async with self._conn() as db: cur = await db.execute( - "DELETE FROM paw_print_widgets WHERE id = ?", (widget_id,), + "DELETE FROM paw_print_widgets WHERE id = ?", + (widget_id,), ) await db.commit() return (cur.rowcount or 0) > 0 @@ -188,9 +188,7 @@ class PawPrintStore: await db.commit() return event - async def recent_events( - self, widget_id: str, limit: int = 100 - ) -> list[PawPrintEvent]: + async def recent_events(self, widget_id: str, limit: int = 100) -> list[PawPrintEvent]: await self._ensure_schema() async with self._conn() as db: db.row_factory = aiosqlite.Row @@ -238,7 +236,9 @@ class PawPrintStore: if total >= overall_per_min: return False per_customer = await self.count_events_since( - widget_id, window_start, customer_ref=customer_ref, + widget_id, + window_start, + customer_ref=customer_ref, ) return per_customer < per_customer_per_min diff --git a/tests/cloud/test_decision_traces.py b/tests/cloud/test_decision_traces.py index b43fb039..8aa0bb9f 100644 --- a/tests/cloud/test_decision_traces.py +++ b/tests/cloud/test_decision_traces.py @@ -295,9 +295,7 @@ class TestFabricSnapshotStore: assert [r.object_id for r in rows] == ["a", "b"] @pytest.mark.asyncio - async def test_snapshots_for_object_orders_newest_first( - self, store: InstinctStore - ) -> None: + async def test_snapshots_for_object_orders_newest_first(self, store: InstinctStore) -> None: older = FabricObjectSnapshot(object_id="obj_x", audit_id="aud_1") newer = FabricObjectSnapshot(object_id="obj_x", audit_id="aud_2") await store.record_fabric_snapshot(older) diff --git a/tests/cloud/test_decision_traces_wiring.py b/tests/cloud/test_decision_traces_wiring.py index 950b6ab8..9b1d915b 100644 --- a/tests/cloud/test_decision_traces_wiring.py +++ b/tests/cloud/test_decision_traces_wiring.py @@ -49,9 +49,7 @@ def client(app_with_store): class TestProposeWithTrace: @pytest.mark.asyncio - async def test_reasoning_trace_lands_in_audit_context( - self, store: InstinctStore - ) -> None: + async def test_reasoning_trace_lands_in_audit_context(self, store: InstinctStore) -> None: trace = ReasoningTrace( fabric_queries=["obj_acme"], soul_memories=["mem_q4_pricing"], @@ -81,9 +79,7 @@ class TestProposeWithTrace: assert decoded.backend == "claude_agent_sdk" @pytest.mark.asyncio - async def test_fabric_snapshots_are_keyed_to_the_audit_row( - self, store: InstinctStore - ) -> None: + async def test_fabric_snapshots_are_keyed_to_the_audit_row(self, store: InstinctStore) -> None: snapshots = [ FabricObjectSnapshot( object_id="obj_acme", @@ -201,9 +197,7 @@ class TestHydrationEndpoint: assert body["fabric_current"] == [] @pytest.mark.asyncio - async def test_hydrate_one_returns_snapshots( - self, app_with_store, client: TestClient - ) -> None: + async def test_hydrate_one_returns_snapshots(self, app_with_store, client: TestClient) -> None: _, store = app_with_store await store.propose( pocket_id="pocket-1", diff --git a/tests/cloud/test_paw_print_backend.py b/tests/cloud/test_paw_print_backend.py index 448e5b74..646b3676 100644 --- a/tests/cloud/test_paw_print_backend.py +++ b/tests/cloud/test_paw_print_backend.py @@ -277,9 +277,7 @@ class TestEventStore: assert allowed_other is True @pytest.mark.asyncio - async def test_within_rate_limit_respects_overall_ceiling( - self, store: PawPrintStore - ) -> None: + async def test_within_rate_limit_respects_overall_ceiling(self, store: PawPrintStore) -> None: widget = await store.create_widget(_widget()) now = datetime.now() for i in range(5): diff --git a/tests/cloud/test_paw_print_ingest.py b/tests/cloud/test_paw_print_ingest.py index 305de44c..f4c882ab 100644 --- a/tests/cloud/test_paw_print_ingest.py +++ b/tests/cloud/test_paw_print_ingest.py @@ -156,7 +156,8 @@ class TestSpecEndpoint: def test_empty_allowlist_allows_any_origin(self, client: TestClient) -> None: created = client.post( - "/paw-print/widgets", json=_widget_payload(allowed_domains=[]), + "/paw-print/widgets", + json=_widget_payload(allowed_domains=[]), ).json() res = client.get( f"/paw-print/spec/{created['id']}", @@ -171,9 +172,7 @@ class TestSpecEndpoint: class TestEventIngest: - def test_ingest_happy_path_records_event( - self, app_with_store, client: TestClient - ) -> None: + def test_ingest_happy_path_records_event(self, app_with_store, client: TestClient) -> None: _, store = app_with_store created = client.post("/paw-print/widgets", json=_widget_payload()).json() @@ -243,7 +242,8 @@ class TestEventIngest: return False monkeypatch.setattr( - "ee.paw_print.router._pass_through_guardian", AsyncMock(return_value=False), + "ee.paw_print.router._pass_through_guardian", + AsyncMock(return_value=False), ) created = client.post("/paw-print/widgets", json=_widget_payload()).json() res = client.post( @@ -256,9 +256,7 @@ class TestEventIngest: assert body["accepted"] is False assert body["reason"] == "guardian_rejected" - def test_event_mapping_creates_fabric_object( - self, client: TestClient, monkeypatch - ) -> None: + def test_event_mapping_creates_fabric_object(self, client: TestClient, monkeypatch) -> None: fabric = MagicMock() created_obj = MagicMock() created_obj.id = "obj_created_123" @@ -291,7 +289,9 @@ class TestEventIngest: } obj = fabric.create_object( _FakeFabricObject( - type_name="Order", properties=props, source_connector="paw_print", + type_name="Order", + properties=props, + source_connector="paw_print", ), ) awaited = await obj if hasattr(obj, "__await__") else obj