Skip to content

bug: mixed-engine incremental build corrupts structure/contains edges #89

@carlos-alm

Description

@carlos-alm

Found during dogfooding v2.3.0

Severity: Medium
Command: codegraph build (incremental) then codegraph structure

Reproduction

  1. Build the graph with native engine:

    codegraph build . --engine native --no-incremental

    Verify: codegraph stats shows contains: 111, structure shows all files correctly.

  2. Modify a file (e.g., add a comment to src/logger.js)

  3. Run an incremental build using a different engine (e.g., WASM):

    codegraph build . --engine wasm
  4. Check structure:

    codegraph structure

Expected behavior

  • structure should still show all 99 files across all directories
  • stats should show consistent contains edge counts
  • Incremental builds should be engine-agnostic

Actual behavior

  • structure shows most directories as "0 files, 0 symbols"
  • stats shows contains edges drop from 111 to ~15
  • Only the incrementally-rebuilt file's directory retains correct data
  • This corrupted state also caused a downstream embed --strategy source crash with FOREIGN KEY constraint failed

Root cause

The incremental build appears to re-write structure/contains edges for the entire project, but only has data for the changed files. The unchanged files' contains edges are dropped. When the rebuild engine differs from the original, this is more likely to surface since partial rebuilds with engine mismatch trigger different code paths.

Suggested fix

  • Ensure structure rebuild during incremental builds only modifies directories containing changed files
  • Or store engine info in DB metadata and warn/force full rebuild when engine changes

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions