fix(vue,explore): index Vue template bindings; rank exact identifiers above plain words - #2073
Open
L0garithmic wants to merge 2 commits into
Open
L0garithmic wants to merge 2 commits into
L0garithmic wants to merge 2 commits into
Conversation
…ve plain words
Vue SFC templates were indexed only for component tags. Identifiers a
template binds (`:prop="x"`, `@event="save"`, `v-if`, `v-for` sources,
`{{ mustache }}`) produced no edge, so "where is myLinkBrandingLocked
used" had no answer and explore never rendered the template lines that
bind a named symbol. The Vue extractor now emits `calls` for template
calls and handler names and `references` for bare identifiers the
<script> blocks declare or import, skipping v-for/slot locals, object
keys, member tails, globals and $-helpers. Explore renders same-file
use sites of a named symbol (the component envelope was dropped).
Explore: once a precise query token resolves to a named seed, a file
whose only claim is a plain query word (no seed, no precise term, no
symbol one edge from a seed) loses entry-file gate protection and
centrality and sorts last, so it only takes leftover budget.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…llocation cliff The precise-before-plain tier sorted src/profile/panel.ts (calls the named seed) above the word-only file, but allocateExploreBudget cliffed it to a pointer: it matches no query word, so its score (3.5) sat under the cliff (7.5) while the word-only file kept its bytes. Seed-neighbour files now carry an `anchored` flag that exempts them from the cliff only (weight and share unchanged), set only while a word-only file exists. The neighbour set is hoisted so the relevance gate also keeps them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Two fixes found while using codegraph on a large Vue + TypeScript monorepo.
1. Vue templates now produce edges for the identifiers they bind
Vue SFC templates were indexed for component tags only. An identifier a template binds (
:prop="x",@event="save",v-if/v-show/v-modelvalues,v-forsources,{{ mustache }}expressions) produced no edge, so "where ismyLinkBrandingLockedused" had no answer and explore never rendered the template line that binds a named symbol.src/extraction/vue-extractor.tsnow emitscallsfor template calls and handler names andreferencesfor bare identifiers that the<script>blocks declare or import. It skipsv-forand slot locals, object keys, member tails, globals and$-helpers. Explore also renders the same-file use sites of a named symbol, whose source is the whole-file component node that the range builder drops as an envelope.2. Exact identifiers rank above plain English words
Once a precise query token (camelCase, PascalCase, snake_case, qualified) resolves to a named seed, a file whose only claim is a plain query word (no seed, no precise term, no symbol one edge from a seed) now loses entry-file gate protection and centrality and sorts last, so it only gets leftover budget. Example:
WorkspaceMyLinkView appearance section myLinkBrandingLockedspent its budget after the view on an unrelated PHP layout class that matched only "section".A second commit keeps the files one edge from the named seed (its callers and callees) in the relevance gate, and exempts them from the allocation cliff only while such a word-only file is in the running. Without it, a caller of the exact symbol (the answer to "where is X used") scored under the cliff because it matches no query word, while the word-only file kept its bytes. Its weight and share are unchanged, and when no word-only file exists the cliff behaves exactly as before.
Tests
__tests__/extraction.test.ts: template bindings produce the expectedcallsandreferencesedges, and locals, keys, globals and$-helpers produce none.__tests__/explore-nl-stopword-collision.test.ts: precise-before-plain ordering.Rebased onto current
main(through #2064).tsc --noEmitis clean, and every__tests__/*explore*.test.tsfile plusextraction.test.tspasses (the 692 extraction tests included). One note from running them locally on Windows: with many files per worker a thread died with a V8 "Fatal process out of memory: Zone" before reporting. Each file passes on its own, so this looks like worker memory rather than these changes.