Skip to content

Commit 0f41699

Browse files
DeepCodeWorkclaude
andcommitted
feat: router adapters — React Router + Next.js routes → page components (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>
1 parent 3776287 commit 0f41699

34 files changed

Lines changed: 1093 additions & 8 deletions

TRACKER.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
## Status
66

77
- **Current phase:** 3 — Journey graph
8-
- **Next step:** 3.1Router adapters
9-
- **Done:** 0.1–0.4, 1.1–1.6, 2.1–2.5
8+
- **Next step:** 3.2Action effects
9+
- **Done:** 0.1–0.4, 1.1–1.6, 2.1–2.5, 3.1
1010
- **Gates passed:** Gate 0 (CI + red-path, #5/#6) · Gate 1 (precision 1.000, recall 0.895, zero poison) · Gate 2 (C1 instance attribution 1.000 · B1 4-level handler chains · C6 store writers↔readers · A9 portals — scorecard 137/0/0, precision & recall 1.000)
1111

1212
## What CodeRadar is
@@ -182,7 +182,7 @@ The heart of the project. C1 and B1 live here.
182182

183183
## Phase 3 — Journey graph
184184

185-
### [ ] 3.1 Router adapters
185+
### [x] 3.1 Router adapters
186186
**Failure modes:** B4
187187
**Build:** `RouteNode` (`path`, `layout`, `guards`) in core. Adapters: React Router (`createBrowserRouter` / `<Route>` trees, nested + lazy) and Next.js file-based (app + pages router). `routes-to` edges route → page-component instance tree.
188188
**Accept:** fixtures `b4-react-router`, `b4-nextjs-approuter` green: every golden route maps to its page component.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function PricingPage() {
2+
return <section>Simple, transparent pricing</section>;
3+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default function DashboardLayout({ children }: { children: React.ReactNode }) {
2+
return (
3+
<section>
4+
<aside>Dashboard menu</aside>
5+
{children}
6+
</section>
7+
);
8+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { useEffect, useState } from "react";
2+
3+
export default function DashboardPage() {
4+
const [metrics, setMetrics] = useState<unknown[]>([]);
5+
useEffect(() => {
6+
fetch("/api/metrics").then((r) => r.json()).then(setMetrics);
7+
}, []);
8+
return (
9+
<main>
10+
<h2>Key metrics</h2>
11+
<div>{metrics.length}</div>
12+
</main>
13+
);
14+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function DocsPage() {
2+
return <article>Documentation chapter</article>;
3+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export default function RootLayout({ children }: { children: React.ReactNode }) {
2+
return (
3+
<html lang="en">
4+
<body>
5+
<header>Nimbus Analytics</header>
6+
{children}
7+
</body>
8+
</html>
9+
);
10+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function HomePage() {
2+
return <h1>Your analytics at a glance</h1>;
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function UserProfilePage() {
2+
return <article>Member profile and activity</article>;
3+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/** Marks this fixture as a Next.js project for router detection. */
2+
export default {};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function MyApp({ Component, pageProps }: { Component: React.ComponentType; pageProps: Record<string, unknown> }) {
2+
return <Component {...pageProps} />;
3+
}

0 commit comments

Comments
 (0)