Skip to content

Add on_poll callback to wait_for_review in sync and async clients - #72

Closed
abhish12345 wants to merge 75 commits into
prooflinedev:mainfrom
abhish12345:improve-client-resilience
Closed

abhish12345 wants to merge 75 commits into
prooflinedev:mainfrom
abhish12345:improve-client-resilience

Conversation

@abhish12345

@abhish12345 abhish12345 commented Nov 20, 2026 •

Copy link
Copy Markdown

Summary

Add an optional on_poll callback to wait_for_review in both ProoflineClient and AsyncProoflineClient.

Problem Statement

When waiting for a review in CI/CD pipelines, CLI tools, or automated services, reviews can take several minutes to settle. Previously, wait_for_review polled silently without giving callers any visibility into intermediate assessment progress or execution states.

Solution & Approach

  • Added on_poll: Callable[[CustomerReviewDetail], None] | None = None to ProoflineClient.wait_for_review.
  • Added on_poll: Callable[[CustomerReviewDetail], Awaitable[None] | None] | None = None to AsyncProoflineClient.wait_for_review, supporting both sync callbacks and async coroutines seamlessly.
  • Callers can now stream live progress, check active assessment states, and report status without re-implementing custom polling logic.
  • Backward compatibility is 100% preserved.

Verification & Testing

  • Added unit tests in tests/test_http.py (test_wait_for_review_invokes_on_poll_callback) verifying callback execution in both sync and async clients against the mock HTTP server.
  • Verified with pytest (all tests passing).
  • Verified with mypy and ruff (no type or lint errors).

Development Prompts

  • "Explore sdk-python repository and run the test suite to establish a passing baseline."
  • "Investigate client.py and outcomes.py to identify developer-experience improvements for review polling."
  • "Implement an optional on_poll callback in wait_for_review for both ProoflineClient and AsyncProoflineClient."
  • "Ensure AsyncProoflineClient supports both synchronous callbacks and asynchronous coroutines via isawaitable."
  • "Add comprehensive unit tests in tests/test_http.py covering sync and async polling callback execution."
  • "Run ruff linter and mypy type checker across proofline package to ensure clean code quality."
  • "Verify that all unit tests pass with pytest."

…ining timeout and test sync callback in async client
…ll, close coroutines on expired budget, distinguish callback TimeoutError, and add timeout test
…ome on deadline expiry, record callback timeout distinction, and assert cancellation
…deadline expiry to protect classified mismatch from cancellation exceptions
…ple callback task cancellation from wait return, and add tests
…andle cancellation during async_wait, and test mutation across all modes
…udget, and assert invocation count in mutation test
…ous callbacks, and cancel/observe Futures and Tasks on budget expiry
…, record timeout winner vs callback completion, and add watchdog timeout test
…umption, and latch callback error propagation against absolute deadline
…ck exceptions, record callback completion time, and verify cancellation signaling
…ne callback timestamp on future, and test coroutine isolation
…cellation and test classified outcome on callback timeout
…ith UNSET, close generators, and document optional sync on_poll
…ults, test pending future cancellation, and isolate watchdogs in subprocess
…n_poll contract and cancellation failure suppression, move pending future test into watchdog subprocess, and test inline callback mutation isolation
…ted futures directly, close unstarted coroutines safely, and verify suspending callback within budget
…onError, skip closed loop futures, and assert nested mutation isolation
…e exceptions before loop check, runner deadline check, and in-memory deep snapshot test
…closed before future wait, close suspended coroutines, and thorough test assertions
…ed tuples in finalization, copy memoryviews, reject unsupported mutables, and enforce safe tuple size
…ct immutable scalar types, copy container subclasses, buffer size limits, document snapshot failure modes, and in-memory stubbed watchdog
…e unstarted generators/coroutines inline, traverse private and dict slots, check multidimensional buffer nbytes, and bound timeout elapsed times
…line before coroutine validation, isolate tuple subclasses, and assert delivery order with request counts
…ining budget after setup, document copy error mismatch, and assert watchdog remaining budget
…ember checks, tuple constructor fallbacks, memoryview shape, and task creation guards
…ard, empty set attributes, memoryview cast errors, and test assertions
…e exception retrieval, bytearray subclass preservation, slot descriptor enumeration, custom tzinfo copying, and test fixtures
…length with element format and stride, isolate wrapper context from transport deadline, traverse reachable state through identity-hashed attributes for custom-hashed members, document backing buffer size limit, clarify callback cancellation precedence in docstring, and strengthen watchdog producer/wrapper teardown assertions
…ll invocation, support array.array and bytearray subclass exporters with attribute expansion and scalar shape=(), traverse custom hash dependencies through tuple elements, document cancellation during mismatch in README, and harden watchdog teardown and test assertions
…ces, instantiate array.array subclasses via __new__ with args, reject unlisted mutable class attributes, traverse custom-hash members across container graphs, validate loop ownership on detached tasks, document completion-time callback cutoffs, and harden watchdog and fixture teardowns
…for unhashable tasks, validate SDK requests in watchdog against test server, test timely future failure with clock advance before waiter resumption, track wrapper exception in case 4, document already-done future return cutoff, close rejected sync on_poll adapters, clear deadline around async_create_task, reject mutable class attrs on buffer and set subclasses, and traverse frozensets in readiness walk
…rectly await worker in case 3b, cleanup wrappers in case 4 finally, queue wrapper before cancelling in case 6b, test class-state rejection for set and buffer views, test custom hash reading deferred dict through frozenset, await waiter_coro_task whenever present in case 6, timestamp callback return for already-done futures, close fresh awaitable adapters discarded after deadline, reject frozenset subclasses with mutable class attributes, preserve layout for strided memoryviews over bytes, check backing buffer size, and collect set members in deadline-checked batches
… docstrings and README, include inline cancellation in mismatch exception list, retrieve completed task exception before loop check in detachment, use shared guard and cleanup discarded awaitables in all unstarted exits, check completion time before taking future timeout branch, resolve self-blocked custom-hash frozenset members, race worker startup against polling task in case 3b, capture and cancel callback task in case 3 finally, settle fixture in SyncCancelRaisingFuture teardown, and assert first snapshot head_commit_sha is UNSET
…entered runner in case 6b teardown, resume normal polling after reading completed on_poll future, cleanup discarded awaitables on task creation error, preserve future close hooks, verify membership of fallback-built frozensets after deferred writes, memoize frozenset clones before attribute assignment, pass current_target_id on dict key readiness check, handle None members in frozenset fallback, reject tuple subclasses with mutable class attrs, and test frozenset custom hash with deferred dict
…xternal tracking, detach futures before marker check, hold strong references to detached futures, omit close on invalid non-awaitable returns, reject mutable class attrs on datetime subclasses and custom tzinfo, defer unresolved attribute assignments in frozensets, reapply strides to empty memoryviews, preserve bytes exporter subclasses, race startup waits in cases 3 and 7, suspend async mutating callback before edits, and let overdue coroutine fail before waiter processes completion in case 4
…gth checks, memoryview strides and buffer sharing, and race condition test coverage
…xporter mutability sharing, loop-scoped detached futures cleanup, and catch late system exceptions in runner
…e, check bytes subclass length, use native byte counts for memoryview exporter, loop-scoped detached futures fallback, check cancellation before callback return validation, and improve mismatch and overdue test coverage
…ble, exact bytes size check, unhookable loop test, loop close store clearing order, bytes subclass native buffer reconstruction, baseline cancellation comparison, and documentation clarifications
…ple bytes length bound, bytes subclass memoryview exporter fallback, dictionary key lookup validation, natural pending cancellation delivery, and detached task loop close cleanup
… pre-materialization bytes bounds, mutable set membership validation, independent cancellation check, README awaitable deadline rules, and test improvements
…ng future observer removal, loop close exception draining, Case 3 bounded wait, and immutable bytes cutoff documentation
…odule builtins, doc signals and cancellation, bound Case 3b joins, observer removal, exception draining, and test fixtures
…callback unregistration, Python 3.10 cancellation tracking, frozenset subclass __dict__ alias fixtures, nested state dict lookup fixture, and mismatch callback event synchronization
…subclass dict finalization, dict source order, wait loop budget recheck, and watchdog assertions
…cancellation qualification and observation, and review head commit assertion
…rapper deadline operator, wait loop completion break, and test cleanup settling
… memoryview reconstruction, strict deadline comparison, Case 6c bounded wait, and mismatch review isolation
…cutoff, Case 6a bounded join, callback removal checks, mismatch field assertions, and ctypes write-through test
…ding future registration completion, fetch timeout propagation, and test join bounds
…covering span byte casting, multidimensional byte view preservation, already-failed exact-deadline assertion, and test quality improvements
…uction, ctypes._CFuncPtr guard, exporter slot copying, cyclic frozenset deadline checking, and bounded joins
…es span row slicing, subprocess sys import, Case 3b result check, multi-element reverse slice assertions, and controlled mismatch callback synchronization
…D ctypes physical span reconstruction, post-done deadline cutoff, README limit qualification, and test completion tying
@abhish12345 abhish12345 closed this by deleting the head repository Nov 27, 2026
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