Skip to content

Wait for a deployment review by its public key - #55

Open
coolman-97 wants to merge 1 commit into
prooflinedev:mainfrom
coolman-97:feat/wait-for-deployment-review
Open

coolman-97 wants to merge 1 commit into
prooflinedev:mainfrom
coolman-97:feat/wait-for-deployment-review

Conversation

@coolman-97

@coolman-97 coolman-97 commented Nov 16, 2026 •

Copy link
Copy Markdown

Who this helps

A deploy job knows its deployment's public key, not the review id. Today it has to call get_deployment_review in its own loop and decide when the review is settled, which means copying the deadline, backoff and completion rules that wait_for_review already owns, or getting them subtly wrong (treating COMPLETED with missing check receipts as a pass, for example).

wait_for_deployment_review(organization_id, public_key, *, timeout=300) on both ProoflineClient and AsyncProoflineClient gives that job one call that returns the same ReviewOutcome a review wait does:

result = client.wait_for_deployment_review(org_id, os.environ["PROOFLINE_DEPLOYMENT_KEY"], timeout=600)
if result.status != "COMPLETED":
    raise SystemExit(f"Deployment review is {result.status}: {result.review_url}")

Decisions

  • The first response pins the review id. Every later poll passes it to outcome(..., review_id=...), so if the key starts resolving to a different review the wait raises urn:proofline:sdk:invalid-response instead of returning another deployment's verdict. The pin is also applied to the final TIMED_OUT outcome, so a drifted record is never retained as the last observation.
  • No new outcome rules. Completion, gaps, FAILED vs STOPPED, the 5s to 60s backoff, the shared DEADLINE budget and the "transport timeout at the deadline means TIMED_OUT" behavior all come from the existing code paths. The timeout validation moved into a small _wait_timeout helper that both waits use.
  • review_url. Once the id is known it is the normal review URL. If the wait times out before any response, it falls back to /orgs/by-id/{org}/reviews/deployments/{key} with the key percent-encoded. I couldn't confirm that console route from the public contract; happy to switch the fallback to whatever the console actually serves.
  • Nothing under proofline/_generated/ changed. scripts/contracts.py lists the new method as a hand-written helper next to wait_for_review.

Verification

New tests in tests/test_http.py, each run for sync and async against the loopback server:

  • pending, running, completed: polls the escaped deployment path three times with [5, 10] delays and reports the pinned review URL
  • key drift on the second and on the third poll: raises invalid-response and stops polling
  • timeout=0: no request, TIMED_OUT, deployment URL; a 30s budget keeps the last running record and the review URL; negative, inf and nan timeouts are rejected
  • 403 refusal: surfaces the typed problem after one request

python scripts/check.py (generation check, contracts, ruff, mypy, full pytest, wheel and sdist install smoke) passed on Ubuntu via this repo's own Checks workflow on my fork: https://github.com/coolman-97/sdk-python/actions/runs/43921450158

One note from running locally on Windows: generate.py --check reports a diff there because write_text emits CRLF, and two deadline tests (test_streaming_and_resolution_keep_deadline_outcomes_explicit, test_body_stream_deadline_does_not_turn_authority_into_timeout) are timing sensitive on Windows. Both happen on a clean main too and are unrelated to this change.

A deploy job knows its deployment's public key, not the review id, so it
had to poll get_deployment_review itself and decide when the review had
settled. wait_for_deployment_review does that on both clients with the
same deadline, backoff and outcome rules as wait_for_review.

The first response pins the review id. A key that later resolves to a
different review raises an invalid-response error instead of returning
another review's result.
@coolman-97
coolman-97 force-pushed the feat/wait-for-deployment-review branch from d1edc71 to 6399d98 Compare November 16, 2026 17:44

mohsen1 commented Nov 17, 2026

Copy link
Copy Markdown
Member

Codex review: Validate the first response against the requested deployment key and require DEPLOYMENT kind before reporting completion. _pinned currently accepts any first returned ID as authoritative. Add wrong-first-ID and wrong-kind regressions, preserving the exact-head polling changes now on main.

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