|
| 1 | +# PRD: FU-P12-T3-2 — Add `error_code` column to audit CSV export |
| 2 | + |
| 3 | +**Created:** 2026-02-19 |
| 4 | +**Priority:** P3 |
| 5 | +**Branch:** `codex/feature/FU-P12-T3-2-error-code-csv-export` |
| 6 | +**Status:** PLAN |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +## 1. Problem Statement |
| 11 | + |
| 12 | +`AuditLogger.export_csv()` uses a fixed CSV header list that excludes `error_code`. |
| 13 | +As a result, exported audit files silently drop a useful diagnostic field even |
| 14 | +when entries contain structured error metadata. |
| 15 | + |
| 16 | +--- |
| 17 | + |
| 18 | +## 2. Scope |
| 19 | + |
| 20 | +### In Scope |
| 21 | +- Add `error_code` to CSV export headers in `AuditLogger.export_csv()`. |
| 22 | +- Ensure rows include `error_code` values when present. |
| 23 | +- Ensure rows emit empty strings for `error_code` when absent. |
| 24 | +- Add/adjust unit tests in `tests/unit/webui/test_audit.py`. |
| 25 | + |
| 26 | +### Out of Scope |
| 27 | +- Audit schema redesign. |
| 28 | +- New export formats. |
| 29 | +- Dashboard UI changes. |
| 30 | + |
| 31 | +--- |
| 32 | + |
| 33 | +## 3. Deliverables |
| 34 | + |
| 35 | +1. CSV export update |
| 36 | +- `src/mcpbridge_wrapper/webui/audit.py` |
| 37 | +- `error_code` present in exported CSV columns. |
| 38 | + |
| 39 | +2. Test coverage |
| 40 | +- `tests/unit/webui/test_audit.py` |
| 41 | +- Assertions for both present and missing `error_code` cases. |
| 42 | + |
| 43 | +3. Validation artifact |
| 44 | +- `SPECS/INPROGRESS/FU-P12-T3-2_Validation_Report.md` |
| 45 | + |
| 46 | +--- |
| 47 | + |
| 48 | +## 4. Acceptance Criteria |
| 49 | + |
| 50 | +- [ ] CSV export includes `error_code` column. |
| 51 | +- [ ] Entries without `error_code` render empty string in that column. |
| 52 | +- [ ] Existing CSV tests still pass. |
| 53 | +- [ ] `pytest` passes. |
| 54 | +- [ ] `ruff check src/` passes. |
| 55 | +- [ ] `mypy src/` passes. |
| 56 | +- [ ] `pytest --cov` reports coverage >= 90%. |
| 57 | + |
| 58 | +--- |
| 59 | + |
| 60 | +## 5. Dependencies |
| 61 | + |
| 62 | +- P12-T3 ✅ |
| 63 | + |
| 64 | +--- |
| 65 | + |
| 66 | +## 6. Risks and Mitigations |
| 67 | + |
| 68 | +- **Risk:** Column order changes may break fragile tests or downstream CSV |
| 69 | + consumers expecting a fixed order. |
| 70 | + - **Mitigation:** Keep existing order and append `error_code` at the end to |
| 71 | + minimize disruption. |
| 72 | + |
| 73 | +--- |
| 74 | + |
| 75 | +## 7. Validation Plan |
| 76 | + |
| 77 | +1. Update export column list to include `error_code`. |
| 78 | +2. Add/adjust test fixtures and assertions for CSV header + row values. |
| 79 | +3. Run required quality gates and document results in validation report. |
| 80 | + |
| 81 | +--- |
| 82 | +**Archived:** 2026-02-19 |
| 83 | +**Verdict:** PASS |
0 commit comments