# coordinate-parallel-ci

## Task: Multi-Worktree CI/CD Coordination for Parallel Development

**Purpose**: Intelligent coordination of GitLab CI/CD pipelines across multiple git worktrees for parallel development workflows with merge readiness assessment and conflict prevention.

**When to Use**:

- Managing CI across multiple parallel development streams
- Coordinating merge readiness across feature branches
- Aggregate CI health monitoring for parallel work
- Integration planning for parallel development completion

---

## Task Configuration

### Input Parameters

- `coordination_mode` (optional): monitor, assess, coordinate, full (default: full)
- `merge_target` (optional): Target branch for merge coordination (default: main)
- `health_threshold` (optional): Minimum health percentage for merge approval (default: 80)
- `include_stale_branches` (optional): Include branches without recent activity (default: false)
- `generate_report` (optional): Generate coordination report (default: true)
- `auto_recommendations` (optional): Generate merge sequence recommendations (default: true)

### Expected Outputs

- Multi-worktree CI status overview
- Merge readiness assessment for each branch
- Conflict risk analysis and recommendations
- Coordinated integration plan
- Aggregate health metrics across parallel work

---

## Task Execution

### Phase 1: Parallel Development Detection and Setup

```bash
echo "🔀 Parallel Development CI Coordination"
echo "======================================"

# Check for parallel development integration
source .bmad-core/utils/gitlab-integration-bridge.md
detect_expansion_packs

if [ "$PARALLEL_DEV_INTEGRATION" != "true" ]; then
  echo "⚠️ Parallel development integration not detected"
  echo "   💡 This task is optimized for multi-worktree parallel development"
  echo "   📦 Consider installing ck-parallel-dev expansion pack"
  echo ""
  echo "   Continuing with basic multi-branch analysis..."
fi

# Verify GitLab CLI authentication
glab auth status || {
  echo "❌ GitLab CLI not authenticated"
  exit 1
}

MERGE_TARGET=${merge_target:-"main"}
HEALTH_THRESHOLD=${health_threshold:-80}
COORDINATION_MODE=${coordination_mode:-"full"}

echo "🎯 Coordination Mode: $COORDINATION_MODE"
echo "📍 Merge Target: $MERGE_TARGET"
echo "📊 Health Threshold: $HEALTH_THRESHOLD%"

# Detect worktrees and branches
echo ""
echo "🔍 Detecting Parallel Development Setup:"
echo "======================================"

# Check for multiple worktrees
WORKTREE_COUNT=$(git worktree list 2>/dev/null | wc -l || echo "1")

if [ "$WORKTREE_COUNT" -gt 1 ]; then
  echo "✅ Multiple worktrees detected: $WORKTREE_COUNT"
  echo "🔀 Parallel development mode: ACTIVE"
  PARALLEL_MODE=true
else
  echo "ℹ️ Single worktree detected"
  echo "🔀 Parallel development mode: STANDARD"
  PARALLEL_MODE=false

  # Check for multiple active branches instead
  ACTIVE_BRANCHES=$(git branch -r --merged HEAD 2>/dev/null | grep -v "HEAD\|$MERGE_TARGET" | wc -l || echo "0")
  if [ "$ACTIVE_BRANCHES" -gt 2 ]; then
    echo "📋 Multiple active branches detected: $ACTIVE_BRANCHES"
    echo "   💡 Consider git worktrees for true parallel development"
  fi
fi
```

### Phase 2: Worktree and Branch Discovery

