Skip to content

fix: keep review dedupe off the poll path, require open Bitbucket PRs, and retry failed heads - #109

Merged
OkiriGabriel merged 5 commits into
open-devops-agent:mainfrom
Nitjsefnie-OSC:fix/review-queue-followup
Oct 22, 2026
Merged

OkiriGabriel merged 5 commits into
open-devops-agent:mainfrom
Nitjsefnie-OSC:fix/review-queue-followup

Conversation

@Nitjsefnie

Copy link
Copy Markdown
Contributor

Description

Moves the permanent review dedupe record off the queue prefix the poll loop scans, ignores Bitbucket pull requests that are no longer open, and lets a review that ended failed be retried by a later delivery for the same head. Restores the review-trigger regression tests that #104 added and that the merge of main into that branch dropped.

Fixes #108

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Code refactoring
  • New platform/collector support

Platform/Component

  • Core Agent
  • Kubernetes
  • CI/CD (specify: ____________)
  • Cloud Provider (specify: ____________)
  • ArgoCD
  • Docker
  • API Server
  • Tools/Executor
  • Documentation
  • Tests

Testing

  • Unit tests added/updated
  • Integration tests pass
  • Manual testing performed
  • Tested with dummy data
  • Tested in production-like environment

Test Configuration

OS: Linux
Python Version: 3.10 / 3.11 / 3.12 (CI matrix); 3.13 locally
Kubernetes Version: (not applicable)
Cloud Provider: (not applicable — MemoryStorage used throughout)

What was actually run:

  • The four affected test files locally: python -m pytest tests/test_security.py tests/test_services.py tests/test_storage.py tests/test_api.py -q — 291 passed, 2 skipped. The two skips are the completed-outcome rows of failure-only crash stages.
  • flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics — 0.
  • bandit -r . -ll — no issues at medium or higher.
  • The full suite on the project's CI: the 10-job run at e651862b77ce89629fd9ff9d6d43af41d6ff6853 is green, including the Python 3.10, 3.11 and 3.12 unit jobs, Lint, Security Scan and Docker Build. The full suite was not run locally.

The boundedness claim is pinned by a recording backend: an idle list_pending_org_ids + recover_stale_processing + claim_next pass performs zero review-object reads and four listings, at 100 and at 1000 seeded terminal reviews, for both completed and failed history. Each new guarantee has a source mutation that makes its test fail by assertion, and the crash matrix performs 26 real os._exit(19) child exits rather than injecting exceptions.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Screenshots (if applicable)

Not applicable.

Breaking Changes

Two deployment-visible changes, both deliberate:

  1. Review storage layout. A review's durable authority now lives at attempt-scoped keys outside queue/ (review_heads/<head>/<sequence>.json, review_dedupe/<attempt>.json, review_releases/<attempt>.json, review_claims/<attempt>.json) plus a normal queue/pending/<attempt>.json index. A one-time adoption pass runs at startup and converts non-terminal legacy queue/reviews/ records into the new layout, so work queued before the upgrade is claimed normally. It runs once per process start, is idempotent across concurrent starts and interrupted runs, and leaves terminal legacy records to ordinary retention. No manual migration step is required. A terminal legacy record is compacted in place, and its claim is compacted before it, exactly as the previous retention helper did; a failed legacy review's source record is then removed, with the minimal terminal claim remaining as its evidence.
  2. S3 conditional writes. S3Storage.put_json_if_absent previously fell back to a non-atomic check-then-write when the SDK rejected IfNoneMatch, and treated a 409 ConditionalRequestConflict as proof that the object existed. Both are now explicit failures, and exists no longer reports a failed HEAD request as absence. A deployment on an S3 SDK too old to support conditional writes will now fail loudly at the first conditional create instead of silently running without dedupe.

Additional Notes

What is bounded, and what is not:

  • Bounded: review-object reads on the poll path, and the admission lookup, which lists only the exact head's slot prefix and therefore scales with that head's attempt count rather than with total history.
  • Not bounded: the global key listing in list_pending_org_ids for org discovery, the one-time startup adoption scan, retention's own sweep, and the retained minimal metadata (slots, terminal receipts, terminal fences). The first two were already history-dependent before this change; they are disclosed rather than fixed, because removing them needs a separate org-discovery design.

Two policy notes:

The review-trigger regression tests from #104 are restored against the new layout. TestBitbucketWebhookSignature and every other pre-existing class in tests/test_security.py are byte-identical to main, and the six imports left dangling by the merge are used again.

Reviewer Checklist

  • Code quality is acceptable
  • Tests are comprehensive
  • Documentation is updated
  • No security concerns
  • Performance impact is acceptable

Generated by DeepSeek V4.1 Flash 1017 (lead), GPT-6.1 Sol (implementation), GPT-6 Astra (review)

Nitjsefnie and others added 5 commits October 22, 2026 12:36
Restore review trigger regressions, restrict terminal webhook payloads, and retain durable evidence through queue and retention interruptions.

Co-Authored-By: GPT-6.1 Sol <[email protected]>
Persist each failed attempt before releasing its marker, preserve completed-head dedupe, and keep retention cleanup scoped to the attempt.

Co-Authored-By: GPT-6.1 Sol <[email protected]>
@OkiriGabriel
OkiriGabriel merged commit e6dfb01 into open-devops-agent:main Oct 22, 2026
10 checks passed
@Nitjsefnie

Copy link
Copy Markdown
Contributor Author

Thanks for merging. Some context on how this PR happened: it came out of spare weekly AI-coding-subscription usage. I built Overflow (free, MIT, no money involved) so maintainers can price issues for people with spare usage to pick up, and credit for merged work pays for your own issues later: https://github.com/Nitjsefnie/Overflow. This and any future PRs don't depend on any of that, and nothing changes whether you look at it or not. If you'd like more people with spare usage picking up your issues, registering a public repo is one form. No reply needed, and I won't bring it up again.

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.

Review queue rescans every historical review, Bitbucket queues reviews for non-open pull requests, and a failed review never retries

2 participants