fix(sync): a call left with one candidate links after a delete or a rename

x.go() with go in two classes stays unlinked while both exist. A sync that
deleted one of them, or renamed it away, never retried that call: the
failed-reference retry looks refs up by the names the changed files carry
now, which a deleted file or a renamed-away name no longer has, and a sync
that only deletes files skips the retry. Failed refs under the names a
sync's definitionDelta lost or gained now go back to pending for the
sweep, next to the CG-33 rebind that does the same for resolved edges,
under the same per-name ceiling. CODEGRAPH_NO_REBIND=1 turns both off.

Review changes: the CHANGELOG entry beside the sync entries for calls,
with credit.

Validation: 6 tests; on main's source the 4 delete and rename tests fail
and the 2 still-ambiguous controls pass. 10 fixture edits (Python,
TypeScript, JavaScript, Go, Java), each compared with a fresh index of the
same tree, in a later process and in the same process: main diverged in 6
of each, this in none. excalidraw with excalidraw-app/data/LocalData.ts
deleted (its `save` was one of two): main was 38 edges short of a fresh
index, identical here over nodes, edges, refs and files; renaming
BinaryHeap's `pop` away re-opens 28 refs that fail again, as in a fresh
index.

Original PR #3004 by @inth3shadows.
Fixes #3006

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Eric Minish
2026-10-30 12:00:19 +00:00
committed by Colby Mchenry
co-authored by Claude Opus 5.5
parent e431491972
commit 2d98c1b69a
4 changed files with 158 additions and 3 deletions
+13 -2
View File
@@ -1526,7 +1526,8 @@ export class CodeGraph {
// as a full index resolves.
//
// `definitionDelta` is empty for a body-only edit, so the overwhelmingly
// common sync pays one branch. CODEGRAPH_NO_REBIND=1 disables it.
// common sync pays one branch. CODEGRAPH_NO_REBIND=1 disables it, and
// the failed-ref re-open that follows the rebind with it.
if (result.definitionDelta && process.env.CODEGRAPH_NO_REBIND !== '1') {
const tRebind = Date.now();
const rebound = this.orchestrator.resurrectStaleResolutionEdges(
@@ -1534,9 +1535,19 @@ export class CodeGraph {
result.changedFilePaths ?? [],
edgesBeforeRetry
);
// And the failed refs under those names: a call that failed only
// because two definitions shared its name (`x.go()` with `go` in two
// classes) resolves once one of them is gone. The retry above looks
// failed refs up by the names the changed files carry now, which a
// deleted file or a name renamed away no longer has, and a sync that
// only deletes files skips it. The sweep below resolves what this
// re-opens.
const reopenedFailed = this.queries.reopenFailedReferences(
this.queries.getRetryableFailedReferences(result.definitionDelta).flatMap((ref) => (ref.rowId === undefined ? [] : [ref.rowId]))
);
if (process.env.CODEGRAPH_SYNTH_TIMINGS) {
console.error(
`[phase-timing] sync-rebind: ${Date.now() - tRebind}ms (${result.definitionDelta.length} changed names, ${rebound} edges re-opened)`
`[phase-timing] sync-rebind: ${Date.now() - tRebind}ms (${result.definitionDelta.length} changed names, ${rebound} edges and ${reopenedFailed} failed refs re-opened)`
);
}
}