```bash
echo ""
echo "📋 Worktree and Branch Analysis:"
echo "==============================="

# Collect worktree information
declare -A WORKTREE_BRANCHES
declare -A BRANCH_PATHS
declare -A BRANCH_CI_STATUS

if [ "$PARALLEL_MODE" = true ]; then
  echo "🔍 Analyzing worktrees..."

  git worktree list | while read worktree_line; do
    WORKTREE_PATH=$(echo "$worktree_line" | awk '{print $1}')
    WORKTREE_COMMIT=$(echo "$worktree_line" | awk '{print $2}')
    WORKTREE_BRANCH=$(echo "$worktree_line" | awk '{print $3}' | tr -d '[]')

    if [ -n "$WORKTREE_BRANCH" ] && [ "$WORKTREE_BRANCH" != "detached" ]; then
      echo "   📁 $WORKTREE_PATH"
      echo "      Branch: $WORKTREE_BRANCH"
      echo "      Commit: $WORKTREE_COMMIT"

      # Store branch information
      WORKTREE_BRANCHES["$WORKTREE_BRANCH"]="$WORKTREE_PATH"
      BRANCH_PATHS["$WORKTREE_BRANCH"]="$WORKTREE_PATH"

      # Check if branch has recent activity
      LAST_COMMIT_AGE=$(cd "$WORKTREE_PATH" && git log -1 --format=%ct 2>/dev/null || echo "0")
      CURRENT_TIME=$(date +%s)
      AGE_DAYS=$(( (CURRENT_TIME - LAST_COMMIT_AGE) / 86400 ))

      echo "      Last activity: $AGE_DAYS days ago"

      # Include branch based on activity and settings
      if [ "$include_stale_branches" = "true" ] || [ "$AGE_DAYS" -lt 14 ]; then
        echo "      Status: ✅ INCLUDED in coordination"
      else
        echo "      Status: ⏩ SKIPPED (stale branch)"
        continue
      fi
    fi
  done
else
  echo "🔍 Analyzing multiple branches (single worktree mode)..."

  # Get list of recent branches
  RECENT_BRANCHES=$(git branch -r --sort=-committerdate | grep -v "HEAD\|$MERGE_TARGET" | head -10 | sed 's/origin\///' | xargs)

  for branch in $RECENT_BRANCHES; do
    if [ -n "$branch" ]; then
      echo "   🌿 $branch"

      # Check last activity
      LAST_COMMIT_AGE=$(git log -1 --format=%ct "origin/$branch" 2>/dev/null || echo "0")
      CURRENT_TIME=$(date +%s)
      AGE_DAYS=$(( (CURRENT_TIME - LAST_COMMIT_AGE) / 86400 ))

      echo "      Last activity: $AGE_DAYS days ago"

      if [ "$include_stale_branches" = "true" ] || [ "$AGE_DAYS" -lt 14 ]; then
        BRANCH_PATHS["$branch"]="single-worktree"
        echo "      Status: ✅ INCLUDED in coordination"
      else
        echo "      Status: ⏩ SKIPPED (stale branch)"
      fi
    fi
  done
fi
```

### Phase 3: CI Status Collection Across Branches

