---
name: step-04-route-audit
description: Verify route alignment between navigation seed data, componentRegistry, and controllers
next_step: steps/step-05-report.md
---

# Step 4: Route Audit

## YOUR TASK:
Verify that routes are consistent across 3 sources: navigation seed data, componentRegistry (PageRegistry), and backend controllers (NavRoute attributes).

---

## EXECUTION SEQUENCE:

### 1. Extract Seed Data Routes

From {seed_files}, extract all section routes:
```
{seed_routes} = [
  { code: "departments", route: "/human-resources/employees/departments", file: "...", line: N },
  { code: "list", route: "/human-resources/employees", file: "...", line: N },
  ...
]
```

### 2. Extract PageRegistry Keys

From {registry_file}, extract all `PageRegistry.register()` calls:
```typescript
PageRegistry.register('human-resources.employees.departments', ...)
PageRegistry.register('human-resources.employees', ...)
```

Build: `{registry_keys}` = all registered page keys.

### 3. Extract Controller NavRoutes

From {controller_files}, extract `[NavRoute("...")]` attributes:
```csharp
[NavRoute("human-resources.employees")]
[NavRoute("human-resources.employees.departments")]
```

Build: `{controller_navroutes}` = all NavRoute values.

### 4. Cross-Reference

**Check A: Seed Routes → PageRegistry**
For each seed route (excluding reserved sections and /:id routes):
- Convert route to PageRegistry key: `/human-resources/employees/departments` → `human-resources.employees.departments`
- Verify key exists in {registry_keys}
- If missing → BLOCKING (seed route has no frontend page)

**Check B: Controller NavRoutes → Seed Data**
For each NavRoute:
- Convert to route path: `human-resources.employees` → `/human-resources/employees`
- Verify exists in seed data routes
- If missing → WARNING (controller exists but no navigation entry)

**Check C: PageRegistry → Page Files**
For each registry entry:
- Verify the imported component file exists on disk
- If missing → BLOCKING (registry references non-existent page)

**Check D: Orphan Pages**
For each page file in {page_files}:
- Check if it's registered in componentRegistry
- If NOT registered → WARNING (page exists but has no route — unreachable)

**Check E: DynamicRouter Convention Routes**
For each section with a list page:
- Verify these implicit routes are handled (either by registry or DynamicRouter convention):
  - `{section}/:id` → detail page
  - `{section}/create` → create page
  - `{section}/:id/edit` → edit page
- Note: DynamicRouter may resolve these by convention without explicit registry entries. Only flag if BOTH registry AND convention are missing.

### 5. Record Findings

| ID | Severity | Rule |
|----|----------|------|
| ROUTE-001 | BLOCKING | Seed data route has no matching PageRegistry entry |
| ROUTE-002 | WARNING | Controller NavRoute has no matching seed data entry |
| ROUTE-003 | BLOCKING | PageRegistry references non-existent page file |
| ROUTE-004 | WARNING | Orphan page — exists on disk but not registered (unreachable) |
| ROUTE-005 | WARNING | Implicit route (detail/create/edit) not resolvable |

---

## SUCCESS METRICS:
- All 3 sources extracted completely
- Cross-reference completed for all combinations
- Orphan detection completed
- DynamicRouter conventions accounted for

## NEXT STEP:
Proceed to `./step-05-report.md`
