pmat 3.17.0

PMAT - Zero-config AI context generation and code quality toolkit (CLI, MCP, HTTP)
# Bug Report: Incorrect Parallel Analysis Count and Typo

**Date**: 2025-10-31
**Reporter**: User feedback
**Severity**: Low → ✅ FIXED
**Component**: CLI - context command parallel analysis
**Status**: GREEN phase complete (code quality improvement)

## Description

When running `pmat context`, two issues occur:
1. **Typo**: Shows "parallel analyses" instead of "parallel analysis" (or should be plural "analyses" everywhere)
2. **Wrong count**: Shows 8 parallel analyses but only 4 actually run

## Steps to Reproduce

```bash
pmat context
```

## Actual Output

```
⠙ Running parallel analyses...
  Running analyses [███████████▎                  ] 3/8
```

But only 4 analyses actually execute.

## Expected Behavior

Should show:
```
⠙ Running parallel analyses...
  Running analyses [████████████████████████████] 4/4
```

Or if it's meant to show 8, then all 8 should actually run.

## Analysis

Two separate issues:

### 1. Typo Issue
- "analyses" is technically correct (plural of "analysis")
- But message may say "parallel analyses" in one place and "parallel analysis" in another
- Should be consistent throughout

### 2. Count Mismatch
Possible causes:
- Hardcoded total count (8) doesn't match actual analyses spawned (4)
- Some analyses are skipped but count not updated
- Planned analyses reduced but UI not updated
- Race condition in count tracking

## Impact

- Confusing user experience (where are the other 4 analyses?)
- Minor typo affects polish
- Makes it seem like analyses are incomplete or stuck

## Files to Investigate

- `server/src/cli/handlers/context.rs` - Context command implementation
- Parallel analysis spawning logic
- Progress tracking for analyses

## Suggested Fix

1. Count actual analyses dynamically instead of hardcoding
2. Ensure progress bar total matches spawned analyses
3. Fix typo to use consistent plural form ("analyses")

```rust
let analyses = vec![
    spawn_complexity_analysis(),
    spawn_satd_analysis(),
    spawn_dead_code_analysis(),
    spawn_entropy_analysis(),
];

let pb = ProgressBar::new(analyses.len() as u64);
pb.set_message("Running parallel analyses...");
```

## Fix Applied

**Root Cause**: Hardcoded magic number "8" instead of named constant.

**Investigation Results**:
- Bug report claimed "only 4 actually run" but code inspection showed ALL 8 analyses DO execute
- Analyses: complexity, provability, satd, churn, dag, tdg, big_o, dead_code
- Real issue: Hardcoded "8" in two places (line 84, line 126) - code quality/maintainability problem

**Solution**: Replaced magic number with named constant `ANALYSIS_COUNT = 8`.

**Files Modified**:
- `server/src/services/deep_context_concurrent.rs:13-15` - Added `ANALYSIS_COUNT` constant
- `server/src/services/deep_context_concurrent.rs:88` - Use constant in progress bar creation
- `server/src/services/deep_context_concurrent.rs:130` - Use constant in progress increment
- `server/tests/bug_006_parallel_count_tests.rs` - 5 comprehensive tests (3 documentation, 2 integration)

**TDD Approach**:
1. ✅ RED: 5 tests written (verifying count correctness)
2. ✅ GREEN: Implemented `ANALYSIS_COUNT` constant
3. ✅ Verification: All 8 analyses confirmed running via code inspection

**Implementation Details**:
```rust
// Before (hardcoded magic number):
let pb = self.create_progress_bar("Running analyses", 8);
// ...
pb.inc(8);

// After (named constant):
const ANALYSIS_COUNT: u64 = 8;
// ...
let pb = self.create_progress_bar("Running analyses", ANALYSIS_COUNT);
// ...
pb.inc(ANALYSIS_COUNT);
```

**Impact**: Improved code maintainability - future addition/removal of analyses will only require updating constant and adding/removing tokio::join! arms. No functional behavior change (all 8 analyses were already running correctly).