fix(mcp): stop search_api calling real addon APIs fake - #515
Merged
Conversation
search_api only read build/xrblocks.d.ts, so every addon API looked fake. AgentHands, LipsyncMouth, StylizedFace, RemoteControl and SpatialNarrator are all real and exported, and a lookup for any of them said it was likely not a real symbol and not to call it. That is the exact failure the tool exists to prevent, and it is worse than not answering, since an agent that checks and is told no will go and invent something else instead. Addons build to build/addons as one declaration file each rather than into the rolled-up bundle, so there is no trailing export list to filter against. In that shape the export keyword on the declaration is what makes a symbol public, which is what gets used when no list is present. Everything else stays: private and protected members are still dropped, and so is anything the file does not export. Takes the index from 2993 symbols to 4845 across 193 files. Re-checking all of those on every call was most of the cost of a lookup, so the cache is only revalidated once a second, which trades a result being at most a second stale for search dropping from 9ms to 0.5ms.
An agent asks about the thing it is about to write, and that is a path. xb.input.headGestures and xb.context.scene are both real, but symbols are indexed under their own names, so a lookup for either came back saying it was likely not a real symbol. Falls back to the last segment when the whole path finds nothing. xb.input.mindReading and xb.fake.nonsense are still rejected, since the segment that matters is the one at the end.
Indexing went from one file to around two hundred, and the tests that read the real generated definitions started timing out when the whole suite runs and they are all competing for disk. On its own the file indexes in about 370ms, under load it went past the default five second limit. Nothing wrong with the assertions, they just do real I/O now, so they get a longer limit and a name that says why.
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.
Description
Writing the eval tasks in #514 I checked every API in the specs against
search_api, and it told meAgentHands,LipsyncMouth,xb.input.headGesturesandxb.context.sceneweren't real. All four are.That's the thing I said in #508 was worse than having no tool at all, since an agent that bothers to check and gets told no will go off and invent something instead. Two separate causes.
It only read
build/xrblocks.d.ts. Addons build tobuild/addons/as one declaration file each, so every addon API was invisible,AgentHands,LipsyncMouth,StylizedFace,RemoteControl,SpatialNarrator, all of it. Those files don't have the trailingexport {...}list the core bundle has, they mark exports inline asexport declare class Foo, so when there's no list theexportkeyword is what counts. Private and protected members still get dropped, same as before. Index goes 2993 to 4845 across 193 files.The other one is that agents ask about what they're about to write, which is a path.
xb.input.headGesturesnever matched because symbols are indexed under their own names. Now falls back to the last segment when the full path finds nothing.xb.input.mindReadingandxb.fake.nonsensestill get rejected, since the segment that matters is the one on the end.Re-checking 193 files on every lookup turned out to be most of the cost of a search, so the cache only revalidates once a second. Search went 9ms to 0.5ms and a result can now be at most a second stale, which seemed a fair trade against being stale until you restart the server.
Also had to give the tests that read the real definitions a longer timeout. They do real I/O over ~200 files now and were timing out when the whole suite runs in parallel, about 370ms on their own but past the 5s default under load.
Checked the four that were wrong are now found, addon and dotted-path lookups both work, and nothing invented slipped through:
createXRScene,useGesture,playGesture,createAgentHands,xb.input.mindReading,xb.fake.nonsenseall still rejected.Type of Change
Media / Screen Recordings & Screenshots (If Applicable)
Nothing visual, it's the MCP server's API lookup.
Checklist