Skip to content

feat: router adapters — React Router + Next.js routes → page components (B4)#18

Merged
officialCodeWork merged 1 commit into
developmentfrom
build/phase-3/step-3.1-router-adapters
Jul 14, 2026
Merged

feat: router adapters — React Router + Next.js routes → page components (B4)#18
officialCodeWork merged 1 commit into
developmentfrom
build/phase-3/step-3.1-router-adapters

Conversation

@officialCodeWork

Copy link
Copy Markdown
Owner

Step 3.1 — Router adapters (Phase 3 opener, failure mode B4)

Routes are the journey graph's entry points: this step teaches the graph which page component every URL renders.

Core

  • RouteNode{ path, router, layout, guards }, path patterns in :param form (catch-alls as :param*) so step 3.2's navigate(...) effects join on the same shape.
  • New routes-to edge: route → page component definition (its instances form the page tree).
  • JSON Schema regenerated (drift test green).

Parser — routes.ts

  • React Router: createBrowserRouter/createHashRouter/createMemoryRouter object trees and <Route> JSX trees (incl. createRoutesFromElements). Nested path joining, index routes, pathless guard routes, inline guard wrappers (element={<RequireAuth><AuditLog/></RequireAuth>}), Component prop, and lazy routes — both lazy: () => import(...) (module Component/default export) and React.lazy variables.
  • Next.js file-based: app router ([param]:param, [...catchAll]:catchAll*, (group) dropped, nearest ancestor layout.tsx recorded) and pages router (index collapse, _app/_document/api/** excluded). Gated on next.config.* or a next dependency so a plain React repo with a pages/ folder doesn't sprout fake routes.
  • Guard heuristic: wrapper components matching Require*/Protected*/Private*/;*Guard are guards; other wrappers are the nearest layout. Unresolvable pages emit route nodes flagged unresolved-page — visible, never silent.

Eval

  • routes + forbiddenRoutes golden checks (forbidden routes never xfail, like poison attributions).
  • New fixtures b4-react-router (8 routes across both declaration styles) and b4-nextjs-approuter (6 routes incl. a pages-router leftover).

Acceptance

  • Both B4 fixtures fully green: every golden route maps to its page component with the right layout/guards.
  • Scorecard 161 pass / 0 fail / 0 xfail, lineage precision & recall 1.000, match accuracy 1.000, eval gate OK.
  • 76 unit tests green (11 new), typecheck clean.

TRACKER updated: 3.1 done, next 3.2 (action effects).

🤖 Generated with Claude Code

…ts (B4)

Step 3.1. RouteNode (path/router/layout/guards) + routes-to edge in core;
parser adapters for createBrowserRouter object trees and <Route> JSX trees
(nested paths, index routes, pathless guard routes, inline guard wrappers,
lazy route modules) and Next.js file-based routing (app router with [param]/
[...catchAll]/(group) segments and nearest layout.tsx, pages router with
_app/api exclusions — gated on next.config/next dependency so plain repos
with a pages/ folder don't sprout fake routes). Unresolvable pages emit
flagged route nodes, never silence. Eval: routes + forbiddenRoutes checks;
fixtures b4-react-router, b4-nextjs-approuter — scorecard 161/0/0.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@officialCodeWork
officialCodeWork merged commit 9aab3f6 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