Skip to content

Add wait_for_reviews: wait for several reviews under one shared deadline - #165

Open
mamane19 wants to merge 1 commit into
prooflinedev:mainfrom
mamane19:wait-for-reviews
Open

mamane19 wants to merge 1 commit into
prooflinedev:mainfrom
mamane19:wait-for-reviews

Conversation

@mamane19

@mamane19 mamane19 commented Dec 3, 2026 •

Copy link
Copy Markdown

What

Adds wait_for_reviews(organization_id, review_ids, *, timeout=300, head_commit_shas=None) -> dict[UUID, ReviewOutcome] to ProoflineClient and AsyncProoflineClient, with a README section and tests in tests/test_http.py. scripts/contracts.py lists it with the other client helpers that are not API operations.

Behaviour

  • One deadline for the batch. The sync client waits in the order given and gives each review what is left of the deadline; a review it reaches after the deadline is TIMED_OUT without a request. The async client waits for every review at once.
  • Each review goes through wait_for_review, so it keeps that method's polling, retry and commit-pin policy.
  • A read that raises ProoflineError makes that review FAILED, with no review and a reason that names only the HTTP status, so repr and str show no server text. The other reviews keep going.
  • timeout=0 reads each review once. A review named twice is waited on once. Results come back in the order given.
  • timeout, the review IDs and every pin are checked before any request. A review ID that is not a UUID, or a pin for a review outside the batch, raises ValueError.

Checks

python3 scripts/check.py passes: generation check, contracts, ruff, mypy, 252 tests, and the wheel and sdist installs.

@dboles99

dboles99 commented Dec 5, 2026

Copy link
Copy Markdown

Request changes: one finding.

Sync and async disagree on a review that already finished. The sync wait_for_reviews waits in order, so when the first review spends the shared deadline, every later review gets TIMED_OUT without a request (the else branch). The async client starts all waits at once and reads each one. Same input, two answers: a review that finished long ago is TIMED_OUT from the sync client and COMPLETED from the async one.

Repro: two reviews, the first stays RUNNING, the second is already COMPLETED, timeout=12. Sync returns TIMED_OUT for both; async returns TIMED_OUT and COMPLETED.

Fix: give a review reached after the deadline one read (timeout=0, which wait_for_review already treats as a single read) instead of a synthesized outcome. Cost: each late read can run the batch past the deadline by one request, so the docstring and README should say so. Round-robin polling in the sync client would keep the deadline exact but rewrites the loop; the single read is the smaller, safer change.

Branch: https://github.com/dboles99/sdk-python/tree/review/pr-165-read-after-deadline (cbfaa68): the change in both clients, docs, and a test that fails on the sync client before it and passes after. Full suite 244 passed; ruff, format and mypy clean.

The rest checks out: one monotonic deadline, duplicates waited on once, a per-review FAILED, and validation before any request.

@mamane19

mamane19 commented Dec 6, 2026

Copy link
Copy Markdown
Author

Thanks for running it. The sync result is what the brief asks for: a review that starts after the deadline has passed returns TIMED_OUT without a request, and the sync client waits in the order given, so reading each late review once would run the batch past its deadline by one request per review. The README now says this directly: the sync client can report TIMED_OUT for a review the async client reports COMPLETED.

This branch has not been deployed

No deployments
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.

2 participants