```bash
echo ""
echo "📊 CI Status Collection:"
echo "======================"

# Get CI status for each active branch
for branch in "${!BRANCH_PATHS[@]}"; do
  if [ -n "$branch" ]; then
    echo ""
    echo "🔍 Analyzing CI status for: $branch"
    echo "-----------------------------------"

    # Get pipeline data for this branch
    PIPELINE_DATA=$(glab ci get --output json --branch "$branch" 2>/dev/null)

    if [ $? -eq 0 ] && [ "$PIPELINE_DATA" != "" ]; then
      # Extract pipeline metrics
      source .bmad-core/utils/ci-status-parser.md

      STATUS=$(echo "$PIPELINE_DATA" | jq -r '.status // "unknown"')
      DURATION=$(echo "$PIPELINE_DATA" | jq -r '.duration // 0')
      TOTAL_JOBS=$(echo "$PIPELINE_DATA" | jq -r '.jobs | length')
      FAILED_JOBS=$(echo "$PIPELINE_DATA" | jq -r '.jobs[] | select(.status == "failed") | .name' | wc -l)
      SUCCESS_RATE=$(( (TOTAL_JOBS - FAILED_JOBS) * 100 / TOTAL_JOBS ))
      PIPELINE_URL=$(echo "$PIPELINE_DATA" | jq -r '.web_url')

      # Store CI metrics
      BRANCH_CI_STATUS["$branch,status"]="$STATUS"
      BRANCH_CI_STATUS["$branch,duration"]="$DURATION"
      BRANCH_CI_STATUS["$branch,success_rate"]="$SUCCESS_RATE"
      BRANCH_CI_STATUS["$branch,total_jobs"]="$TOTAL_JOBS"
      BRANCH_CI_STATUS["$branch,failed_jobs"]="$FAILED_JOBS"
      BRANCH_CI_STATUS["$branch,url"]="$PIPELINE_URL"

      # Display status
      STATUS_EMOJI=$(status_to_emoji "$STATUS")
      echo "   Status: $STATUS_EMOJI $STATUS"
      echo "   Duration: $(format_duration "$DURATION")"
      echo "   Success Rate: $SUCCESS_RATE% ($((TOTAL_JOBS - FAILED_JOBS))/$TOTAL_JOBS jobs)"
      echo "   Pipeline: $PIPELINE_URL"

      # Merge readiness assessment
      case "$STATUS" in
        "success")
          if [ "$SUCCESS_RATE" -ge "$HEALTH_THRESHOLD" ]; then
            MERGE_READY="YES"
            READINESS_EMOJI="✅"
          else
            MERGE_READY="PARTIAL"
            READINESS_EMOJI="⚠️"
          fi
          ;;
        "failed")
          MERGE_READY="NO"
          READINESS_EMOJI="❌"
          ;;
        "running")
          MERGE_READY="PENDING"
          READINESS_EMOJI="🔄"
          ;;
        *)
          MERGE_READY="UNKNOWN"
          READINESS_EMOJI="❓"
          ;;
      esac

      BRANCH_CI_STATUS["$branch,merge_ready"]="$MERGE_READY"
      echo "   Merge Ready: $READINESS_EMOJI $MERGE_READY"

    else
      echo "   ⚪ No pipeline data available"
      BRANCH_CI_STATUS["$branch,status"]="no-pipeline"
      BRANCH_CI_STATUS["$branch,merge_ready"]="UNKNOWN"
    fi
  fi
done
```

### Phase 4: Merge Conflict Risk Analysis

