Skip to content

feat(match): most-specific-subtree resolution with ancestor context (A6)#27

Merged
officialCodeWork merged 1 commit into
developmentfrom
build/phase-4/step-4.3-subtree
Jul 14, 2026
Merged

feat(match): most-specific-subtree resolution with ancestor context (A6)#27
officialCodeWork merged 1 commit into
developmentfrom
build/phase-4/step-4.3-subtree

Conversation

@officialCodeWork

Copy link
Copy Markdown
Owner

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.

  • Subtree-aware coverage: a component covers a term if the term is in its own text or any descendant's (via rendersinstance-of edges).
  • A full-page term set (title + section + card term) ranks the page top — 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.

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

  • 36 core + 100 parser tests pass (3 new subtree tests).
  • pnpm eval: green, precision/recall 1.000, match accuracy 1.000.

🤖 Generated with Claude Code

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>
@officialCodeWork
officialCodeWork merged commit 69fd357 into development Jul 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants