feat(match): most-specific-subtree resolution with ancestor context (A6)#27
Merged
Merged
Conversation
When matches nest — a Page renders a Section renders a Card — resolve to the smallest subtree that covers the query (TRACKER step 4.3): - Coverage is now subtree-aware: a component covers a term if the term appears in its own text or any descendant's (via renders → instance-of edges). - A full-page term set (title + section + card term) ranks the page top, since only its subtree covers all terms. - A card-specific term set collapses the equal-coverage ancestors into the match's new `context` field and returns the deepest node (the card) — ancestors are context, not competing candidates. Non-nested matching is unchanged (subtree = self), so every existing fixture stays green. ComponentMatch gains `context`; eval GoldenQuery gains `context`. Fixture a6-composed-page. 36 core + 100 parser tests pass; eval green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Step 4.3 — Most-specific-subtree resolution
Failure mode A6. When matches nest — a Page renders a Section renders a Card — resolve to the smallest subtree that covers the query.
renders→instance-ofedges).contextfield and returns the deepest node (the card). Ancestors are context, not competing candidates.Non-nested matching is unchanged (subtree = self), so every existing fixture stays green.
API / eval
ComponentMatch.context?: ComponentNode[];GoldenQuery.context. Fixture a6-composed-page:["Analytics Dashboard", "Total revenue", "Workspace settings"]→DashboardPage["Total revenue", "vs last month"]→RevenueCard, context[RevenueSection, DashboardPage]Verification
pnpm eval: green, precision/recall 1.000, match accuracy 1.000.🤖 Generated with Claude Code