```bash
echo ""
echo "🔍 Merge Conflict Risk Analysis:"
echo "==============================="

# Analyze potential merge conflicts between branches
echo "🔍 Checking for potential merge conflicts with $MERGE_TARGET..."

CONFLICT_RISKS=()
LOW_RISK_BRANCHES=()
HIGH_RISK_BRANCHES=()

for branch in "${!BRANCH_PATHS[@]}"; do
  if [ -n "$branch" ] && [ "$branch" != "$MERGE_TARGET" ]; then
    echo ""
    echo "🔍 Conflict analysis: $branch → $MERGE_TARGET"

    # Check if branch can merge cleanly (dry run)
    if git merge-tree "origin/$MERGE_TARGET" "origin/$branch" >/dev/null 2>&1; then
      CONFLICT_OUTPUT=$(git merge-tree "origin/$MERGE_TARGET" "origin/$branch" 2>/dev/null | grep -c "<<<<<<< " || echo "0")

      if [ "$CONFLICT_OUTPUT" -eq 0 ]; then
        echo "   ✅ Clean merge expected"
        LOW_RISK_BRANCHES+=("$branch")
      else
        echo "   ⚠️ Potential conflicts detected: $CONFLICT_OUTPUT conflict markers"
        CONFLICT_RISKS+=("$branch:$CONFLICT_OUTPUT conflicts")
        HIGH_RISK_BRANCHES+=("$branch")
      fi
    else
      echo "   ❓ Unable to analyze merge (branch may not exist remotely)"
    fi

    # Check for overlapping file changes
    CHANGED_FILES=$(git diff --name-only "origin/$MERGE_TARGET...origin/$branch" 2>/dev/null | wc -l || echo "0")
    echo "   📁 Files changed: $CHANGED_FILES"

    # Check commit divergence
    COMMITS_AHEAD=$(git rev-list --count "origin/$MERGE_TARGET..origin/$branch" 2>/dev/null || echo "0")
    COMMITS_BEHIND=$(git rev-list --count "origin/$branch..origin/$MERGE_TARGET" 2>/dev/null || echo "0")
    echo "   📊 Commits ahead: $COMMITS_AHEAD, behind: $COMMITS_BEHIND"

    # Risk assessment
    if [ "$CHANGED_FILES" -gt 20 ] || [ "$COMMITS_BEHIND" -gt 10 ]; then
      echo "   🚨 HIGH RISK: Many changes or branch is stale"
      if [[ ! " ${HIGH_RISK_BRANCHES[@]} " =~ " $branch " ]]; then
        HIGH_RISK_BRANCHES+=("$branch")
      fi
    elif [ "$CHANGED_FILES" -gt 5 ] || [ "$COMMITS_BEHIND" -gt 3 ]; then
      echo "   ⚠️ MEDIUM RISK: Moderate changes"
    else
      echo "   ✅ LOW RISK: Minimal changes"
    fi
  fi
done

echo ""
echo "📊 Conflict Risk Summary:"
echo "   ✅ Low Risk Branches: ${#LOW_RISK_BRANCHES[@]}"
echo "   🚨 High Risk Branches: ${#HIGH_RISK_BRANCHES[@]}"

if [ ${#CONFLICT_RISKS[@]} -gt 0 ]; then
  echo ""
  echo "⚠️ Detected Conflict Risks:"
  for risk in "${CONFLICT_RISKS[@]}"; do
    echo "   - $risk"
  done
fi
```

### Phase 5: Aggregate Health Assessment

```bash
echo ""
echo "📊 Aggregate CI Health Assessment:"
echo "================================="

# Calculate overall parallel development health
TOTAL_BRANCHES=0
HEALTHY_BRANCHES=0
MERGE_READY_BRANCHES=0
FAILED_BRANCHES=0
PENDING_BRANCHES=0

for branch in "${!BRANCH_PATHS[@]}"; do
  if [ -n "$branch" ]; then
    TOTAL_BRANCHES=$((TOTAL_BRANCHES + 1))

    BRANCH_STATUS="${BRANCH_CI_STATUS["$branch,status"]}"
    BRANCH_MERGE_READY="${BRANCH_CI_STATUS["$branch,merge_ready"]}"
    BRANCH_SUCCESS_RATE="${BRANCH_CI_STATUS["$branch,success_rate"]:-0}"

    case "$BRANCH_STATUS" in
      "success")
        if [ "$BRANCH_SUCCESS_RATE" -ge "$HEALTH_THRESHOLD" ]; then
          HEALTHY_BRANCHES=$((HEALTHY_BRANCHES + 1))
        fi
        ;;
      "failed")
        FAILED_BRANCHES=$((FAILED_BRANCHES + 1))
        ;;
      "running")
        PENDING_BRANCHES=$((PENDING_BRANCHES + 1))
        ;;
    esac

    if [ "$BRANCH_MERGE_READY" = "YES" ]; then
      MERGE_READY_BRANCHES=$((MERGE_READY_BRANCHES + 1))
    fi
  fi
done

# Calculate health percentages
if [ "$TOTAL_BRANCHES" -gt 0 ]; then
  HEALTH_PERCENTAGE=$((HEALTHY_BRANCHES * 100 / TOTAL_BRANCHES))
  MERGE_READY_PERCENTAGE=$((MERGE_READY_BRANCHES * 100 / TOTAL_BRANCHES))
else
  HEALTH_PERCENTAGE=0
  MERGE_READY_PERCENTAGE=0
fi

echo "📈 Aggregate Metrics:"
echo "   Total Branches: $TOTAL_BRANCHES"
echo "   ✅ Healthy: $HEALTHY_BRANCHES ($HEALTH_PERCENTAGE%)"
echo "   🚀 Merge Ready: $MERGE_READY_BRANCHES ($MERGE_READY_PERCENTAGE%)"
echo "   ❌ Failed: $FAILED_BRANCHES"
echo "   🔄 Pending: $PENDING_BRANCHES"

# Overall health assessment
echo ""
echo "🎯 Overall Health Assessment:"
if [ "$HEALTH_PERCENTAGE" -ge 80 ]; then
  echo "   Status: ✅ EXCELLENT ($HEALTH_PERCENTAGE%)"
  OVERALL_HEALTH="EXCELLENT"
elif [ "$HEALTH_PERCENTAGE" -ge 60 ]; then
  echo "   Status: 👍 GOOD ($HEALTH_PERCENTAGE%)"
  OVERALL_HEALTH="GOOD"
elif [ "$HEALTH_PERCENTAGE" -ge 40 ]; then
  echo "   Status: ⚠️ NEEDS ATTENTION ($HEALTH_PERCENTAGE%)"
  OVERALL_HEALTH="NEEDS_ATTENTION"
else
  echo "   Status: 🚨 CRITICAL ($HEALTH_PERCENTAGE%)"
  OVERALL_HEALTH="CRITICAL"
fi
```

