Repository navigation
fix(sync): a call through an imported object follows an edit to its members - #3373
Merged
Merged
Conversation
colbymchenry
force-pushed
the
claude/issue-3015-sync-object-members
branch
from
November 18, 2026 03:54
b930d01 to
3eb619e
Compare
…embers
In JavaScript and TypeScript, a call through an imported object binds to
the object's member when the object literal has one, and to the object
itself when it doesn't: `api.bar()` after `import { api } from './api'`,
with `export const api = { foo, bar }`. When a sync edited the literal, the
caller's file was unchanged, so its references weren't re-resolved, and the
edit declares no name (`{ foo }` to `{ foo, bar }`, `{ bar }` to
`{ bar: baz }`), so the definition-delta rebind (CG-33) and the other
module passes re-opened nothing. The call kept its old target, the object
or the old member, until the caller changed or the project was indexed
again, including through a facade whose members come from another module.
A new sync pass, after the other re-open passes for edited modules, reads
each object literal an edited JS/TS file exports to another file (a
constant or variable an `imports` edge reaches) from its new text, takes
the importers' references through it (`L.m`, under whatever local name),
and sends back to pending only those its text now disagrees with: on the
object though the literal has the member; elsewhere though it has the
member no more; on another name than the identifier the member names (an
import alias counts as that name); outside the literal though the member is
written inline. The orphan sweep then resolves them as a full index would.
An edit that leaves the members alone re-opens nothing. A literal whose
members a spread or computed key hides is left as before.
CODEGRAPH_NO_REBIND=1 turns the pass off with the rebind.
The literal's members are read by the same scan the resolver uses
(objectLiteralProperty), now split so both share it.
Validation:
- sync-object-members.test.ts: a member added, removed, repointed and
written inline; a facade whose members come from another module, reached
under an alias and through a barrel; an aliased import member and an
untouched member re-open nothing. Each case compares the synced graph with
a full index of the final tree. The 5 change cases fail on main and pass
here (7 passed).
- Sync, object-literal and alias resolution tests: 18 files, 321 passed.
- Sync cost on excalidraw (1,318 files), medians of 3 with the arm order
alternating, in two runs (v1.6.3 sources vs this branch): no-change sync
2.05 s vs 1.87 s and 1.36 s vs 1.37 s; a body edit 4.42 s vs 4.33 s and
3.26 s vs 3.55 s; an edit to packages/common/src/keys.ts, whose KEYS
literal 67 files import, 5.46 s vs 4.17 s and 3.61 s vs 3.73 s. Timed on
its own (CODEGRAPH_SYNTH_TIMINGS), the pass takes 0-1 ms on the body edit
and 67-113 ms on the keys.ts edit, re-opening nothing; the rest is this
shared machine's noise.
- Fresh indexes are byte-identical to v1.6.3 sources on taxonomy,
excalidraw, vscode-be and controls flask and gin (3 interleaved rounds).
Fixes #3015
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
colbymchenry
force-pushed
the
claude/issue-3015-sync-object-members
branch
from
November 18, 2026 03:58
3eb619e to
b10aa6e
Compare
This was referenced Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In JavaScript and TypeScript, a call through an imported object (
api.bar()afterimport { api } from './api', withexport const api = { foo, bar }) binds to the member the object literal names, or to the object itself when it names none. When a sync edited the literal (adding, removing or repointing a member), the call in the unchanged caller kept its old target until the caller changed or the project was indexed again. A sync now follows such an edit, and its result matches a fresh index.Root cause
The caller's file is unchanged, so its references aren't re-resolved. The edit declares no name:
{ foo }→{ foo, bar }adds no definition (baralready existed), and neither does{ bar }→{ bar: baz }. So the definition-delta rebind (CG-33) and the module re-open passes (default exports, barrels, name-matched imports, re-export targets) had nothing to go on. The literal's members aren't stored in the index; the resolver reads them from source each time.Fix
A new sync pass,
reopenReferencesThroughObjectMembers(src/resolution/module-importers.ts), runs after the other re-open passes for edited modules.importsedge reaches.L.m…, under whatever local name the importer uses) withgetResolutionEdgesThrough.The orphan sweep then resolves them exactly as a full index does. An edit that leaves the members alone re-opens nothing. A literal whose members a spread or computed key hides is left as before.
CODEGRAPH_NO_REBIND=1turns the pass off together with the rebind.The pass reads members with the same scan the resolver uses (
objectLiteralPropertyinname-matcher.ts), now split intoobjectLiteralMemberSpans/objectLiteralMemberOfso both share it.Validation
New tests.
__tests__/sync-object-members.test.tsindexes the first tree, edits, syncs, and compares the whole graph (edges and unresolved refs) with a full index of the final tree.bar→bar: baz) and written inline.import { api as A }) and through a barrel.Area tests. Sync, object-literal and alias-resolution test files: 18 files, 321 passed.
Fresh indexes are byte-identical to v1.6.3's sources (3 interleaved rounds) on taxonomy, excalidraw, vscode-be, and the controls flask and gin. The shared member scan changed nothing.
Sync cost on excalidraw (1,318 files), medians of 3, with the arm order alternating each round. Two runs, v1.6.3 sources → this branch:
scene/Renderer.ts)common/src/keys.ts, whoseKEYSliteral 67 files import (~710 uses)Timed on its own (
CODEGRAPH_SYNTH_TIMINGS), the pass takes 0–1 ms on the body edit and 67–113 ms on thekeys.tsedit, re-opening nothing. The rest of the swings are this shared machine's noise.Full suite: see the PR's READY note.
Left out
K.bar()after addingstatic bar) andObject.assigntargets aren't followed.Thanks @inth3shadows for the report and the differential harness that found it.
Fixes #3015
🤖 Generated with Claude Code