Skip to content

fix: analyze-complexity overwrites existing report instead of merging across --from/--to runs #1644

@bjcoombs

Description

@bjcoombs

Summary

Running task-master analyze-complexity with --from/--to ranges multiple times causes earlier results to be lost. Each run replaces the entire report instead of merging new results with existing ones.

Steps to Reproduce

# Run 1: Analyze tasks 49-53
task-master analyze-complexity --from=49 --to=53 --research
# Report now contains: [49, 50, 52, 53]

# Run 2: Analyze tasks 54-59
task-master analyze-complexity --from=54 --to=59 --research
# Report now contains: [54, 55, 56, 57, 58, 59]
# Expected: [49, 50, 52, 53, 54, 55, 56, 57, 58, 59]
# Results from run 1 (49-53) are GONE

# Run 3: Analyze tasks 41-53
task-master analyze-complexity --from=41 --to=53 --research
# Report now contains: [41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 52, 53]
# Expected: all of [41-59] except cancelled 51
# Results from run 2 (54-59) are GONE

Observed Behavior

The log output claims to merge but finds 0 existing entries from the current tag:

[INFO] Found existing complexity report at .../task-complexity-report_026-operations-console.json
[INFO] Existing report contains 6 task analyses
...
[INFO] Merged 12 new analyses with 0 existing entries from current tag

The merge logic locates the existing report but considers 0 entries to be from the "current tag", so all previous entries are dropped on write.

Expected Behavior

Each analyze-complexity run should:

  1. Read the existing report file
  2. Preserve all entries from the existing report that are NOT in the current analysis range
  3. Add/update entries from the current analysis
  4. Write the merged result

Impact

  • Complexity scores from earlier runs are lost, requiring re-analysis
  • The expand command uses complexity scores to determine subtask count — if scores are lost, expansion uses defaults instead of the analyzed values
  • Workaround: run a single analyze-complexity covering the full range in one invocation

Report File

.taskmaster/reports/task-complexity-report_<tag>.json

Report Structure

{
  "meta": { ... },
  "complexityAnalysis": [
    { "taskId": 49, "complexityScore": 7, "recommendedSubtasks": 5, ... },
    ...
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cliCLI functionalityarea:task-managementCore task management featuresbugSomething isn't workingmedium-priorityImportant but not urgent

    Projects

    Status

    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions