refactor: split impact.ts into fn-impact and diff-impact modules#617
refactor: split impact.ts into fn-impact and diff-impact modules#617carlos-alm wants to merge 3 commits intomainfrom
Conversation
|
Claude finished @carlos-alm's task —— View job Reviewing PR: Split impact.ts into fn-impact and diff-impact modulesConducting comprehensive 5-phase review analysis: Todo List:
Phase 1: Root Cause Analysis ✅Problem Being Solved: Large monolithic Why This Approach: Clean separation of concerns - function-level impact analysis ( Backward Compatibility: Maintained via re-export barrel pattern in the original Phase 2: Configuration Change Detection ✅No Configuration Changes: This is a pure code refactoring - no biome rules, test configurations, or build settings modified. Phase 3: Test Integrity ✅Test Coverage Preserved: Found 6 test files referencing the moved functions. All imports go through the barrel file ( Phase 4: Code Quality Assessment ✅Strengths:
Code Quality Issues Found:
Architecture Compliance:
Phase 5: Backlog Compliance EvaluationRoot Cause AnalysisProblem Being Solved: Reducing file complexity from 721 SLOC to maintainable modules (<350 SLOC each) to improve navigation and reduce cognitive load during development. Backlog Compliance
Critical ConcernsNone - This is a well-executed refactoring with proper backward compatibility. Minor improvements suggested:
Final Recommendation
This PR successfully achieves its goal of splitting a large file into focused modules while maintaining perfect backward compatibility. |
Greptile SummaryThis PR splits the 721-SLOC Key observations:
Confidence Score: 4/5Safe to merge once CI and the boundary/cycle checks from the test plan are confirmed green. The refactoring is a faithful, mechanical extraction with no logic changes. Backward compatibility is maintained through barrel re-exports, and the domain→presentation concern from the prior round has been addressed. The one remaining gate is CI validation (lint, build, tests, boundary check), which the author has listed as outstanding — that is a process gate, not a code defect. No files require special attention beyond CI confirmation; src/domain/queries.ts is worth a quick look if the boundary checker flags the presentation import, but the intent is architecturally defensible. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
queries["src/domain/queries.ts\n(barrel re-export)"]
impact["src/domain/analysis/impact.ts\n(barrel re-export)"]
fnImpact["src/domain/analysis/fn-impact.ts\nbfsTransitiveCallers\nimpactAnalysisData\nfnImpactData"]
diffImpact["src/domain/analysis/diff-impact.ts\ndiffImpactData\n+ git diff helpers"]
mermaid["src/presentation/diff-impact-mermaid.ts\ndiffImpactMermaid"]
queries -->|re-exports diffImpactData, fnImpactData, impactAnalysisData| impact
queries -->|re-exports diffImpactMermaid| mermaid
impact -->|re-exports| fnImpact
impact -->|re-exports| diffImpact
diffImpact -->|calls bfsTransitiveCallers| fnImpact
mermaid -->|calls diffImpactData| diffImpact
style queries fill:#e3f2fd,stroke:#1565c0
style impact fill:#e8f5e9,stroke:#2e7d32
style fnImpact fill:#f3e5f5,stroke:#6a1b9a
style diffImpact fill:#fff3e0,stroke:#e65100
style mermaid fill:#fce4ec,stroke:#880e4f
Reviews (2): Last reviewed commit: "fix: remove domain→presentation re-expor..." | Re-trigger Greptile |
| * Look up CODEOWNERS for changed and affected files. | ||
| * Returns null if no owners are found or lookup fails. | ||
| * impact.ts — Re-export barrel for backward compatibility. | ||
| * |
There was a problem hiding this comment.
Domain barrel re-exports from presentation layer
impact.ts lives in domain/analysis/ but re-exports diffImpactMermaid from ../../presentation/diff-impact-mermaid.js. This introduces a domain → presentation dependency edge in the graph.
The project's layered architecture runs codegraph check --boundaries to enforce that domain code does not import presentation code, and the PR itself lists that check as an outstanding to-do. Any importer that currently does import { diffImpactMermaid } from './impact.js' will silently acquire this upward dependency, and the boundary check should flag it.
The safest fix for backward compat is to drop the diffImpactMermaid re-export from the domain barrel and let the 15 importers be updated to point directly at presentation/diff-impact-mermaid.js. Alternatively, keep the re-export but move impact.ts itself outside the domain/ subtree (e.g., as a top-level or features/ barrel), so it is no longer classified as domain code.
| * | |
| export { diffImpactData } from './diff-impact.js'; | |
| export { bfsTransitiveCallers, fnImpactData, impactAnalysisData } from './fn-impact.js'; |
There was a problem hiding this comment.
Fixed. Removed the diffImpactMermaid re-export from domain/analysis/impact.ts so the domain barrel no longer crosses into the presentation layer. The re-export now lives in domain/queries.ts where it points directly at presentation/diff-impact-mermaid.js — queries.ts is a cross-cutting barrel so this is architecturally appropriate. All existing importers continue to work without changes.
There was a problem hiding this comment.
Fixed. Removed the diffImpactMermaid re-export from domain/analysis/impact.ts so the domain barrel no longer crosses into the presentation layer. The re-export now lives in domain/queries.ts where it points directly at presentation/diff-impact-mermaid.js — queries.ts is a cross-cutting barrel so this is architecturally appropriate. All existing importers continue to work without changes.
There was a problem hiding this comment.
…impact Impact: 1 functions changed, 2 affected
Move diffImpactMermaid re-export out of domain/analysis/impact.ts (which created a domain→presentation boundary violation) and into domain/queries.ts where it imports directly from the presentation layer.
Review StatusThis PR's core changes (splitting Review comments addressed:
CI status: Lint failing due to pre-existing Recommendation: Close this PR as superseded — the identical refactoring already exists on main. No unique changes remain that aren't already merged. |
Summary
impact.ts(721 SLOC) intofn-impact.tsanddiff-impact.tspresentation/diff-impact-mermaid.tsTitan Audit Context
Changes
src/domain/analysis/impact.ts-- reduced to re-exports and shared utilitiessrc/domain/analysis/fn-impact.ts-- extracted function-level impact analysis (BFS callers)src/domain/analysis/diff-impact.ts-- extracted diff-based impact analysis (git diff parsing)src/presentation/diff-impact-mermaid.ts-- extracted mermaid diagram renderingMetrics Impact
Test plan