fix: persist retry state, add API retry logic, raise on GraphQL errors#76
Merged
fix: persist retry state, add API retry logic, raise on GraphQL errors#76
Conversation
- Persist _retry_counts as retry_counts_json column (schema v8) Survives crash/resume, prevents infinite retry loops - Add exponential backoff retry to _run_gh() for transient errors (rate limits, 5xx, network timeouts) — up to 3 retries - Raise GitHubAPIError on GraphQL errors with no data in get_unresolved_review_comments() and get_latest_copilot_review_thread_ts() instead of silently returning empty results Closes #74
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
Addresses all three items in issue #74 — retry state persistence, GitHub API retry logic, and silent GraphQL error handling.
Changes
1. Persist _retry_counts for crash recovery (schema v8)
retry_counts_json TEXTcolumn. Schema v7 to v8, migration entry, _TASK_COLUMNS updated.__init__loads_retry_countsfromtask["retry_counts_json"](JSON deserialized). After incrementing a retry counter in_do_verify_push()or_do_verify_pr(), persists viaupdate_task(task_id, retry_counts_json=json.dumps(...)).Before: If the orchestrator crashed and resumed during VERIFY_PUSH,
_retry_countsreset to{}, allowing infinite retry loops.2. Exponential backoff retry in _run_gh()
_run_gh()now retries up to 3 times with exponential backoff (1s, 2s, 4s) for transient errors.rate limit,abuse detection,server error,502,503,504,timed out,connection refused,connection reset,network is unreachable.check=Falsecallers are unaffected — they still get empty stdout on failure.3. Raise GitHubAPIError on GraphQL errors
get_unresolved_review_comments()andget_latest_copilot_review_thread_ts()now raiseGitHubAPIErrorwhen GraphQL returns errors with no usable data.try/exceptaround these calls will catch and handle the new exceptions.Tests Added (10 new)
test_retry_counts_json_persists+ migration test updated (test_persistence.py)test_retries_on_rate_limit(test_github_api.py)test_no_retry_on_permanent_error(test_github_api.py)test_retries_on_server_error(test_github_api.py)test_gives_up_after_max_retries(test_github_api.py)test_check_false_no_raise(test_github_api.py)test_unresolved_comments_raises_on_graphql_error_no_data(test_github_api.py)test_unresolved_comments_partial_error_returns_data(test_github_api.py)test_latest_thread_ts_raises_on_graphql_error_no_data(test_github_api.py)test_latest_thread_ts_partial_error_returns_data(test_github_api.py)Verification
Closes #74
🤖 autopilot-loop