Skip to content

repair branch reconciliation and PR lifecycle sync#216

Merged
rostilos merged 1 commit into
mainfrom
1.6.1-rc
Jul 6, 2026
Merged

repair branch reconciliation and PR lifecycle sync#216
rostilos merged 1 commit into
mainfrom
1.6.1-rc

Conversation

@rostilos

@rostilos rostilos commented Jul 6, 2026

Copy link
Copy Markdown
Owner
  • add full branch reconciliation service outside BranchAnalysisProcessor
  • sync stale open PR states from VCS during full reconcile
  • refresh existing PR branch metadata and reopen state on active PR events
  • route overlapping webhook events with payload-aware handler matching
  • mark merged/declined PRs from provider close events
  • add provider PR state mapping tests for GitHub, Bitbucket, and GitLab
  • harden incremental RAG updates with batching and retry handling

Summary by CodeRabbit

  • New Features

    • Added PR status syncing so open pull requests can be reconciled with the source control provider.
    • Improved webhook handling to update PR state on merge/close events across Bitbucket, GitHub, and GitLab.
    • Expanded branch reconciliation to recover missing PR numbers and include merged PR data during analysis.
  • Bug Fixes

    • Existing pull requests now refresh branch names and reopen correctly when new webhook data arrives.
    • Incremental RAG updates now use batching and retries for more reliable processing.

- add full branch reconciliation service outside BranchAnalysisProcessor
- sync stale open PR states from VCS during full reconcile
- refresh existing PR branch metadata and reopen state on active PR events
- route overlapping webhook events with payload-aware handler matching
- mark merged/declined PRs from provider close events
- add provider PR state mapping tests for GitHub, Bitbucket, and GitLab
- harden incremental RAG updates with batching and retry handling
@rostilos rostilos merged commit 74e59a6 into main Jul 6, 2026
1 check was pending
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9e6e994f-d052-459c-ab87-288518a43dad

📥 Commits

Reviewing files that changed from the base of the PR and between 5015b17 and 940558b.

📒 Files selected for processing (35)
  • java-ecosystem/libs/analysis-engine/src/main/java/org/rostilos/codecrow/analysisengine/processor/analysis/BranchAnalysisProcessor.java
  • java-ecosystem/libs/analysis-engine/src/main/java/org/rostilos/codecrow/analysisengine/service/PullRequestService.java
  • java-ecosystem/libs/analysis-engine/src/main/java/org/rostilos/codecrow/analysisengine/service/PullRequestStatusSyncService.java
  • java-ecosystem/libs/analysis-engine/src/main/java/org/rostilos/codecrow/analysisengine/service/branch/BranchFullReconciliationService.java
  • java-ecosystem/libs/analysis-engine/src/main/java/org/rostilos/codecrow/analysisengine/service/vcs/VcsOperationsService.java
  • java-ecosystem/libs/analysis-engine/src/test/java/org/rostilos/codecrow/analysisengine/processor/analysis/BranchAnalysisProcessorTest.java
  • java-ecosystem/libs/analysis-engine/src/test/java/org/rostilos/codecrow/analysisengine/service/PullRequestServiceTest.java
  • java-ecosystem/libs/analysis-engine/src/test/java/org/rostilos/codecrow/analysisengine/service/PullRequestStatusSyncServiceTest.java
  • java-ecosystem/libs/analysis-engine/src/test/java/org/rostilos/codecrow/analysisengine/service/branch/BranchFullReconciliationServiceTest.java
  • java-ecosystem/libs/core/src/main/java/org/rostilos/codecrow/core/persistence/repository/codeanalysis/CodeAnalysisRepository.java
  • java-ecosystem/libs/core/src/main/java/org/rostilos/codecrow/core/persistence/repository/pullrequest/PullRequestRepository.java
  • java-ecosystem/libs/core/src/main/java/org/rostilos/codecrow/core/service/CodeAnalysisService.java
  • java-ecosystem/libs/core/src/test/java/org/rostilos/codecrow/core/service/CodeAnalysisServiceTest.java
  • java-ecosystem/libs/rag-engine/pom.xml
  • java-ecosystem/libs/rag-engine/src/main/java/org/rostilos/codecrow/ragengine/service/IncrementalRagUpdateService.java
  • java-ecosystem/libs/rag-engine/src/test/java/org/rostilos/codecrow/ragengine/service/IncrementalRagUpdateServiceTest.java
  • java-ecosystem/services/pipeline-agent/pom.xml
  • java-ecosystem/services/pipeline-agent/src/main/java/org/rostilos/codecrow/pipelineagent/bitbucket/service/BitbucketOperationsService.java
  • java-ecosystem/services/pipeline-agent/src/main/java/org/rostilos/codecrow/pipelineagent/bitbucket/webhookhandler/BitbucketCloudBranchWebhookHandler.java
  • java-ecosystem/services/pipeline-agent/src/main/java/org/rostilos/codecrow/pipelineagent/bitbucket/webhookhandler/BitbucketCloudPullRequestWebhookHandler.java
  • java-ecosystem/services/pipeline-agent/src/main/java/org/rostilos/codecrow/pipelineagent/generic/controller/ProviderWebhookController.java
  • java-ecosystem/services/pipeline-agent/src/main/java/org/rostilos/codecrow/pipelineagent/generic/webhookhandler/WebhookHandler.java
  • java-ecosystem/services/pipeline-agent/src/main/java/org/rostilos/codecrow/pipelineagent/generic/webhookhandler/WebhookHandlerFactory.java
  • java-ecosystem/services/pipeline-agent/src/main/java/org/rostilos/codecrow/pipelineagent/github/service/GitHubOperationsService.java
  • java-ecosystem/services/pipeline-agent/src/main/java/org/rostilos/codecrow/pipelineagent/github/webhookhandler/GitHubPullRequestWebhookHandler.java
  • java-ecosystem/services/pipeline-agent/src/main/java/org/rostilos/codecrow/pipelineagent/gitlab/service/GitLabOperationsService.java
  • java-ecosystem/services/pipeline-agent/src/main/java/org/rostilos/codecrow/pipelineagent/gitlab/webhookhandler/GitLabMergeRequestWebhookHandler.java
  • java-ecosystem/services/pipeline-agent/src/main/java/org/rostilos/codecrow/pipelineagent/gitlab/webhookhandler/GitLabMrMergeWebhookHandler.java
  • java-ecosystem/services/pipeline-agent/src/test/java/org/rostilos/codecrow/pipelineagent/bitbucket/service/BitbucketOperationsServiceTest.java
  • java-ecosystem/services/pipeline-agent/src/test/java/org/rostilos/codecrow/pipelineagent/bitbucket/webhookhandler/BitbucketCloudPullRequestWebhookHandlerPrCleanupTest.java
  • java-ecosystem/services/pipeline-agent/src/test/java/org/rostilos/codecrow/pipelineagent/generic/webhookhandler/WebhookHandlerFactoryTest.java
  • java-ecosystem/services/pipeline-agent/src/test/java/org/rostilos/codecrow/pipelineagent/github/service/GitHubOperationsServiceTest.java
  • java-ecosystem/services/pipeline-agent/src/test/java/org/rostilos/codecrow/pipelineagent/github/webhookhandler/GitHubPullRequestWebhookHandlerPrCleanupTest.java
  • java-ecosystem/services/pipeline-agent/src/test/java/org/rostilos/codecrow/pipelineagent/gitlab/service/GitLabOperationsServiceTest.java
  • java-ecosystem/services/pipeline-agent/src/test/java/org/rostilos/codecrow/pipelineagent/gitlab/webhookhandler/GitLabMergeRequestWebhookHandlerPrCleanupTest.java

