fix(cache): Correct key collisions, anchor/whole-file isolation, and cache-hit detection for undefined values#22
Draft
Copilot wants to merge 2 commits intoperf/file-cachefrom
Draft
fix(cache): Correct key collisions, anchor/whole-file isolation, and cache-hit detection for undefined values#22Copilot wants to merge 2 commits intoperf/file-cachefrom
Copilot wants to merge 2 commits intoperf/file-cachefrom
Conversation
Co-authored-by: ryodine <5068378+ryodine@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add cache to speed up reference resolution
fix(cache): Correct key collisions, anchor/whole-file isolation, and cache-hit detection for undefined values
Mar 15, 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.
FileCachehad three correctness bugs:|-separator key collisions, anchor-scoped parsed results polluting the whole-file cache slot, and false cache misses for legitimately-undefinedparsed values (e.g.!ignore-rooted documents).src/cache.tsMap<string, CacheEntry>keyed by"filePath|anchor"with a nestedMap<string, Map<string|undefined, unknown>>. Paths or anchors containing|can no longer collide.fileContents: Map<string, string>. Callingset(path, content, anchor, fileContent)no longer synthesises a whole-file parsed entry — a subsequentget(path)(no anchor) correctly yields a miss and triggers a fresh full-document parse.has()/hasAsync(): New methods distinguish a storedundefinedvalue from a genuine cache miss, sinceget()returnsundefinedin both cases.src/parser.tscache.has(...)instead ofcached !== undefined, so!ignore-rooted files (which parse toundefined) are not endlessly reparsed.cachedContentguard changed fromif (cachedContent)→if (cachedContent !== undefined)in both sync and async paths, so empty files cached as""are not re-read from disk.test/cache.test.tsset(path, content, anchor, fileContent)— one parsed entry (anchor-scoped), zero whole-file parsed entry,getFileContentstill returns the raw string.has()assertion to the "cache undefined values" case to cover the new API.💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.