Skip to content

fix: address whole-SDK review findings for 0.2.0 - #5

Merged
DeevsDeevs merged 13 commits into
feature/policy-targetingfrom
fix/review-findings
Dec 2, 2026
Merged

DeevsDeevs merged 13 commits into
feature/policy-targetingfrom
fix/review-findings

Conversation

@DeevsDeevs

Copy link
Copy Markdown
Collaborator

Stacked on feature/policy-targeting (#4). Addresses the remaining findings from the whole-SDK review (finding 2 landed directly on feature/policy-targeting in 20d2e74).

Finding Commit Summary
1 c55073a Require non-empty rules on policies.create() and metrics.create() (sync and async) + CHANGELOG.md breaking-change note
3 cd84334 Accept optional role= on Event.tool_call, tool_result, tool_definition, and agent
4 0f3c7bc Raise WebhookVerificationError with from None in Webhooks.parse so raw payload values cannot leak via __cause__ tracebacks
5 79c84d1 Define local variables with literals across README/cookbook snippets, replace /api/usage raw-request example in README.md, and document client.billing.usage() and client.users.properties
6 475527b Expose optional trace_id and span_id on artifacts.check() (sync and async)
7 b359ca0 Reset _ws on stream close(), wrap binary WebSocket frames as StreamError("invalid_frame", ...), and honor client read timeout while waiting for ready in connect()
8 d96178f Delete unused Body type alias from _types.py
9 de7596c Return NotImplemented in Expression.__and__ on non-Expression operands and reject bare str/bytes in Field.is_in/not_in
10.1, 10.2 252747e Reject "reset" in Event.reference and default UserRisk.total_strike_points = 0 and strikes = []
11 1330133 Add unit test coverage for policy/metrics fields, shadow-only checked, client.events.stream/check_stream wiring, AsyncCheckedStream async-generator aclose(), path_param(""), and async retries

Make rules required on Policies.create and AsyncPolicies.create (and
inherited Metrics/AsyncMetrics) and raise ValueError when rules is empty,
matching the API which rejects omitted or empty rules with HTTP 400.

BREAKING CHANGE: policies.create() and metrics.create() now require a
non-empty rules sequence.
Add optional role: Role | None = None to Event.tool_call, tool_result,
tool_definition, and agent so callers can override Policy direction on
non-message Events without dropping down to raw Event(...).
Raise WebhookVerificationError with 'from None' instead of chaining the
raw pydantic.ValidationError so webhook payload content is not leaked
into formatted tracebacks. Assert __cause__ is None and formatted
tracebacks omit payload values.
…ent usage and user properties

Define local variables with simple literals in cookbook snippets (and
type openai_tokens in docs/streaming.md), replace wrapped /api/usage in
README.md with a placeholder path, document client.billing.usage() in
docs/usage.md, and document client.users.properties in
docs/strikes-and-webhooks.md.
Expose optional trace_id and span_id parameters from ArtifactCheckRequest
on Artifacts.check and AsyncArtifacts.check.
…ect timeout

Reset _ws to None in EventStream.close and AsyncEventStream.close so
post-close append/finish/receive raise WhiteCircleError instead of
silently dropping frames; catch WebSocketInvalidTypeReceived and raise
StreamError('invalid_frame', ...); honor the client read timeout while
waiting for ready in connect().
…es in is_in/not_in

Return NotImplemented when Expression.__and__ receives a non-Expression
operand so Python raises TypeError instead of AttributeError, and reject
bare str/bytes values in Field.is_in and Field.not_in both statically
and at runtime.
Restrict Event.reference to non-reset SelectorType values (raising
ValueError at runtime on 'reset') and default UserRisk.total_strike_points
to 0 and UserRisk.strikes to [] to match UserRiskResponse in OpenAPI.
…and async retries

Add unit tests for country_codes/severity_level_id on create,
event_selector_list/country_codes on update, metrics delete/get/list,
shadow-only EventCheckResult.checked, client.events.stream/check_stream
wiring, AsyncCheckedStream async-generator aclose(), path_param(''), and
async GET 502/504, 429 backoff, and ConnectError retries. Avoid awaiting
sync stream()/check_stream() methods in test_events_require_an_environment.
@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Team
  • Run ID: ec6608a6-f136-43a9-94f1-37df9a3d75a1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Document that tool/arguments defaults to the user side (so role_list=[]
or ['user'] judges it as is) and recommend passing role='assistant' on
Event.tool_call(...) so an assistant-only Policy judges an agent's own
tool calls. Update CHANGELOG.md and extend test_tool_arguments_targeting
to verify the role='assistant' override live.
…fallback

Only fall back to EventSelector.model_construct when field and kind are
None or str, so malformed items with non-string field or kind raise
ValidationError. Add parametrized tests covering malformed selector items.
@DeevsDeevs
DeevsDeevs merged commit 54f0b29 into feature/policy-targeting Dec 2, 2026
8 checks passed
@DeevsDeevs
DeevsDeevs deleted the fix/review-findings branch December 2, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant