Skip to content

bug(native): SQLITE_CORRUPT during incremental rebuild — breaks benchmark #715

@carlos-alm

Description

@carlos-alm

Summary

The native (Rust) engine crashes with SQLITE_CORRUPT during 1-file incremental rebuilds, causing the benchmark worker to exit with code 1 and producing "native": null in benchmark results since v3.6.0.

Evidence

From CI workflow run #538, build-benchmark job logs:

[codegraph] Using native engine (v3.6.0)
[codegraph] Parsed 514 files (0 skipped)
[codegraph] Graph built: 13184 nodes, 25423 edges
  [native] Benchmarking no-op rebuild...
  ...

Then during the 1-file incremental rebuild:

at runPipelineStages (file:///tmp/codegraph-bench-ulUFNK/node_modules/@optave/codegraph/dist/domain/graph/builder/pipeline.js:176:11)
at async buildGraph (file:///tmp/codegraph-bench-ulUFNK/node_modules/@optave/codegraph/dist/domain/graph/builder/pipeline.js:230:9)
at async file:///home/runner/work/ops-codegraph-tool/ops-codegraph-tool/scripts/benchmark.ts:168:15 {
  code: 'SQLITE_CORRUPT'
}

Node.js v22.22.1
[fork] native worker exited with code 1

Impact

Additional context

Edge count discrepancy: native reports 25,423 edges vs WASM 25,425 (−2). This parity gap may be related to the corruption — the native engine may be writing slightly different graph structures that become inconsistent on incremental update.

The no-op rebuild appears to work (it ran 3 times before the 1-file rebuild), so the corruption is triggered specifically when re-parsing a modified file and running pipeline stages on the changed subset.

Reproduce

npx codegraph build . --engine native
# modify any file
npx codegraph build . --engine native --incremental

Expected

Native incremental rebuild should succeed without SQLITE_CORRUPT, matching WASM behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions