fix: incremental rebuild drops edges from unchanged files (#116)#120
fix: incremental rebuild drops edges from unchanged files (#116)#120carlos-alm merged 2 commits intomainfrom
Conversation
…116) When a file was rebuilt incrementally, edges from other unchanged files pointing to it were permanently lost because edge deletion was bidirectional and unchanged importers never rebuilt their edges. Add reverse-dependency cascade: before deleting nodes for changed files, find files with edges TO them, delete only their outgoing edges (preserving node IDs), and re-parse them so they participate in edge building. Impact: 1 functions changed, 1 affected
|
Claude finished @carlos-alm's task —— View job PR Review: Fix Incremental Rebuild Edge DroppingReview Todo List
Root Cause AnalysisProblem Being Solved: During incremental rebuilds, edges from unchanged files to changed files were being permanently lost. When a file changed, the system would delete both incoming and outgoing edges bidirectionally, and unchanged files that imported the changed file would never have their edges rebuilt, causing permanent graph corruption. Why This Approach: The fix implements a "reverse-dependency cascade" that identifies files with edges pointing TO changed files, preserves their node IDs while clearing only their outgoing edges, then adds them to the re-parse list so they participate in edge rebuilding. This is architecturally sound and maintains data integrity without breaking incremental build performance. Risk Assessment: LOW RISK - The fix is surgical, well-targeted, and includes comprehensive testing. Code Quality AssessmentStrengths:
Technical Quality:
Test Quality:
Minor Considerations
Final Assessment |
Greptile SummaryFixes a critical bug in incremental rebuilds where edges from unchanged files to changed files were permanently lost. The solution adds a reverse-dependency cascade that identifies files with edges pointing to changed files, deletes only their outgoing edges (preserving node IDs via the Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Start Incremental Build] --> B{Full Build?}
B -->|Yes| C[Delete All Edges/Nodes]
B -->|No| D[Build changedRelPaths Set]
D --> E[Query DB: Find Files with Edges TO Changed Files]
E --> F{Reverse Deps Found?}
F -->|Yes| G[Add to reverseDeps Set]
F -->|No| H[Delete Edges/Nodes for Changed Files]
G --> I[Verify File Exists on Disk]
I --> H
H --> J[Delete Only Outgoing Edges for Reverse Deps]
J --> K[Add Reverse Deps to parseChanges with _reverseDepOnly Flag]
K --> L[Parse All Files in parseChanges]
L --> M[Insert Nodes with INSERT OR IGNORE]
M --> N{Has _reverseDepOnly Flag?}
N -->|Yes| O[Skip Hash Update]
N -->|No| P[Update File Hash]
O --> Q[Rebuild Edges]
P --> Q
Q --> R[End]
C --> L
Last reviewed commit: aa3255f |
The lock file had @optave/codegraph-*-* at 2.3.0 while package.json requires 2.4.0, and win32-x64-msvc was missing entirely. This caused npm ci to fail in CI (License Compliance Scan).
|
Claude finished @carlos-alm's task —— View job PR Review: Fix Incremental Rebuild Edge DroppingReview Todo List
Root Cause AnalysisProblem Being Solved: During incremental rebuilds, edges from unchanged files to changed files were being permanently lost. When a file changed, the system would delete both incoming and outgoing edges bidirectionally, and unchanged files that imported the changed file would never have their edges rebuilt, causing permanent graph corruption. Why This Approach: The fix implements a "reverse-dependency cascade" that identifies files with edges pointing TO changed files, preserves their node IDs while clearing only their outgoing edges, then adds them to the re-parse list so they participate in edge rebuilding. This is architecturally sound and maintains data integrity without breaking incremental build performance. Risk Assessment: LOW RISK - The fix is surgical, well-targeted, and includes comprehensive testing. Configuration Change DetectionAnalysis: The primary change in package-lock.json appears to be a significant reduction in size (1032 lines deleted vs 52 added), which typically indicates dependency deduplication or removal of unused lockfile entries. This is LOW RISK as it doesn't involve relaxing linting rules, disabling strict modes, or increasing timeouts. No configuration files (biome.json, tsconfig.json, test configs) were modified. Test Integrity AssessmentExcellent Test Quality: The new test (tests/integration/build.test.js:264-331) is EXEMPLARY:
No Test Weakening: No existing tests were modified or assertions removed. Code Quality AssessmentStrengths:
Technical Quality:
Test Quality:
Minor Considerations
Final Assessment |
Summary
builder.js— before deleting nodes for changed files, finds all files with edges TO them, deletes only their outgoing edges (preserving node IDs), and adds them to the re-parse list so they participate in edge building.math.jspreserves all import and call edges fromutils.jsandindex.js.Closes #116
Test plan
npx vitest run tests/integration/build.test.js -t "issue #116"— passes, detects 2 reverse-deps, all 9 edges preservednpx vitest run tests/integration/— 158 passed, 2 skippednpm run lint— no issues