Skip to content

feat: change coupling detection (co-change analysis) #23

@bntvllnt

Description

@bntvllnt

Summary

Detect files that frequently change together in git history but have no direct import relationship — hidden temporal coupling.

Motivation

  • CodeScene's change coupling is one of their most valued features
  • Files that always change together reveal hidden dependencies the import graph misses
  • AI agents making changes need to know "if you touch X, you probably need to touch Y too"
  • Amazon's AI code incident was partly caused by missing awareness of coupled systems

Approach

  1. Parse git log --all --name-only (already done for churn)
  2. For each commit, record which files changed together
  3. Compute co-change frequency for file pairs
  4. Filter by minimum threshold (e.g., changed together 3+ times)
  5. Flag pairs with high co-change but no import edge (hidden coupling)

Proposed API Addition

Add to detect_changes or new get_coupling tool:

output: {
  temporalCoupling: Array<{
    fileA: string,
    fileB: string,
    coChangeCount: number,
    hasImportEdge: boolean,
    confidence: "high" | "medium" | "low"
  }>
}

Acceptance Criteria

  • Co-change pairs computed from git history
  • Hidden coupling flagged (co-change without import edge)
  • Exposed via MCP tool
  • Tests with real git repos

Priority

Short-term — High value, low effort (git data already parsed).

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions