---
name: step-03-report
description: Generate the final structured audit report with migration plan
---

# Step 3: Final Report

## MANDATORY EXECUTION RULES:
- Use ALL data collected from steps 0-2
- Follow the EXACT output structure below
- Prioritize migration steps by impact (critical > important > nice-to-have)
- Include file:line references for every finding
- Keep executive summary to 3 lines maximum

## YOUR TASK:
Generate the complete structured audit report.

---

## OUTPUT STRUCTURE:

Generate the following report EXACTLY in this format:

```markdown
---

# Audit Dynamic Routing — {project_name}

**Date**: {current_date}
**Branch**: {current_branch}
**Scope**: {scope}
**Strict mode**: {strict}

---

## Resume executif

**Score global : {X}/5 elements conformes — Statut : {OK / A corriger / Critique}**

{Line 1: Overall architecture state in one sentence}
{Line 2: Most critical finding or strength}
{Line 3: Recommended immediate action (if any)}

---

## 1. componentRegistry
**Statut** : {✅ / ⚠️ / ❌ / 🔴}
**Fichier** : {path:line or ABSENT}

{If deviation: full 5-question causal analysis (a through e)}
{If conforme: brief confirmation with notable strengths}

---

## 2. ProtectedRoute
**Statut** : {✅ / ⚠️ / ❌ / 🔴}
**Fichier** : {path:line or ABSENT}

{If deviation: full 5-question causal analysis}
{If conforme: brief confirmation}

---

## 3. DynamicRouter
**Statut** : {✅ / ⚠️ / ❌ / 🔴}
**Fichier** : {path:line or ABSENT}

{If deviation: full 5-question causal analysis}
{If conforme: brief confirmation}

---

## 4. useRouteConfig (hook de fetch)
**Statut** : {✅ / ⚠️ / ❌ / 🔴}
**Fichier** : {path:line or ABSENT}

{If deviation: full 5-question causal analysis}
{If conforme: brief confirmation}

---

## 5. API Navigation
**Statut** : {✅ / ⚠️ / ❌ / 🔴}
**Endpoint** : {method path or ABSENT}

{If deviation: full 5-question causal analysis}
{If conforme: brief confirmation}

---

## Validation MCP (baseline automatique)

{If MCP unavailable: "MCP non disponible — audit base sur l'analyse manuelle uniquement."}

{If MCP available:}

### validate_frontend_routes
| Metrique | Valeur |
|----------|--------|
| Valid | {yes/no} |
| Registry exists | {yes/no} |
| Registered keys | {N} |
| Missing keys | {N} |
| API client issues | {N} |
| Recommendations | {list} |

### validate_conventions (frontend-routes)
| Metrique | Valeur |
|----------|--------|
| Errors | {N} |
| Warnings | {N} |
| Seed data routes checked | {N} |

### Divergences MCP vs analyse manuelle
{List any differences between MCP automated results and manual analysis.
If both agree, state: "Aucune divergence — MCP et analyse manuelle sont alignes."}

---

## Anti-patterns detectes

{If none: "Aucun anti-pattern detecte."}

{If found, list ALL with file:line references:}

| # | Type | Fichier:Ligne | Severite | Description |
|---|------|--------------|----------|-------------|
| 1 | {type} | {file}:{line} | {CRITIQUE/IMPORTANT/MINEUR} | {description} |

### Detail par anti-pattern

#### AP-{n}: {title}
- **Localisation** : {file}:{line}
- **Code concerne** :
  ```tsx
  {relevant code snippet, max 5 lines}
  ```
- **Probleme** : {why this is an anti-pattern}
- **Impact** : {concrete consequence}
- **Correction** : {specific fix}

---

## Plan de migration priorise

{If no migration needed: "Aucune migration necessaire — l'architecture est conforme au pattern cible."}

{If migration needed:}

### Critique (bloquer toute PR)
{numbered list of critical fixes with file references and estimated scope}

### Important (a planifier dans le sprint)
{numbered list of important fixes}

### Nice-to-have (backlog)
{numbered list of improvements}

### Ordre de migration recommande
{If multiple fixes, specify dependency order:}
1. {First fix — prerequisite for others}
2. {Second fix — depends on #1}
3. ...

---

## Metriques

| Metrique | Valeur |
|----------|--------|
| Elements conformes | {X}/5 |
| Elements partiellement conformes | {Y}/5 |
| Elements non conformes | {Z}/5 |
| Elements absents | {W}/5 |
| Anti-patterns detectes | {count} |
| Anti-patterns critiques | {count} |
| Fichiers a modifier | {count} |
| Estimation effort migration | {Faible/Moyen/Eleve} |
| MCP baseline disponible | {Oui/Non} |
| Divergences MCP vs manuel | {count} |

---
```

---

## REPORT QUALITY RULES:

1. **Every finding has evidence** — file:line or code snippet
2. **No vague statements** — "some routes are hardcoded" -> "3 routes hardcoded in TicketListView.tsx:42, UserPage.tsx:18, AdminDashboard.tsx:7"
3. **Migration steps are actionable** — not "refactor the routing" but "Move Route definition from App.tsx:34-56 to DynamicRouter, add componentKey 'admin.dashboard' to PageRegistry"
4. **Distinguish SmartStack-specific patterns** — Some deviations from the generic pattern may be correct for SmartStack SDK architecture. Flag these as "SmartStack-specific: conforming to SDK pattern" rather than as deviations
5. **Be honest about ambiguity** — If you cannot determine whether a deviation is intentional, say "Intention ambigue" and present both interpretations

## SUCCESS METRICS:
- Report follows exact structure above
- All sections populated with data from steps 0-2
- Executive summary is exactly 3 lines
- Migration plan is prioritized and actionable
- Metrics table is complete and accurate
- Every finding has a file:line reference
