Commit f6f5482
authored
fix(native): backfill silently-dropped files via WASM for engine parity (#970)
* fix(native): backfill silently-dropped files via WASM for engine parity
The native engine's `parse_files_parallel` (Rust) uses `filter_map` with the
`?` operator, which silently drops any file whose read/parse/extract step
fails — including files in languages where the installed native addon lacks
an extractor (e.g. HCL/Scala/Swift on v3.9.2). WASM handles these languages
correctly, so benchmarks showed 668 native vs 728 WASM file nodes on the
same tree (#967).
Fix the parity gap in two places:
- `parseFilesAuto`: track which files the native parser actually returned;
re-parse the rest with WASM so the JS pipeline gets complete coverage.
- `tryNativeOrchestrator`: after the native Rust orchestrator writes to the
DB, diff `collectFiles()` against the `kind='file'` rows and backfill any
missing files via a WASM pass + `batchInsertNodes`.
Both paths warn explicitly when a drop happens so the underlying Rust
regression stays visible. This complements the Rust-side fix (adding
HCL/Scala/Swift extractors in newer binaries) by protecting users who
still have older native addons installed.
* fix: address review feedback on native backfill (#970)
- Scope backfill/warn to installed WASM grammars. Extract
getInstalledWasmExtensions() helper so the parity check in
parseFilesAuto and the post-orchestrator backfill both ignore
languages neither engine can parse (keeps warn count meaningful).
- Populate qualified_name and scope on backfilled symbol nodes so
cross-file reference resolution and go-to-definition queries can
find them (matches insertDefinitionsAndExports).
- Only run the post-orchestrator filesystem scan on full builds.
Incremental builds parse through parseFilesAuto, which already has
its own per-file backfill, so the extra scan was wasted work.
- Fix import ordering flagged by biome.
Impact: 4 functions changed, 14 affected
* fix(native): backfill exported symbols in WASM-dropped-files path (#970)
The engine-parity backfill in `backfillNativeDroppedFiles` was only
inserting `symbols.definitions` and skipping `symbols.exports`. Queries
filtering on `exported = 1` (e.g. dead-export detection, reverse-dep
walks, "exports of file") would miss symbols from backfilled files —
HCL/Scala/Swift on stale native addons.
Mirror the reference flow in
`src/domain/graph/builder/stages/insert-nodes.ts:insertDefinitionsAndExports`:
- Iterate `symbols.exports ?? []`, push an `INSERT OR IGNORE` row (no-op
if a definition row for the same name/kind/line already exists), and
collect the (name, kind, file, line) key for a second pass.
- After `batchInsertNodes`, run chunked `UPDATE nodes SET exported = 1
WHERE …` statements (chunk size 500 with a prepared-statement cache)
so backfilled exports are discoverable.
Also fix a smaller parity gap in the file row: `qualified_name` was
`relPath`; the reference flow uses `NULL`. Matches the canonical insert
so `kind='file'` rows are shape-identical across both paths.
Addresses Greptile P1 (comment 3107870224) on PR #970.
Impact: 1 functions changed, 4 affected1 parent 9be31e1 commit f6f5482
2 files changed
Lines changed: 158 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| 33 | + | |
32 | 34 | | |
33 | | - | |
| 35 | + | |
34 | 36 | | |
35 | 37 | | |
36 | | - | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| |||
696 | 698 | | |
697 | 699 | | |
698 | 700 | | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
699 | 713 | | |
700 | 714 | | |
701 | 715 | | |
702 | 716 | | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
703 | 818 | | |
704 | 819 | | |
705 | 820 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
338 | 338 | | |
339 | 339 | | |
340 | 340 | | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
341 | 362 | | |
342 | 363 | | |
343 | 364 | | |
| |||
884 | 905 | | |
885 | 906 | | |
886 | 907 | | |
| 908 | + | |
887 | 909 | | |
888 | 910 | | |
| 911 | + | |
889 | 912 | | |
890 | 913 | | |
891 | 914 | | |
| |||
901 | 924 | | |
902 | 925 | | |
903 | 926 | | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
904 | 945 | | |
905 | 946 | | |
906 | 947 | | |
| |||
0 commit comments