---
name: LLM-Native Conflict Resolver
version: 1.0.0
role: Resolve complex conflicts in parallel development
description: Provides intelligent conflict resolution strategies using LLM reasoning to handle semantic conflicts and architectural inconsistencies
capabilities:
  - Multi-dimensional conflict detection
  - Intelligent resolution strategies
  - Automated and guided resolution
  - Architectural reconciliation
  - Prevention recommendations
---

# LLM-Native Conflict Resolver

## Purpose

Provides intelligent conflict resolution strategies using LLM reasoning to handle complex merge scenarios, semantic conflicts, and architectural inconsistencies that arise during parallel development.

## Core Capabilities

### 1. Conflict Type Detection

- **Syntactic Conflicts**: Traditional merge conflicts
- **Semantic Conflicts**: Logic conflicts without file overlap
- **Architectural Conflicts**: Design pattern violations
- **Business Logic Conflicts**: Feature interaction issues

### 2. Resolution Strategies

- **Automated Resolution**: For simple, deterministic conflicts
- **Guided Resolution**: Step-by-step instructions for complex cases
- **Refactoring Suggestions**: Propose architectural changes
- **Communication Templates**: For team coordination

## Conflict Analysis Framework

### Input Structure

```json
{
  "conflictType": "semantic|syntactic|architectural|business",
  "affectedWorkItems": ["story-1", "story-2"],
  "conflictDetails": {
    "files": ["src/auth.js", "src/user.js"],
    "description": "Both stories modify authentication flow",
    "codeSnippets": {
      "story1": "// OAuth implementation",
      "story2": "// JWT implementation"
    }
  },
  "context": {
    "architecture": "microservices",
    "constraints": ["backward compatibility", "security compliance"]
  }
}
```

### Resolution Prompt Template

```markdown
You are an expert software architect resolving conflicts in parallel development. Analyze the conflict and provide resolution strategies that maintain code quality and system integrity.

## Conflict Details:

[Type, affected items, specific issues]

## System Context:

[Architecture, constraints, business requirements]

## Resolution Tasks:

1. **Conflict Analysis**
   - Root cause of the conflict
   - Impact on system functionality
   - Risk assessment if left unresolved

2. **Resolution Options**
   Provide 3 strategies ranked by preference:
   - Option A: [Most recommended approach]
   - Option B: [Alternative approach]
   - Option C: [Fallback approach]

3. **Implementation Guide**
   For the recommended option, provide:
   - Step-by-step resolution process
   - Code changes required
   - Testing strategy
   - Rollback plan

4. **Prevention Strategy**
   - How to avoid similar conflicts
   - Architectural improvements
   - Process recommendations

Format the response for automated processing and human readability.
```

### Output Structure

```json
{
  "analysis": {
    "rootCause": "Parallel implementation of authentication without coordination",
    "impact": "HIGH - Authentication is core functionality",
    "riskLevel": "CRITICAL"
  },
  "resolutionStrategies": [
    {
      "rank": 1,
      "approach": "Unified Authentication Service",
      "description": "Merge both approaches into a flexible auth service",
      "effort": "4 hours",
      "risk": "LOW"
    }
  ],
  "implementationGuide": {
    "steps": [
      "Create auth-service interface",
      "Implement OAuth and JWT providers",
      "Add configuration-based selection",
      "Update dependent services"
    ],
    "codeChanges": "// Detailed code snippets",
    "testing": "Integration tests for both auth methods",
    "rollback": "Feature flags for gradual rollout"
  },
  "prevention": {
    "architectural": "Define clear service boundaries",
    "process": "Pre-execution API contract review",
    "tooling": "Automated conflict detection in CI/CD"
  }
}
```

## Intelligent Resolution Patterns

### 1. Semantic Merge Strategy

```markdown
When two features modify the same business logic differently:

1. Identify the business intent of each change
2. Find a unified approach that satisfies both intents
3. Refactor to accommodate both features
4. Add feature flags for gradual enablement
```

### 2. Architectural Reconciliation

```markdown
When parallel work creates architectural inconsistencies:

1. Identify the architectural principles violated
2. Propose a unifying pattern
3. Create adapters for backward compatibility
4. Plan migration strategy
```

### 3. API Contract Negotiation

```markdown
When parallel work creates incompatible API changes:

1. Design a versioned API strategy
2. Create compatibility layer
3. Implement gradual migration
4. Update all consumers systematically
```

## Platform Integration

### Conflict Detection Automation

```javascript
// Real-time conflict monitoring
async function monitorParallelWork(workItems) {
  const conflicts = await llmAnalyzer.detectConflicts(workItems);

  if (conflicts.length > 0) {
    const resolutions = await llmResolver.generateResolutions(conflicts);
    await notifyTeam(resolutions);
  }
}
```

### Resolution Workflow

```javascript
// Guided conflict resolution
async function resolveConflict(conflict) {
  // 1. Get LLM analysis
  const analysis = await llmResolver.analyzeConflict(conflict);

  // 2. Present options to team
  const choice = await presentOptions(analysis.resolutionStrategies);

  // 3. Generate implementation guide
  const guide = await llmResolver.createImplementationGuide(choice);

  // 4. Execute resolution
  await executeResolution(guide);
}
```

## Advanced Features

### 1. Predictive Conflict Detection

```markdown
Before parallel execution begins:

1. Analyze planned changes
2. Predict potential conflicts
3. Suggest preventive measures
4. Adjust execution plan
```

### 2. Learning from Resolutions

```markdown
Track resolution patterns to:

1. Identify common conflict types
2. Build resolution templates
3. Improve prediction accuracy
4. Suggest architectural improvements
```

### 3. Team Communication

```markdown
Generate communication artifacts:

1. Conflict summary for stakeholders
2. Technical details for developers
3. Resolution timeline
4. Impact assessment
```

## Usage Examples

### Simple Semantic Conflict

```bash
llm-resolve-conflict \
  --type "semantic" \
  --stories "auth-oauth,auth-jwt" \
  --description "Both implement authentication differently"

# Output: Unified auth service design with both methods
```

### Complex Architectural Conflict

```bash
llm-resolve-conflict \
  --type "architectural" \
  --stories "microservice-split,monolith-optimize" \
  --context "gradual migration to microservices"

# Output: Phased migration plan with compatibility layer
```

## Benefits

1. **Intelligent Resolution**: Beyond simple file merging
2. **Proactive Prevention**: Detect conflicts before they occur
3. **Architectural Integrity**: Maintain design consistency
4. **Team Efficiency**: Clear resolution guidance
5. **Continuous Learning**: Improve over time
6. **Platform Agnostic**: Works with any LLM

This LLM-native approach transforms conflict resolution from a reactive problem to a proactive, intelligent process that maintains code quality and system integrity.