### Phase 6: Coordination Recommendations

```bash
if [ "$auto_recommendations" = "true" ]; then
  echo ""
  echo "🎯 Coordination Recommendations:"
  echo "==============================="

  # Merge sequence recommendations
  echo "🔄 Recommended Merge Sequence:"
  echo ""

  # Sort branches by merge readiness and risk
  echo "📋 Priority Order:"

  # High priority: Ready branches with low conflict risk
  PRIORITY_1=()
  for branch in "${LOW_RISK_BRANCHES[@]}"; do
    if [ "${BRANCH_CI_STATUS["$branch,merge_ready"]}" = "YES" ]; then
      PRIORITY_1+=("$branch")
    fi
  done

  if [ ${#PRIORITY_1[@]} -gt 0 ]; then
    echo "   🟢 HIGH PRIORITY (Ready + Low Risk):"
    for branch in "${PRIORITY_1[@]}"; do
      echo "      1. $branch - Safe to merge immediately"
    done
  fi

  # Medium priority: Ready branches with higher risk
  PRIORITY_2=()
  for branch in "${!BRANCH_PATHS[@]}"; do
    if [ "${BRANCH_CI_STATUS["$branch,merge_ready"]}" = "YES" ] && \
       [[ ! " ${PRIORITY_1[@]} " =~ " $branch " ]]; then
      PRIORITY_2+=("$branch")
    fi
  done

  if [ ${#PRIORITY_2[@]} -gt 0 ]; then
    echo "   🟡 MEDIUM PRIORITY (Ready + Higher Risk):"
    for branch in "${PRIORITY_2[@]}"; do
      echo "      2. $branch - Review conflicts before merge"
    done
  fi

  # Low priority: Not ready branches
  PRIORITY_3=()
  for branch in "${!BRANCH_PATHS[@]}"; do
    if [ "${BRANCH_CI_STATUS["$branch,merge_ready"]}" != "YES" ]; then
      PRIORITY_3+=("$branch")
    fi
  done

  if [ ${#PRIORITY_3[@]} -gt 0 ]; then
    echo "   🔴 LOW PRIORITY (Not Ready):"
    for branch in "${PRIORITY_3[@]}"; do
      STATUS="${BRANCH_CI_STATUS["$branch,status"]}"
      echo "      3. $branch - Fix CI issues first ($STATUS)"
    done
  fi

  # Integration strategy recommendations
  echo ""
  echo "🎯 Integration Strategy:"

  case "$OVERALL_HEALTH" in
    "EXCELLENT")
      echo "   ✅ STRATEGY: Parallel Integration"
      echo "      - All branches can be integrated in parallel"
      echo "      - Consider batch merge for efficiency"
      echo "      - Monitor for integration test conflicts"
      ;;
    "GOOD")
      echo "   👍 STRATEGY: Staged Integration"
      echo "      - Merge ready branches first"
      echo "      - Fix failing branches in parallel"
      echo "      - Integrate in 2-3 waves"
      ;;
    "NEEDS_ATTENTION")
      echo "   ⚠️ STRATEGY: Sequential Integration"
      echo "      - Focus on fixing critical failures first"
      echo "      - Merge branches one by one"
      echo "      - Validate each integration before proceeding"
      ;;
    "CRITICAL")
      echo "   🚨 STRATEGY: Hold Integration"
      echo "      - Address critical failures before any merges"
      echo "      - Review parallel development process"
      echo "      - Consider branch consolidation"
      ;;
  esac
fi
```

