Skip to content

feat(impact): persist import edge details + 2-hop impact candidates#50

Merged
PatrickSys merged 1 commit intomasterfrom
feat/phase2-impact-details
Feb 28, 2026
Merged

feat(impact): persist import edge details + 2-hop impact candidates#50
PatrickSys merged 1 commit intomasterfrom
feat/phase2-impact-details

Conversation

@PatrickSys
Copy link
Owner

  • Persist internal import edge details (line + importedSymbols) in relationships/intelligence artifacts.\n- Use these details to compute 2-hop impact candidates for decision-card preflight.\n- Add structured preflight.impact.details while keeping preflight.impact.files for backward compatibility.\n- Ignore .pnpm-store/ repo-wide.\n\nTest plan: CI pnpm test; local pnpm build.

@greptile-apps
Copy link

greptile-apps bot commented Feb 28, 2026

Greptile Summary

Extended the codebase indexing system to persist import edge details (line numbers and imported symbols) and compute 2-hop impact candidates for better risk assessment in decision cards.

  • Import edge tracking: Modified InternalFileGraph.trackImport() to accept line numbers and symbols, merging details when multiple imports exist between the same files
  • Persistence: Updated relationships and intelligence artifacts to include importDetails field with conditional spreading to avoid empty objects
  • 2-hop analysis: Implemented computeImpactCandidates() to find both direct importers (hop 1) and importers-of-importers (hop 2), providing richer impact context
  • Backward compatibility: Maintained existing impact.files field while adding new impact.details array with line and hop information
  • CLI display: Enhanced formatter to show line numbers and hop distance when details are available

The changes maintain the framework-agnostic architecture and add no any types, adhering to project constraints. One minor style improvement opportunity exists in the path matching loop.

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk, pending CI test validation
  • Score reflects well-structured implementation with proper type safety, backward compatibility, and adherence to AGENTS.md constraints (no any types, framework-agnostic). Reduced from 5 due to: (1) minor performance optimization opportunity in path matching loop, (2) no new tests covering the 2-hop logic, and (3) need to verify CI tests pass as specified in PR description
  • Pay close attention to src/tools/search-codebase.ts for the complex 2-hop analysis logic

Important Files Changed

Filename Overview
src/core/indexer.ts Added line number parameter to trackImport call, conditionally includes importDetails in output
src/tools/search-codebase.ts Implemented 2-hop impact analysis with edge details - complex logic with minor performance optimization opportunity
src/utils/usage-tracker.ts Extended InternalFileGraph to track and persist import edge details (line + symbols) with proper merging logic

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Parse Imports<br/>indexer.ts] -->|line, symbols| B[InternalFileGraph.trackImport<br/>usage-tracker.ts]
    B -->|merge details| C[importDetails Map<br/>line + importedSymbols]
    C -->|toJSON| D[Persist to Artifacts<br/>relationships.json]
    D -->|load| E[search-codebase.ts<br/>getImportDetailsGraph]
    E -->|2-hop analysis| F[computeImpactCandidates<br/>hop 1 + hop 2]
    F -->|top 20 candidates| G[DecisionCard.impact<br/>files + details]
    G -->|format| H[CLI Display<br/>file:line hop N]
    
    style B fill:#e1f5ff
    style F fill:#fff4e1
    style G fill:#e8f5e9
Loading

Last reviewed commit: 5bd84a1

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@PatrickSys PatrickSys merged commit f296e30 into master Feb 28, 2026
3 checks passed
@PatrickSys PatrickSys deleted the feat/phase2-impact-details branch March 2, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant