Skip to content

fix(sync): record only indexed files as synthesis inputs - #2688

Merged
colbymchenry merged 1 commit into
mainfrom
claude/synthesis-inputs-indexed-files
Oct 19, 2026
Merged

colbymchenry merged 1 commit into
mainfrom
claude/synthesis-inputs-indexed-files

Conversation

@colbymchenry

Copy link
Copy Markdown
Owner

Fixes #2565.

What was wrong

codegraph sync exits 1 with Failed to sync: FOREIGN KEY constraint failed in a project whose code lazy-loads a workspace package, and every later sync fails the same way. A full index of the same tree succeeds. @bompus's report bisects it to #2420 and pins the cause:

  • lazyValueModules names the module a lazy value loads as a synthesis input, so a sync that changes the module redraws the JSX that names the value.
  • For dynamic(() => import('icons').then((mod) => mod.EdgeFunctions)) (Supabase Studio), the resolver hands back the package directory, packages/icons. vben's () => import('@vben/layouts').then((m) => m.IFrameView) does the same in five apps.
  • synthesis_inputs.file_path references files(path). The stage's publish step therefore fails on the directory, and the whole sync rolls back.

What changed

Both places that write synthesis_inputs now keep only paths the files table holds:

  • QueryBuilder.replaceSynthesisInputs, which writes to the index directly;
  • SynthesisStage.publish, inside its BEGIN IMMEDIATE write transaction. That also covers a file leaving the index while the passes run.

A directory never matched a changed file, so dropping it loses nothing.

Not in scope: resolving a workspace package's lazy import to its entry file. With that, the value would reach EdgeFunctions, and an edit to the entry would redraw it. Today the lookup reads the directory and finds nothing, before and after this change.

Tests (__tests__/sync-synthesis-inputs.test.ts)

A/B: main 3308cff vs this branch, native kernel built from the same source

  • Fresh indexes: vben (61c0793), excalidraw (e1b7aac) and zod (afdac65) are byte-identical (scripts/dump-graph.mjs).
  • vben sync: index, then append a line to the five apps/*/src/layouts/index.ts files, then codegraph sync.
    • main: exit 1, FOREIGN KEY constraint failed.
    • this branch: exit 0, and the synced graph equals a fresh index of the edited tree.

Credit

Reported and diagnosed by @bompus. @inth3shadows found the same cause and opened #2574 for it; this is our own implementation, and the CHANGELOG thanks both.

🤖 Generated with Claude Code

A sync whose code lazy-loads a workspace package failed with "FOREIGN KEY
constraint failed" and rolled back, and every later sync did the same
(issue 2565). lazyValueModules names the module a lazy value loads as a
synthesis input, and for `import('icons')` or `import('@vben/layouts')`
the resolver gives the package directory, which is not an indexed file.
synthesis_inputs.file_path references files(path), so the stage's publish
step failed. A file that leaves the index while the passes run broke it
the same way.

Both places that write synthesis_inputs now keep only paths the files
table holds: replaceSynthesisInputs on the index, and SynthesisStage's
publish, inside its write transaction. The directory never matched a
changed file anyway, so nothing is lost.

A/B on main 3308cff: fresh indexes of vben, excalidraw and zod are
byte-identical; vben's sync after editing its five layouts/index.ts files
exits 1 on main and 0 here, and the synced graph equals a fresh index of
the edited tree.

Reported by @bompus; @inth3shadows found the same cause.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@colbymchenry
colbymchenry merged commit e8b478a into main Oct 19, 2026
@colbymchenry
colbymchenry deleted the claude/synthesis-inputs-indexed-files branch October 19, 2026 23:24
danusha2345 pushed a commit to danusha2345/codegraph that referenced this pull request Oct 20, 2026
…eam as colbymchenry#2688

Reverts the four colbymchenry#2574 commits (98be01f, 9769065, 2bc5180, d194b4c);
the maintainer's own fix for colbymchenry#2565 comes in with the next merge of main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
danusha2345 pushed a commit to danusha2345/codegraph that referenced this pull request Oct 20, 2026
…Rust Self:: and std impls, colbymchenry#2688 synthesis inputs, first foreign merges)

Conflicts: name-matcher takes main's `isGoOutsideImport` family in place of
colbymchenry#1954's `isGoExternalImport`; keeps colbymchenry#1942's Java same-language preference and
colbymchenry#1947's `cls` beside main's `withinCppTranslationUnit`; colbymchenry#1949's Java static
field block and main's Rust `Self::` block both stay; colbymchenry#1935's `findOwnMethod`
gets main's Go standard-method-name condition.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
inth3shadows added a commit to inth3shadows/codegraph that referenced this pull request Oct 21, 2026
Upstream merged 17 of the fork's carried PRs on 2026-10-20 (several
squashed, some with maintainer edits; colbymchenry#1704's content landed inside
colbymchenry#1926). Every conflict was our pre-merge copy of one of them, so the
upstream side was taken throughout. After the merge the tree differs
from upstream only by colbymchenry#1842, its test-flag fix, .gitignore, the
untracked .pyc and the README banner.

Dropped __tests__/sync-synthesis-input-package.test.ts: colbymchenry#2574 was
superseded by upstream colbymchenry#2688, which does not normalize spellings like
`@/widgets/Chart/`. That gap is colbymchenry#2577; it is carried separately via colbymchenry#2610.
inth3shadows added a commit to inth3shadows/codegraph that referenced this pull request Oct 21, 2026
…fixes colbymchenry#2577)

Carries upstream PR colbymchenry#2610 by @JiaMingWang-CN. Restores the fork's
end-to-end test from colbymchenry#2574 (sync-synthesis-input-package), which upstream's
colbymchenry#2688 alone fails on the `@/widgets/Chart/` and `src/widgets/./Chart`
spellings and which passes with colbymchenry#2610.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

codegraph sync fails with "FOREIGN KEY constraint failed" after d0bb9be5 when a file lazy-loads a workspace package

1 participant