### Phase 7: Report Generation

```bash
if [ "$generate_report" = "true" ]; then
  echo ""
  echo "📄 Generating Coordination Report:"
  echo "================================="

  REPORT_FILE="parallel_ci_coordination_$(date +%Y%m%d_%H%M%S).md"

  cat > "$REPORT_FILE" << EOF
# Parallel Development CI Coordination Report

**Generated:** $(date)
**Coordination Mode:** $COORDINATION_MODE
**Merge Target:** $MERGE_TARGET
**Health Threshold:** $HEALTH_THRESHOLD%

## Executive Summary

**Overall Health:** $OVERALL_HEALTH ($HEALTH_PERCENTAGE%)
**Merge Ready:** $MERGE_READY_BRANCHES of $TOTAL_BRANCHES branches
**Integration Risk:** $([ ${#HIGH_RISK_BRANCHES[@]} -gt 0 ] && echo "HIGH" || echo "LOW")

## Branch Status Overview

$(for branch in "${!BRANCH_PATHS[@]}"; do
  if [ -n "$branch" ]; then
    STATUS="${BRANCH_CI_STATUS["$branch,status"]}"
    MERGE_READY="${BRANCH_CI_STATUS["$branch,merge_ready"]}"
    SUCCESS_RATE="${BRANCH_CI_STATUS["$branch,success_rate"]:-N/A}"
    EMOJI=$(status_to_emoji "$STATUS")

    echo "### $branch"
    echo ""
    echo "- **CI Status:** $EMOJI $STATUS"
    echo "- **Success Rate:** $SUCCESS_RATE%"
    echo "- **Merge Ready:** $MERGE_READY"
    echo "- **Risk Level:** $(if [[ " ${HIGH_RISK_BRANCHES[@]} " =~ " $branch " ]]; then echo "HIGH"; else echo "LOW"; fi)"

    if [ "${BRANCH_CI_STATUS["$branch,url"]}" != "" ]; then
      echo "- **Pipeline:** [View Pipeline](${BRANCH_CI_STATUS["$branch,url"]})"
    fi
    echo ""
  fi
done)

## Coordination Recommendations

$(generate_coordination_recommendations)

## Next Steps

1. **Immediate Actions:**
   - Address failed CI pipelines
   - Resolve high-risk merge conflicts
   - Update stale branches

2. **Integration Planning:**
   - Follow recommended merge sequence
   - Monitor aggregate health metrics
   - Coordinate team communication

3. **Process Improvements:**
   - Regular coordination reviews
   - Automated conflict detection
   - Enhanced parallel development workflows

---
*Report generated by GitLab CI/CD Automation - coordinate-parallel-ci task*
EOF

  echo "📁 Report saved: $REPORT_FILE"
fi

generate_coordination_recommendations() {
  echo "### Merge Sequence"
  echo "1. **High Priority:** $(IFS=', '; echo "${PRIORITY_1[*]}")"
  echo "2. **Medium Priority:** $(IFS=', '; echo "${PRIORITY_2[*]}")"
  echo "3. **Low Priority:** $(IFS=', '; echo "${PRIORITY_3[*]}")"
  echo ""
  echo "### Risk Mitigation"
  if [ ${#HIGH_RISK_BRANCHES[@]} -gt 0 ]; then
    echo "- **High Risk Branches:** $(IFS=', '; echo "${HIGH_RISK_BRANCHES[*]}")"
    echo "- **Actions:** Manual conflict resolution, branch synchronization"
  fi
  echo ""
  echo "### Health Improvements"
  echo "- Focus on branches with < $HEALTH_THRESHOLD% success rate"
  echo "- Address recurring CI failures"
  echo "- Optimize pipeline performance"
}
```

### Phase 8: Coordination Summary and Next Steps

```bash
echo ""
echo "🎯 Coordination Summary:"
echo "======================="

echo "✅ Analysis Complete"
echo "📊 Branches Analyzed: $TOTAL_BRANCHES"
echo "🏥 Overall Health: $OVERALL_HEALTH ($HEALTH_PERCENTAGE%)"
echo "🚀 Merge Ready: $MERGE_READY_BRANCHES branches"

if [ ${#HIGH_RISK_BRANCHES[@]} -gt 0 ]; then
  echo "⚠️ High Risk Branches: ${#HIGH_RISK_BRANCHES[@]}"
fi

echo ""
echo "🔄 Recommended Actions:"
echo "======================"

case "$OVERALL_HEALTH" in
  "EXCELLENT")
    echo "✅ PROCEED WITH INTEGRATION"
    echo "   - All systems healthy"
    echo "   - Parallel integration possible"
    echo "   - Monitor for conflicts during merge"
    ;;
  "GOOD")
    echo "👍 STAGED INTEGRATION RECOMMENDED"
    echo "   - Merge ready branches first"
    echo "   - Fix remaining issues in parallel"
    echo "   - Validate each integration step"
    ;;
  "NEEDS_ATTENTION")
    echo "⚠️ ADDRESS ISSUES BEFORE INTEGRATION"
    echo "   - Fix failing CI pipelines"
    echo "   - Resolve high-risk conflicts"
    echo "   - Sequential integration recommended"
    ;;
  "CRITICAL")
    echo "🚨 HOLD ALL INTEGRATION"
    echo "   - Critical failures need immediate attention"
    echo "   - Review parallel development process"
    echo "   - Consider branch consolidation"
    ;;
esac

echo ""
echo "🔗 Related Commands:"
echo "   - Monitor specific branch: monitor-pipeline-status --branch <branch>"
echo "   - Analyze failures: analyze-pipeline-failures --branch <branch>"
echo "   - JIRA sync: sync-ci-status-to-jira --branch <branch>"
echo "   - Health report: generate-ci-health-report --branches $(IFS=','; echo "${!BRANCH_PATHS[*]}")"

echo ""
echo "📈 COORDINATION COMPLETE"
echo "🎯 Use insights above for informed integration decisions"
```

---

## Success Criteria

- ✅ Successfully detects and analyzes multi-worktree or multi-branch setups
- ✅ Provides comprehensive CI status across all parallel development streams
- ✅ Accurately assesses merge readiness and conflict risks
- ✅ Generates intelligent coordination recommendations
- ✅ Delivers aggregate health metrics for informed decision making
- ✅ Integrates seamlessly with parallel development workflows
- ✅ Operates autonomously with configurable coordination parameters

## Dependencies

- **Git repository** with worktrees or multiple active branches
- **GitLab CLI** (`glab`) with authentication
- **Utilities**: ci-status-parser, pipeline-analyzer, gitlab-integration-bridge
- **Optional**: Parallel Development Pack (ck-parallel-dev) for enhanced coordination
