/home/techb158/cosmic.abdallabala.com/docs
Edit: /home/techb158/cosmic.abdallabala.com/docs/14-step-7-reporting-export.md (4158B)
# Step 7: Reporting and Export Module
## Purpose
The reporting module converts the COSMIC AI-Risk Dashboard evidence into instructor-ready and reviewer-ready exports.
This step is an implementation extension. The source project defines the need for a measurable AI risk framework, software prototype, REST API, indicators, risk analysis engine, and project-management integration. The reporting module packages that evidence so it can be submitted, reviewed, audited, or printed.
## Source-derived concepts used
| Source concept | Reporting implementation |
|---|---|
| Quantified AI project risk | Executive report and risk register export |
| Organizational, technical, and human dimensions | Governance triangle section in the report |
| ISO-style indicators | Indicator report with measurand, unit, threshold, and interpretation |
| Software prototype and REST API | Report endpoints under `/api/projects/{projectId}/reports` |
| Project-management integration | Integration report for Trello, Jira, Asana, and Microsoft Planner |
| Validation and transfer | Printable HTML report and machine-readable JSON evidence package |
## Reports implemented
| Report | Endpoint | Format |
|---|---|---|
| Executive report | `/api/projects/{projectId}/reports/executive` | JSON |
| Printable executive report | `/api/projects/{projectId}/reports/executive.html` | HTML |
| Full evidence package | `/api/projects/{projectId}/reports/full` | JSON |
| Downloadable full evidence package | `/api/projects/{projectId}/reports/full.json` | JSON file |
| Risk register | `/api/projects/{projectId}/reports/risk-register` | JSON |
| Risk register export | `/api/projects/{projectId}/reports/risk-register.csv` | CSV |
| Mitigation report | `/api/projects/{projectId}/reports/mitigations` | JSON |
| Mitigation export | `/api/projects/{projectId}/reports/mitigations.csv` | CSV |
| Deployment gate report | `/api/projects/{projectId}/reports/gate` | JSON |
| Indicator report | `/api/projects/{projectId}/reports/indicators` | JSON |
| Integration report | `/api/projects/{projectId}/reports/integrations` | JSON |
| Audit trail report | `/api/projects/{projectId}/reports/audit` | JSON |
## UI changes
The dashboard now includes a Reports tab with these actions:
1. Open executive HTML report.
2. Download full JSON evidence package.
3. Download risk register CSV.
4. Download mitigations CSV.
5. Download gate report JSON.
6. Download audit report JSON.
The header Export report JSON button now uses the full reporting package when the API is available.
## Report package coverage
The full evidence package includes:
1. Executive summary.
2. Governance triangle scores.
3. Lifecycle readiness map.
4. Risk register.
5. Mitigation workflow data.
6. Deployment gate criteria and decisions.
7. Indicator catalog.
8. Project-management integration mappings.
9. Audit trail.
## Acceptance criteria
| Check | Expected result |
|---|---|
| Executive JSON | Includes summary, dimensions, lifecycle, top risks, gate, indicators, and integration summary |
| Executive HTML | Opens as a printable report and can be saved as PDF from the browser |
| Risk CSV | Contains all project risks with normalized and residual scores |
| Mitigation CSV | Contains all mitigation actions with linked risks and evidence counts |
| Gate report | Includes current gate and persisted gate history |
| Audit report | Includes governance workflow audit events |
| Tests | `npm test` passes |
## Implementation files
| File | Role |
|---|---|
| `src/services/reportingService.js` | Builds JSON, CSV, and HTML reports |
| `server.js` | Serves report endpoints |
| `public/index.html` | Adds Reports page |
| `public/app.js` | Adds report rendering and export actions |
| `public/styles.css` | Adds report action layout |
| `tests/reporting-workflow.test.js` | Validates report service output |
## Production note
The executive HTML report is the dependency-light PDF path for the prototype. In production, the same HTML could be rendered to PDF by a server-side HTML-to-PDF service. The prototype avoids that dependency so the application remains runnable with native Node.js only.