Skip to content

feat: add positional and spatial AX signals to lexical scoring#19

Merged
luigi-agosti merged 2 commits intomainfrom
feat/issue-7-positional-signals
Apr 11, 2026
Merged

feat: add positional and spatial AX signals to lexical scoring#19
luigi-agosti merged 2 commits intomainfrom
feat/issue-7-positional-signals

Conversation

@Djain912
Copy link
Copy Markdown
Collaborator

@Djain912 Djain912 commented Apr 2, 2026

Summary

  • add PositionalHints to element descriptors (Depth, SiblingIndex, SiblingCount, LabelledBy)
  • parse positional metadata from snapshot JSON in both flat and nested (positional) shapes
  • add positional lexical modifiers:
    • label association boost when query aligns with LabelledBy
    • small boost for singleton siblings (SiblingCount == 1)
  • add deterministic tie-break for equal scores using Depth (deeper preferred), then sibling index/ref for stable ordering
  • add unit tests for label association, sibling uniqueness, depth tiebreak, and snapshot propagation

Issue

Closes #7

Acceptance Mapping

  • PositionalHints added alongside ElementDescriptor
  • Label association extracted from snapshot/AX metadata (labelled_by / labeled_by)
  • Label match contributes to score
  • Depth used as tiebreak when scores equal
  • Unit tests with form elements and labels

Validation

  • go test ./internal/engine -run "SectionContext|LabelledByBoost|SiblingUniqueness|DepthBreaksEqualScores|ActionQueryPrefersInteractiveElement" -count=1 -v
  • go test ./cmd/semantic -run LoadSnapshot -count=1 -v
  • go test . -run "Composite|PositionalHints" -count=1 -v
  • go test ./... -count=1

Web-derived snapshot spot checks (manual)

  • semantic find "work email input" --snapshot testdata/snapshots/login-page.json --format json
  • semantic find "search wikipedia" --snapshot testdata/snapshots/wikipedia-article.json --format json
  • semantic find "pull requests tab" --snapshot testdata/snapshots/github-repo.json --format json

- add PositionalHints (depth, sibling index/count, labelled_by) to ElementDescriptor
- parse positional metadata from snapshot JSON (flat and nested forms)
- add label-association boost and sibling-uniqueness boost to lexical matching
- add depth-based deterministic tie-break for equal scores
- add unit tests for label boost, sibling uniqueness, depth tie-break, and snapshot propagation

Closes #7
Comment thread cmd/semantic/main.go Outdated
Drop labeled_by (American spelling) fallback, keeping only labelled_by
per W3C ARIA spec (aria-labelledby).
@luigi-agosti luigi-agosti force-pushed the feat/issue-7-positional-signals branch from 6128ee7 to 236ceb5 Compare April 11, 2026 19:20
@luigi-agosti luigi-agosti merged commit 97d2dd5 into main Apr 11, 2026
7 checks passed
@luigi-agosti luigi-agosti deleted the feat/issue-7-positional-signals branch April 11, 2026 20:50
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.

Positional and spatial signals from AX tree

2 participants