An intelligent, automated conflict resolution system for GitHub PR comments
Specifically designed for CodeRabbit AI but extensible to other code review bots
- Problem Statement
- Quick Start
- Features
- Architecture
- Use Cases
- Environment Variables
- Documentation
- Contributing
- Project Status
- License
When multiple PR review comments suggest overlapping changes to the same file, traditional automation tools either:
- Skip all conflicting changes (losing valuable suggestions)
- Apply changes sequentially without conflict awareness (potentially breaking code)
- Require tedious manual resolution for every conflict
CodeRabbit Conflict Resolver provides intelligent, semantic-aware conflict resolution that:
- β Understands code structure (JSON, YAML, TOML, Python, TypeScript)
- β Uses priority-based resolution (user selections, security fixes, syntax errors)
- β Supports semantic merging (combining non-conflicting changes automatically)
- β Learns from your decisions to improve over time
- β Provides detailed conflict analysis and actionable suggestions
pip install pr-conflict-resolver# Set your GitHub token (required)
export GITHUB_PERSONAL_ACCESS_TOKEN="your_token_here"
# Analyze conflicts in a PR
pr-resolve analyze --owner VirtualAgentics --repo my-repo --pr 123
# Apply suggestions with conflict resolution
pr-resolve apply --owner VirtualAgentics --repo my-repo --pr 123 --strategy priority
# Apply only conflicting changes
pr-resolve apply --owner VirtualAgentics --repo my-repo --pr 123 --mode conflicts-only
# Simulate without applying changes (dry-run mode)
pr-resolve apply --owner VirtualAgentics --repo my-repo --pr 123 --mode dry-run
# Use parallel processing for large PRs
pr-resolve apply --owner VirtualAgentics --repo my-repo --pr 123 --parallel --max-workers 8
# Load configuration from file
pr-resolve apply --owner VirtualAgentics --repo my-repo --pr 123 --config config.yamlfrom pr_conflict_resolver import ConflictResolver
from pr_conflict_resolver.config import PresetConfig
resolver = ConflictResolver(config=PresetConfig.BALANCED)
results = resolver.resolve_pr_conflicts(
owner="VirtualAgentics",
repo="my-repo",
pr_number=123
)
print(f"Applied: {results.applied_count}")
print(f"Conflicts: {results.conflict_count}")
print(f"Success rate: {results.success_rate}%")- Semantic Understanding: Analyzes JSON, YAML, TOML structure, not just text
- Conflict Categorization: Exact, major, partial, minor, disjoint-keys, semantic-duplicate
- Impact Assessment: Evaluates scope, risk level, and criticality of changes
- Actionable Suggestions: Provides specific guidance for each conflict
- Priority-Based: User selections > Security fixes > Syntax errors > Regular suggestions
- Semantic Merging: Combines non-conflicting changes in structured files
- Sequential Application: Applies compatible changes in optimal order
- Defer to User: Escalates complex conflicts for manual review
- JSON: Duplicate key detection, key-level merging
- YAML: Comment preservation, structure-aware merging
- TOML: Section merging, format preservation
- Python/TypeScript: AST-aware analysis (planned)
- ML-Assisted Priority: Learns from your resolution decisions
- Metrics Tracking: Monitors success rates, resolution times, strategy effectiveness
- Conflict Caching: Reuses analysis for similar conflicts
- Performance: Parallel processing for large PRs
- Conservative: Skip all conflicts, manual review required
- Balanced: Priority system + semantic merging (default)
- Aggressive: Maximize automation, user selections always win
- Semantic: Focus on structure-aware merging for config files
- all: Apply both conflicting and non-conflicting changes (default)
- conflicts-only: Apply only changes that have conflicts
- non-conflicts-only: Apply only changes without conflicts
- dry-run: Analyze and report without applying any changes
- Automatic Rollback: Git-based checkpointing with automatic rollback on failure
- Pre-Application Validation: Validates changes before applying (optional)
- File Integrity Checks: Verifies file safety and containment
- Detailed Logging: Comprehensive logging for debugging and audit trails
Configure via multiple sources with precedence chain: CLI flags > Environment variables > Config file > Defaults
- Configuration Files: Load settings from YAML or TOML files
- Environment Variables: Set options using
CR_*prefix variables - CLI Overrides: Override any setting via command-line flags
See .env.example for available environment variables.
- Getting Started Guide - Installation, setup, and first steps
- Configuration Reference - Complete configuration options
- Rollback System - Automatic rollback and recovery
- Parallel Processing - Performance tuning guide
- Migration Guide - Upgrading from earlier versions
- Troubleshooting - Common issues and solutions
- API Reference - Python API documentation
- Conflict Types Explained - Understanding conflict categories
- Resolution Strategies - Strategy selection guide
- Architecture Overview - System design and components
- Contributing Guide - How to contribute
- Security Policy - Vulnerability reporting, security features
- Security Architecture - Design principles, threat model
- Threat Model - STRIDE analysis, risk assessment
- Incident Response - Security incident procedures
- Compliance - GDPR, OWASP, SOC2, OpenSSF
- Security Testing - Testing guide, fuzzing, SAST
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β GitHub PR Comments β
β (CodeRabbit, Review Bot) β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Comment Parser & Extractor β
β (Suggestions, Diffs, Codemods, Multi-Options) β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Conflict Detection Engine β
β β’ Fingerprinting β’ Overlap Analysis β’ Semantic Check β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββ΄βββββββββββ
βΌ βΌ
ββββββββββββββββββββ ββββββββββββββββββββ
β File Handlers β β Priority System β
β β’ JSON β β β’ User Selected β
β β’ YAML β β β’ Security Fix β
β β’ TOML β β β’ Syntax Error β
β β’ Python β β β’ Regular β
βββββββββββ¬βββββββββ ββββββββββ¬ββββββββββ
β β
ββββββββββββ¬βββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Resolution Strategy Selector β
β β’ Skip β’ Override β’ Merge β’ Sequential β’ Defer β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Application Engine β
β β’ Backup β’ Apply β’ Validate β’ Rollback β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Reporting & Metrics β
β β’ Conflict Summary β’ Visual Diff β’ Success Rate β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Problem: User selects "Option 2" but it conflicts with another suggestion Solution: Priority system ensures user selections override lower-priority changes
Problem: Two suggestions modify different keys in package.json
Solution: Semantic merging combines both changes automatically
Problem: Security fix conflicts with formatting suggestion Solution: Priority system applies security fix, skips formatting
Problem: Manual conflict resolution is time-consuming Solution: Parallel processing + caching resolves conflicts in seconds
Configure the tool using environment variables (see .env.example for all options):
| Variable | Description | Default |
|---|---|---|
GITHUB_PERSONAL_ACCESS_TOKEN |
GitHub API token (required) | None |
CR_MODE |
Application mode (all, conflicts-only, non-conflicts-only, dry-run) |
all |
CR_ENABLE_ROLLBACK |
Enable automatic rollback on failure | true |
CR_VALIDATE |
Enable pre-application validation | true |
CR_PARALLEL |
Enable parallel processing | false |
CR_MAX_WORKERS |
Number of parallel workers | 4 |
CR_LOG_LEVEL |
Logging level (DEBUG, INFO, WARNING, ERROR) |
INFO |
CR_LOG_FILE |
Log file path (optional) | None |
We welcome contributions! See CONTRIBUTING.md for guidelines.
git clone https://github.com/VirtualAgentics/coderabbit-conflict-resolver.git
cd coderabbit-conflict-resolver
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pre-commit install# Run standard tests with coverage
pytest tests/ --cov=src --cov-report=html
# Run property-based fuzzing tests
make test-fuzz # Dev profile: 50 examples
make test-fuzz-ci # CI profile: 100 examples
make test-fuzz-extended # Extended: 1000 examples
# Run all tests (standard + fuzzing)
make test-allMIT License - see LICENSE for details.
- Inspired by the sophisticated code review capabilities of CodeRabbit AI
- Built with experience from ContextForge Memory project
- Community feedback and contributions
Current Version: 0.1.0 (Alpha)
Roadmap:
- β
Phase 0: Security Foundation (COMPLETE)
- β 0.1: Security Architecture Design
- β 0.2: Input Validation & Sanitization
- β 0.3: Secure File Handling
- β 0.4: Secret Detection (14+ patterns)
- β 0.5: Security Testing Suite (95%+ coverage)
- β 0.6: Security Configuration
- β 0.7: CI/CD Security Scanning (7+ tools)
- β 0.8: Security Documentation
- β
Phase 1: Core Features (COMPLETE)
- β Core conflict detection and analysis
- β File handlers (JSON, YAML, TOML)
- β Priority system
- β Rollback system with git-based checkpointing
- β
Phase 2: CLI & Configuration (COMPLETE)
- β CLI with comprehensive options
- β Runtime configuration system
- β Application modes (all, conflicts-only, non-conflicts-only, dry-run)
- β Parallel processing support
- β Multiple configuration sources (file, env, CLI)
- π Phase 3: Documentation & Examples (IN PROGRESS)
- π Comprehensive documentation updates
- π Example configurations and use cases
- π Phase 4: Advanced resolution strategies and ML-assisted learning
- π Phase 5: Performance optimization and caching
- ClusterFuzzLite: Continuous fuzzing (3 fuzz targets, ASan + UBSan)
- Test Coverage: 82.35% overall, 95%+ for security modules
- Security Scanning: CodeQL, Trivy, TruffleHog, Bandit, pip-audit, OpenSSF Scorecard
- Secret Detection: 14+ pattern types (GitHub tokens, AWS keys, API keys, etc.)
- Documentation: Comprehensive security documentation (threat model, incident response, compliance)
- ContextForge Memory - Original implementation
- CodeRabbit AI - AI-powered code review
Made with β€οΈ by VirtualAgentics