feat: sync to panel server v0.2.0 - #2
Conversation
There was a problem hiding this comment.
Pull request overview
Synchronizes the Python SDK with panel server API v0.2.0: the monolithic panel_sdk/__init__.py is broken into modules (client, rater, errors, types, _signing, _scrubber, _retry), the operator client surface is reshaped (new submit_judgment, get_trace, scrubber_url constructor arg, reworked ingest_unit/ingest_trace, removed engine_version/fetch_unit/fetch_trace), and a new RaterClient/AsyncRaterClient is exposed. HMAC signing now runs against the exact JSON bytes that are sent, and scrubber attestation is emitted as a short-lived HS256 JWT.
Changes:
- Restructure package into modular files and bump to
0.2.0; replaceverify_tokenpath with/api/verify. - Rework
PanelClient/AsyncPanelClient: addsubmit_judgment,get_trace, scrubber proxy iningest_unit, exact-byte HMAC signing, new attestation JWT shape. - Replace existing tests with a new respx-based suite and rewrite the README/CHANGELOG.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| panel_sdk/init.py | Now a thin re-export façade for the new modules. |
| panel_sdk/client.py | New sync+async client with rebuilt ingest/scrub/attestation/judgment flow. |
| panel_sdk/_scrubber.py | New off/self-sign/proxy helpers — currently unused dead code. |
| panel_sdk/_signing.py | Canonical JSON, HMAC, and HS256 JWT helpers. |
| panel_sdk/_retry.py | Typed error parsing and (unused) retry/backoff helpers. |
| panel_sdk/errors.py | PanelError, PanelRateLimitError, PanelScrubberError. |
| panel_sdk/rater.py | New site-key-only rater client (sync + async). |
| panel_sdk/types.py | IngestUnitInput, IngestTraceInput, TraceStatus, VerifyResult, TraceResult. |
| tests/test_client.py | Removed (replaced by tests/test_sdk_sync.py). |
| tests/test_sdk_sync.py | New respx tests for ingest HMAC, scrubber attestation, trace, judgment, async parity. |
| README.md | Expanded with sync+async examples for the new method surface. |
| CHANGELOG.md | New v0.2.0 entry (does not accurately describe shipped code). |
| pyproject.toml | Version bump to 0.2.0. |
| .pr_body.md | Mirror of the PR description committed to the repo. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Sync Python SDK to panel server API v0.2.0 with exact-byte HMAC signing and scrubber attestation support.
New/updated methods
PanelClient.ingest_unit(type, payload, *, pool="public", scrubber_text=None) -> dictPanelClient.ingest_trace(source_agent, blob, *, trace_id=None) -> dictPanelClient.get_trace(trace_id) -> dictPanelClient.submit_judgment(unit_id, rater_id, choice, latency_ms, ...) -> dictPanelClient._sign_hmac(raw_body: bytes) -> strPanelClient._scrubber_attestation(output_hash_hex: str) -> str | NoneAsyncPanelClientfor each method above.Server route alignment
~/panel/app/api/units/ingest/route.ts~/panel/app/api/v1/traces/route.ts~/panel/app/api/verify/route.ts~/panel/app/api/judgments/route.ts~/panel/lib/operator-mint.ts~/panel/lib/scrubber-attestation.tsScrubber attestation handling
POST /v1/scrubwhenscrubber_textis provided andscrubber_secretis configured.{output_hash, iat, exp, jti}whereexp = iat + 60.X-Scrubber-Attestation.Types and docs
IngestUnitInput,IngestTraceInput,TraceStatus.Tests