📝 Walkthrough

Walkthrough

Branch reconciliation logic was extracted from BranchAnalysisProcessor into a new BranchFullReconciliationService, with added PR-number recovery from reviewed PRs. A new PullRequestStatusSyncService reconciles local PR state against providers via a new getPullRequestState contract implemented across Bitbucket, GitHub, and GitLab. Webhook handlers now mark PRs merged/declined via PullRequestService, enabled by new payload-aware handler selection. IncrementalRagUpdateService gained batching/retry. Two pom.xml files updated build/plugin configuration.

Changes

Branch reconciliation and PR state services

Layer / File(s) Summary
Extract BranchFullReconciliationService
.../service/branch/BranchFullReconciliationService.java, .../processor/analysis/BranchAnalysisProcessor.java, .../processor/analysis/BranchAnalysisProcessorTest.java
Full reconciliation (merged-PR issue sync, unresolved issue reanalysis, metrics) moved into a new service; processor now delegates via fullReconcile(...).
PR-number recovery in process()
.../BranchAnalysisProcessor.java, .../BranchAnalysisProcessorTest.java
Adds merge-commit PR lookup, reviewed-PR fallback resolution, and best-effort merged marking during branch processing.
PullRequestService branch refresh
.../PullRequestService.java, .../PullRequestServiceTest.java
Updating an existing PR now refreshes source/target branch names and forces state to OPEN.
PullRequestStatusSyncService and provider state lookup
.../PullRequestStatusSyncService.java, .../vcs/VcsOperationsService.java, bitbucket/service/BitbucketOperationsService.java, github/service/GitHubOperationsService.java, gitlab/service/GitLabOperationsService.java, tests
New service syncs stored OPEN PRs against remote state via a new getPullRequestState contract implemented per VCS provider.
Reviewed PR number lookup
CodeAnalysisRepository.java, CodeAnalysisService.java, tests
Adds a repository query and service helper to resolve a reviewed PR number from a commit hash.

Webhook PR-state marking and payload-aware handler routing

Layer / File(s) Summary
Payload-aware handler selection
WebhookHandler.java, WebhookHandlerFactory.java, ProviderWebhookController.java, tests
Adds supportsPayload and a factory overload allowing handler selection based on full webhook payload instead of just event type.
Bitbucket handlers mark merged/declined
BitbucketCloudBranchWebhookHandler.java, BitbucketCloudPullRequestWebhookHandler.java, tests
Handlers inject PullRequestService and mark PRs merged/declined on fulfilled/rejected events.
GitHub handler marks merged/declined
GitHubPullRequestWebhookHandler.java, tests
Handler injects PullRequestService and marks PR state on closed events.
GitLab handlers mark merged/declined
GitLabMergeRequestWebhookHandler.java, GitLabMrMergeWebhookHandler.java, tests
Handlers inject PullRequestService, add payload filtering, and mark PR state on close/merge events.

RAG incremental update batching and retry

Layer / File(s) Summary
Batched delete/update with retry
IncrementalRagUpdateService.java, IncrementalRagUpdateServiceTest.java
Adds configurable batch size/retry, reworks file fetch to return successfully fetched paths, and adjusts result metrics accordingly.

Build configuration updates

Layer / File(s) Summary
Compiler/jar plugin configuration
rag-engine/pom.xml, pipeline-agent/pom.xml
Adds java.version property and configures compiler/jar plugins for module path and Automatic-Module-Name.

Estimated code review effort: 4 (Complex) | ~75 minutes

Possibly related PRs

  • rostilos/CodeCrow#132: Both PRs modify BranchAnalysisProcessor's reconciliation and PR-number recovery logic.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 1.6.1-rc

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot mentioned this pull request Jul 13, 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