Skip to content

Use AST-aware navigation evidence for route reachability #1041

Description

@coderabbitai

Summary

Replace the raw-text navigation-reference matching used by the route-reachability guard with AST/token-aware extraction, or introduce a shared route manifest that provides equivalent authoritative reachability evidence.

Rationale

tests/route-reachability.test.ts currently scans complete source-file text and uses a navigation-context regex. The narrow matcher is sufficient for the wiring-focused work in #1030, but it can still treat comments, string content, and unrelated object properties as route links while missing valid object-form or computed navigation. The test should derive reachability from actual navigation syntax or a canonical manifest.

Affected area

  • tests/route-reachability.test.ts
  • Navigation components and route-builder modules as needed for AST extraction or manifest integration

Required changes

  1. Replace raw full-file regex scanning in referenceRegExp / isReachable with an AST/token-aware approach, or consume a shared route manifest.
  2. Count only genuine navigation uses (for example, Next Link hrefs and supported router/redirect calls).
  3. Do not count comments, route-ownership comparisons, ordinary strings, or unrelated object properties as navigation evidence.
  4. Recognize supported object-form and computed navigation expressions where their target can be established.
  5. Preserve existing canonical builder-target handling and the self-file exclusion behavior.
  6. Keep the guard offline and deterministic.

Acceptance criteria

  • A comment or unrelated { href: "/route" } object does not make an orphan route reachable.
  • Valid supported navigation constructs are recognized, including the documented router/redirect patterns.
  • Existing reachability coverage for canonical builders remains intact.
  • Focused tests cover false positives and false negatives introduced by the previous raw-text matcher.

Backlinks

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions