1.4b — Python SDK precheck() kwargs + configurable retry backoff#14
Open
Shaivpidadi wants to merge 1 commit intodevfrom
Open
1.4b — Python SDK precheck() kwargs + configurable retry backoff#14Shaivpidadi wants to merge 1 commit intodevfrom
Shaivpidadi wants to merge 1 commit intodevfrom
Conversation
… tests Polishes the 1.4a scaffolding to match TASKS.md §1.4b acceptance criteria: - `precheck()` / `async_precheck()` accept `**kwargs` — per-call override of `timeout`, `max_retries`, retry tuning, plus request-body fields (`scope`, `user_id`, `corr_id`, `tags`, `payload`). Unknown kwargs pass through into the request body for forward compat with server schema growth. - Exponential backoff is now fully configurable via `retry_initial_delay`, `retry_backoff_factor`, `retry_max_delay`, and optional `jitter`. Defaults preserve the existing 1s / ×2 / no-jitter behavior. - `_is_retryable_status` and `_compute_retry_delay` factored into module helpers; async path no longer falls back to hard-coded `2**attempt`. Tests added: - `test_precheck_result_fields_populated_from_response` — all 4 fields (decision, redacted_content, reasons, latency_ms) populated from JSON - `test_precheck_forwards_kwargs_into_request_body` — body includes scope/user_id/corr_id/tags/payload and pass-through unknowns - `test_precheck_uses_configurable_backoff` — observed sleeps match initial * factor^attempt without jitter - `test_precheck_max_retries_override_via_kwargs` — per-call limit respected - `test_precheck_does_not_retry_on_4xx` — 4xx surfaces immediately - `test_precheck_timeout_override_via_kwargs` - `test_async_precheck_result_fields_populated`, `test_async_precheck_max_retries_exceeded` All 44 existing + new tests pass; existing retry/payload tests unchanged. Refs: GOV-575
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
precheck()/async_precheck()now accept**kwargsfor per-call overrides (timeout, retry tuning,scope,user_id,corr_id,tags,payload) plus forward-compatible pass-through of unknown body fields.retry_initial_delay,retry_backoff_factor,retry_max_delay, and optionaljitter; defaults preserve the existing 1s / ×2 behavior._is_retryable_status/_compute_retry_delayhelpers; the async path no longer falls back to hard-coded2**attempt.max_retries, 4xx non-retry, timeout override, async field population, async max-retries-exceeded.GovernsAI Tracker issue
GOV-575 (4e8a9405-60fb-489e-99e3-d0f9df5f730d)
TASKS.md ref: §1.4b
Reviewers
Tagging Nexus (code quality) and Cipher (security/arch) — both approvals required.
Test plan
pytest tests/— 44 passed, 2 integration skippedblack --check src/ tests/on changed files — cleanmypy src/governs_ai/client.py --ignore-missing-imports— no new errorsprecheck(...)returns a real decision (reviewer to run withGOVERNS_LOCAL_PRECHECK_URL+-m integration)