Skip to content

fix(sync): an import of a folder further up links its index file when it appears - #2669

Merged
colbymchenry merged 2 commits into
mainfrom
claude/sync-folder-imports-up
Oct 19, 2026
Merged

colbymchenry merged 2 commits into
mainfrom
claude/sync-folder-imports-up

Conversation

@colbymchenry

Copy link
Copy Markdown
Owner

Follow-up to #2666, from its validation.

Problem

An import that names a folder only through where it is written (., .., ../..) parks under no key, so sync tries each one where it is written whenever files are added (#2528's getFailedFolderImports). That lookup listed ., ./, .. and ../ only. An import of a folder two or more levels up stayed unlinked after the folder's index file was added or restored, though a fresh index links it. '../../' even parks under a stray / tail.

Seen in #2666's hold-out scenario on both arms: excalidraw's import { Excalidraw } from "../.." in FontPicker.test.tsx, siderbar.test.helpers.tsx and stats.test.tsx (to packages/excalidraw/index.tsx), and two in bitwarden.

Fix

getFailedFolderImports now lists the folder up to twelve levels above, with and without the trailing slash: 26 names in one IN list.

I also checked Python's from ... import x, whose module ref is ...: a fresh index doesn't link it to the package's __init__.py either, so there's no sync gap there and it isn't listed.

Validation

Arms: main = 437b5c3, fix = this branch, with the same native kernel. Kit: D:\cgwork\cgceil.

Regression test: a TypeScript case in sync-import-retry.test.ts's per-language table. src/a/b/c/m.ts imports '../..', '../../' and '../../..'. A sync then adds src/a/index.ts and src/index.ts, and the result is compared with a from-scratch rebuild. It fails on main, where only the bindings link, and passes here.

Fresh indexes, byte-identical controls: 9/9 identical (folo, vben, milo-ui, ghostfolio, infrahub, excalidraw, bitwarden, gin, django-realworld). The change only acts in sync.

Late scenario (every 7th source file held out, then synced; each arm compared with its own fresh dump):

repo fresh-only lines, main → fix recovered lost
excalidraw 5 → 0 3 import … from "../.." 0
bitwarden 65 → 51 2 '../..' imports and the 12 binding/reference edges that follow them 0
folo, vben, milo-ui, ghostfolio, infrahub, gin unchanged — 0

vben's sync still fails with #2565's FOREIGN KEY constraint failed on both arms (#2574 is open for it).

Cost/plan: the lookup stays on idx_unresolved_failed_import_name (SEARCH … USING INDEX idx_unresolved_failed_import_name (reference_kind=? AND reference_name=?)). On bitwarden's index it takes 0.8 ms for 26 names and finds 2 rows.

Full suite, with main's #2668 merged in and the native kernel built from main's source (CODEGRAPH_KERNEL_EXPECT=1, --maxWorkers=4): 612 files passed, 6 skipped; 7,477 tests passed, 0 failed, 80 skipped.

🤖 Generated with Claude Code

colbymchenry and others added 2 commits October 19, 2026 12:05
… it appears

An import that names a folder only through where it is written (`.`, `..`,
`../..`) is parked under no key, so sync tries each where it is written when
files are added (#2528). That lookup listed `.`, `./`, `..` and `../` only, so
`import { Excalidraw } from "../.."` in excalidraw's tests, or any import of a
folder two or more levels up, stayed unlinked after its folder's `index` file
was added or restored, though a fresh index links it. It now lists the folder
up to twelve levels above, with or without the trailing slash.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant