Skip to content

fix(builder): incremental rebuild EISDIR, edge parity, dev tarball, native version#241

Merged
carlos-alm merged 8 commits intomainfrom
fix/dogfood-bugs-235-236-237
Mar 2, 2026
Merged

fix(builder): incremental rebuild EISDIR, edge parity, dev tarball, native version#241
carlos-alm merged 8 commits intomainfrom
fix/dogfood-bugs-235-236-237

Conversation

@carlos-alm
Copy link
Contributor

Summary

Fixes four issues found during v2.5.35-dev dogfooding:

Test plan

  • New incremental-parity.test.js — full build vs incremental build produces identical nodes and edges (barrel-project fixture)
  • All 1063 existing tests pass
  • --strip flag verified: removes platform deps, keeps other optional deps

Closes #235, closes #236, closes #237

…ld docs

- Add node/edge count drift detection after incremental builds (>20% warns
  to use --no-incremental), persisting counts in build_meta
- Improve complexity command: when data is missing but graph exists, suggest
  --no-incremental instead of implying no graph exists
- Add @huggingface/transformers as devDependency so embedding benchmarks
  work out of the box
- Document dev build tarball installation in README (npm install <url> fails
  for optional platform deps)

Impact: 3 functions changed, 5 affected
…provements

Impact: 1 functions changed, 1 affected
- Add build.driftThreshold to config defaults (0.2) so the 20%
  incremental build drift threshold is user-configurable
- Include actual drift percentages and threshold in warning message
  for easier debugging
- Regenerate package-lock.json to include @huggingface/transformers
  devDependency (fixes License Compliance Scan CI failure)

Impact: 1 functions changed, 1 affected
…ative version

