Skip to content

test(routing): use bound AST navigation evidence#1075

Merged
BigSimmo merged 3 commits into
mainfrom
codex/reconcile-route-reachability-ast
Jul 22, 2026
Merged

test(routing): use bound AST navigation evidence#1075
BigSimmo merged 3 commits into
mainfrom
codex/reconcile-route-reachability-ast

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • replace raw-text route reachability matching with Babel AST extraction
  • resolve next/link, next/navigation redirect/useRouter, and next/server response bindings with lexical shadowing
  • count data-driven hrefs only from the explicit ModeHomeTemplate.actions contract
  • cover aliased links, shadowed redirect/router/link names, conditional/template/object/computed targets, and arbitrary component metadata

Why

The previous regex could treat comments, strings, unrelated component props, or coincidental method names as inbound navigation. This makes the orphan-route guard depend on actual bound navigation syntax and fail closed for unsupported patterns.

Closes #1041.

RAG impact: no retrieval behaviour change — test-only route wiring guard.

Files

  • tests/route-reachability.test.ts

Verification

  • node scripts/run-vitest.mjs run tests/route-reachability.test.ts --reporter=verbose — 5/5 passed
  • npx eslint tests/route-reachability.test.ts — passed
  • npm run typecheck — passed
  • npm run test — 358 files passed; 3,172 passed; 1 skipped
  • npm run verify:cheap — all 20 gates passed; 358 files passed; 3,172 passed; 1 skipped
  • npm run verify:pr-local -- --dry-run --files tests/route-reachability.test.ts — selected runtime, format, lint, typecheck, full unit, and offline RAG fixture validation; build skipped as non-build-affecting
  • npm run check:rag:fixtures — 36 golden cases / 21 suites passed
  • git diff --check — passed

Checks not run

  • Browser/UI gates: test-infrastructure-only change with no UI/runtime code.
  • Provider-backed checks: no clinical, data, retrieval, database, or provider behavior changed.
  • The exact PR-local executor was not repeated after its selected format/lint/type/full-unit gates passed in verify:cheap; its only additional selected check, check:rag:fixtures, was run separately and passed.

Risk and rollback

The matcher is deliberately narrow. New navigation abstractions must be explicitly supported or the orphan guard will fail closed. Roll back by reverting commit 985226b26.

Summary by CodeRabbit

  • Tests
    • Improved route reachability validation to more accurately detect navigation links, redirects, router navigation, and conditional/template-based destinations.
    • Added coverage for aliased imports, variable shadowing, and supported action configurations.
    • Reduced false positives and false negatives when verifying that application routes can be reached.

@supabase

supabase Bot commented Jul 22, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 6f29a33c-18fe-4945-9b68-4e28eb1ed778

📥 Commits

Reviewing files that changed from the base of the PR and between 985226b and 58e57a7.

📒 Files selected for processing (1)
  • tests/route-reachability.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/route-reachability.test.ts

📝 Walkthrough

Walkthrough

Route reachability analysis now parses TypeScript/JSX with Babel, resolves framework navigation APIs through lexical scopes, extracts statically determinable destinations, and checks per-file target sets instead of matching raw source text.

Changes

Route reachability analysis

Layer / File(s) Summary
AST parsing and binding resolution
tests/route-reachability.test.ts
Adds Babel parsing, lexical scope tracking, and framework-specific binding resolution for supported navigation APIs.
Navigation target extraction
tests/route-reachability.test.ts
Extracts hrefs and redirect/router destinations from supported JSX, actions, and expressions, including statically determinable variants.
Reachability integration and tests
tests/route-reachability.test.ts
Stores computed per-file target sets, checks reachability through set membership, and adds coverage for aliases, shadowing, conditional destinations, and action-only inline hrefs.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SourceFiles
  participant BabelParser
  participant NavigationExtractor
  participant ReachabilityChecker
  SourceFiles->>BabelParser: parse each TypeScript/JSX file
  BabelParser->>NavigationExtractor: provide syntax tree
  NavigationExtractor->>SourceFiles: store computed navigation targets
  ReachabilityChecker->>SourceFiles: check route target membership
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: switching route-reachability tests to bound AST-based navigation evidence.
Description check ✅ Passed The description covers summary, rationale, files, verification, and risk/rollback, matching the repository template well.
Linked Issues check ✅ Passed The PR satisfies #1041 by replacing regex scanning with AST-aware navigation extraction, preserving deterministic offline reachability checks.
Out of Scope Changes check ✅ Passed The change stays within the test file and supporting test coverage, with no unrelated runtime or UI modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/reconcile-route-reachability-ast

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 985226b266

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tests/route-reachability.test.ts Outdated
Comment thread tests/route-reachability.test.ts Outdated
@BigSimmo
BigSimmo enabled auto-merge (squash) July 22, 2026 07:06
@BigSimmo
BigSimmo merged commit 46f143d into main Jul 22, 2026
34 checks passed
@BigSimmo
BigSimmo deleted the codex/reconcile-route-reachability-ast branch July 22, 2026 07:13
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.

Use AST-aware navigation evidence for route reachability

1 participant