# Report Template Structure

Template for generating the final feature report markdown (written to `.ralph/reports/{feature-slug}.md`).

```markdown
# Feature Report: {feature}

## Summary
| Field | Value |
|-------|-------|
| Status | {status} |
| Iterations | {iterations_used} / {max} |
| Branch | {branch} |
| Duration | {totalDuration}s ({min} min) |
| Execution | Delegated to /apex |

## Tasks
| # | Task | Category | Status | Commit |
|---|------|----------|--------|--------|
{for each task:}
| {id} | {description} | {category} | {status_emoji} | {commit_hash} |

**{completed}/{total} completed, {failed} failed, {blocked} blocked**

{if moduleStats:}
## Modules
| Module | Status | Tasks | Completed | Failed | Files | Commits |
|--------|--------|-------|-----------|--------|-------|---------|
{for each mod:}
| {code} | {status} | {total} | {completed} | {failed} | {filesCreated} | {commits} |

**{completedModules}/{totalModules} modules completed**
{end if}

{if prd._sectionSplit?.enabled:}
## Section Split Execution
| Phase | Type | Section | Entities | Status |
|-------|------|---------|----------|--------|
{for each phase:}
| {phase} | {type} | {sectionCode || '-'} | {entities.length} | {status} |

{end if}

{if handoffReconciliation.totalDeclared > 0:}
## Handoff Reconciliation

### File Coverage by Category
| Category | Declared | Present | Missing | Coverage |
|----------|----------|---------|---------|----------|
{for each cat in handoffReconciliation.categories:}
| {category} | {declared} | {present} | {missing} | {coverage}% |
{end for}

**Total: {totalPresent}/{totalDeclared} ({totalHandoffCoverage}%)**

{if handoffReconciliation.missingFiles.length > 0:}
### Missing Files
{for each mf in handoffReconciliation.missingFiles:}
- **{mf.category}**: `{mf.path}`
{end for}
{end if}
{end if}

{if brReconciliation.total > 0:}
### Business Rule Coverage
| Metric | Value |
|--------|-------|
| Total Rules | {brReconciliation.total} |
| Implemented | {brReconciliation.implemented} |
| Missing | {brReconciliation.missing.length} |
| Not Tested | {brReconciliation.notTested.length} |

{if brReconciliation.missing.length > 0:}
**Missing BR implementations:**
{for each br in brReconciliation.missing:}
- `{br.id}`: {br.rule} — {br.reason}
{end for}
{end if}
{end if}

{if apiReconciliation.total > 0:}
### API Endpoint Coverage
| Metric | Value |
|--------|-------|
| Total Endpoints | {apiReconciliation.total} |
| Found | {apiReconciliation.found} |
| Missing | {apiReconciliation.missing.length} |

{if apiReconciliation.missing.length > 0:}
**Missing API endpoints:**
{for each ep in apiReconciliation.missing:}
- `{ep.method} {ep.path}` — operation: `{ep.operation}`
{end for}
{end if}
{end if}

## Build & Test Verification (Actual)

> These results come from REAL `dotnet build` and `dotnet test` execution,
> not from PRD task statuses.

| Check | Result |
|-------|--------|
| `dotnet build` | {buildStatus} |
| `dotnet test` | {testStatus} |
| MCP validate_security | {securityScan.status} |
| MCP validate_conventions | {conventionScan.status} |
| Permission semantic check | {permissionWarnings.length === 0 ? 'PASS' : `${permissionWarnings.length} issues`} |

{if stats.buildIntegrityWarning:}
> **INTEGRITY WARNING:** All tasks marked COMPLETE but the build FAILS.
> This means some generated code references types or methods that don't exist.
> Review the build output and fix before considering this feature done.
{end if}

{if permissionWarnings.length > 0:}
> **PERMISSION WARNINGS:** Write endpoints using Read permissions detected:
{for each warning:}
> - {warning}
{end for}
{end if}

## Test Metrics (PRD-based)
| Metric | Value |
|--------|-------|
| Test Tasks | {testTasks.length} |
| Passed | {testsPassed} |
| Failed | {testsFailed} |

## Failed Tasks
{table of failed tasks with error messages, or "None"}

## Files
- Created: {filesCreated.length}
- Modified: {filesModified.length}

## Commits
{unique commits list}

---
*Auto-generated by Ralph Loop — SmartStack CLI*
```