- filter directory nodes from reverse-deps query to prevent EISDIR (#235)
- load unchanged barrel files into reexportMap so barrel-resolved edges
  aren't dropped during incremental rebuilds (#236)
- add --strip flag to sync-native-versions.js removing platform
  optionalDependencies in dev builds, fixing npm install failures (#237)
- sync Cargo.toml version with package.json and automate via version script
- add barrel-project fixture and incremental-parity test

Impact: 4 functions changed, 1 affected
@claude
Copy link

claude bot commented Mar 2, 2026

Claude finished @carlos-alm's task —— View job


PR Review Complete

Reviewing PR #241: fix(builder): incremental rebuild EISDIR, edge parity, dev tarball, native version

Todo List:

  • Phase 1: Root cause analysis for the 4 bug fixes
  • Phase 2: Check for risky configuration changes
  • Phase 3: Validate test integrity and new test coverage
  • Phase 4: Review code quality in critical files
  • Final: Provide rating and recommendation

Phase 1: Root Cause Analysis ✅

Problem Being Solved: Four distinct incremental build issues identified during v2.5.35-dev dogfooding:

  1. bug: EISDIR warning during incremental rebuild — 'src' directory treated as file #235 EISDIR warning: During incremental rebuilds, directory nodes were entering the reverse dependency query, causing file system errors when trying to parse directories as files.

  2. bug: incremental rebuild produces different edge count than full rebuild #236 Edge count mismatch: Incremental builds were dropping barrel-resolved import/call edges because unchanged barrel files weren't loaded into the reexportMap during resolution.

  3. bug: dev build native binary tarball cannot be installed via npm install <url> #237 Dev tarball install fails: Development versions (containing -dev) fail npm installation because @optave/codegraph-* platform packages don't exist for dev versions.

  4. Native version mismatch: Cargo.toml version was out of sync with package.json, causing engine version reporting inconsistencies.

Why This Approach: These are genuine architectural fixes addressing real issues:

  • EISDIR fix targets the SQL query specifically with n_src.kind != 'directory' filter (builder.js:463)
  • Edge parity fix loads barrel files for resolution without adding them to the parse loop (lines 690-728)
  • Dev tarball fix adds --strip flag to remove platform deps that don't exist for dev versions
  • Version sync automates Cargo.toml updates in the existing sync script

Phase 2: Configuration Change Detection ✅

LOW RISK: No risky configuration changes detected:

  • ✅ Biome configuration unchanged
  • ✅ No linting rules disabled or relaxed
  • ✅ No test timeouts increased or coverage thresholds lowered
  • ✅ No TypeScript strict mode flags disabled
  • ✅ The --strip flag addition is a build-time tool, not a rule relaxation

Phase 3: Test Integrity ✅

EXCELLENT: New test coverage addresses the core issue:

  • ✅ New incremental-parity.test.js is specifically designed to catch edge count mismatches
  • ✅ Test uses barrel-file fixture to exercise the exact re-export resolution scenario that was failing
  • ✅ Compares full build vs incremental build for identical results (nodes + edges)
  • ✅ Test methodology is sound: touch file → incremental rebuild → compare with full rebuild
  • ✅ No weakened assertions or test modifications
  • ✅ 60s timeout is appropriate for build operations

Test Quality: The test directly validates the fix with proper isolation (temporary directories) and comprehensive verification (node count, edge count, node equality, edge equality).

Phase 4: Code Quality ✅

SOLID IMPLEMENTATION:

  1. EISDIR Fix (builder.js:463): Clean SQL filter n_src.kind != 'directory' prevents directories from entering file processing pipeline. Targeted and minimal.

  2. Edge Parity Fix (builder.js:694-728): Elegant solution using barrelOnlyFiles set to load barrel files for resolution without double-processing their edges. The barrelCandidates query correctly identifies files with reexports edges.

  3. Dev Tarball Fix (sync-native-versions.js:19-25): Simple boolean flag implementation. Clean separation of concerns with proper conditional logic.

  4. Version Sync (sync-native-versions.js:29-39): Automated Cargo.toml version syncing with proper error handling (try/catch for missing file).

Architecture Quality: All fixes are minimally invasive, well-documented with comments, and follow existing patterns. No performance regressions or security concerns.

Root Cause Analysis

Problem Being Solved: Four genuine incremental build bugs identified through dogfooding, not configuration workarounds
Why This Approach: Targeted fixes addressing root causes, not symptoms
Risk Assessment: LOW - minimal, surgical changes with comprehensive test coverage

Critical Concerns

None. This is high-quality defensive programming addressing real architectural issues.

Final Recommendation

  • Rating: ⭐⭐⭐⭐☆ (4/5)
  • Action: APPROVE
  • Reasoning: Solid architectural fixes with excellent test coverage. The edge parity fix is particularly well-engineered, solving a complex incremental build problem with minimal code. All changes are backed by comprehensive testing and address real issues found during dogfooding.

@carlos-alm carlos-alm merged commit 6b5ff27 into main Mar 2, 2026
40 checks passed
@carlos-alm carlos-alm deleted the fix/dogfood-bugs-235-236-237 branch March 2, 2026 11:19
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 2, 2026

Greptile Summary

This PR comprehensively addresses four dogfooding issues with well-structured fixes:

The implementation includes comprehensive testing with a new incremental-parity.test.js that verifies full and incremental builds produce identical results using a barrel-file fixture. The PR also adds drift detection that warns when incremental builds diverge significantly from previous node/edge counts (configurable via driftThreshold).

All 1063 existing tests pass, and the changes integrate cleanly with the existing codebase architecture.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Well-tested fixes for specific issues with comprehensive test coverage (including new incremental-parity test), all existing tests passing, and clean architectural integration. The only minor concern is an undocumented dependency addition.
  • No files require special attention

Important Files Changed

Filename Overview
src/builder.js Fixes EISDIR warning by filtering directory nodes, resolves edge parity by loading barrel files during incremental builds, adds drift detection
scripts/sync-native-versions.js Adds --strip flag for dev builds and automates Cargo.toml version syncing
tests/integration/incremental-parity.test.js Comprehensive test verifying incremental builds produce identical results to full builds using barrel file fixture
crates/codegraph-core/Cargo.toml Version synced from 0.1.0 to 2.6.0 to match package.json
src/config.js Added configurable driftThreshold default (0.2) for incremental build verification
.github/workflows/publish.yml Added --strip flag to sync-native-versions.js call for dev build publishing
package.json Added @huggingface/transformers to devDependencies (not mentioned in PR description)

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    Start[Start Incremental Build] --> CheckBuild{Full Build?}
    CheckBuild -->|Yes| ParseAll[Parse All Files]
    CheckBuild -->|No| FindChanged[Find Changed Files]
    
    FindChanged --> ReverseDeps[Query Reverse Dependencies]
    ReverseDeps --> FilterDirs[Filter Directory Nodes<br/>Fix #235]
    FilterDirs --> ParseChanged[Parse Changed + Reverse Dep Files]
    
    ParseChanged --> LoadBarrels[Load Unchanged Barrel Files<br/>Fix #236]
    LoadBarrels --> BuildReexportMap[Build reexportMap]
    
    ParseAll --> BuildEdges[Build Edges Loop]
    BuildReexportMap --> BuildEdges
    
    BuildEdges --> SkipBarrelOnly{File in<br/>barrelOnlyFiles?}
    SkipBarrelOnly -->|Yes| Skip[Skip - Edges Already in DB]
    SkipBarrelOnly -->|No| CreateEdges[Create Import/Call Edges]
    
    Skip --> NextFile{More Files?}
    CreateEdges --> NextFile
    NextFile -->|Yes| BuildEdges
    NextFile -->|No| DriftCheck{Incremental?}
    
    DriftCheck -->|Yes| VerifyDrift[Check Node/Edge Drift<br/>vs Previous Counts]
    DriftCheck -->|No| SaveMetadata[Save Metadata]
    
    VerifyDrift --> DriftThreshold{Drift ><br/>threshold?}
    DriftThreshold -->|Yes| Warn[Warn: Rebuild Recommended]
    DriftThreshold -->|No| SaveMetadata
    Warn --> SaveMetadata
    
    SaveMetadata --> StoreCount[Store node_count,<br/>edge_count in metadata]
    StoreCount --> End[Build Complete]
Loading

Last reviewed commit: 1216acc

Copy link
Contributor

@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.

14 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

},
"devDependencies": {
"@biomejs/biome": "^2.4.4",
"@huggingface/transformers": "^3.8.1",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was @huggingface/transformers added to devDependencies? This change isn't mentioned in the PR description. If needed for testing, consider adding a note in the PR description.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

carlos-alm added a commit that referenced this pull request Mar 2, 2026
* docs: add dogfood report for v2.5.35-dev.26434e2

* docs: move dogfood report to correct path

* docs: remove report from incorrect worktree path

* docs: move v2.5.0 dogfood report to generated/dogfood/

* fix: incremental build verification, complexity warnings, and dev build docs

- Add node/edge count drift detection after incremental builds (>20% warns
  to use --no-incremental), persisting counts in build_meta
- Improve complexity command: when data is missing but graph exists, suggest
  --no-incremental instead of implying no graph exists
- Add @huggingface/transformers as devDependency so embedding benchmarks
  work out of the box
- Document dev build tarball installation in README (npm install <url> fails
  for optional platform deps)

Impact: 3 functions changed, 5 affected

* fix: configurable drift threshold, drift logging, and lock file sync

- Add build.driftThreshold to config defaults (0.2) so the 20%
  incremental build drift threshold is user-configurable
- Include actual drift percentages and threshold in warning message
  for easier debugging
- Regenerate package-lock.json to include @huggingface/transformers
  devDependency (fixes License Compliance Scan CI failure)

Impact: 1 functions changed, 1 affected

* fix(builder): incremental rebuild EISDIR, edge parity, dev tarball, native version

- filter directory nodes from reverse-deps query to prevent EISDIR (#235)
- load unchanged barrel files into reexportMap so barrel-resolved edges
  aren't dropped during incremental rebuilds (#236)
- add --strip flag to sync-native-versions.js removing platform
  optionalDependencies in dev builds, fixing npm install failures (#237)
- sync Cargo.toml version with package.json and automate via version script
- add barrel-project fixture and incremental-parity test

Impact: 4 functions changed, 1 affected

* docs: update 2.6.0 changelog with merged PRs #233 #239 #240 #241
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant