Repository navigation
Description
Task
T-078a· Milestone M6 — Analysis + risk · Size S · Priority P1 · Epic #6Implements FR-DSH-007
Branch
feat/t-078a-static-report-figures-matplotlib-svg— one task = one branch = one PR (doc 32 §6)
Summary
Implement reporting/figures.py producing offline SVG figures styled with the Field Notebook tokens (colours read from a token map, not hard-coded): discovery curve, verdict scatter, SHAP bars, interaction heatmap, risk slice heatmaps with hatching for UNCERTAIN.
Context / motivation
The static report must work offline and match the dashboard's visual semantics (colour + shape, colour-blind safe).
Scope
In scope
reporting/theme.pyloading token values from a shared JSON (web/src/styles/tokens.jsongenerated or a backend copy) — single source of truth.
Implementation guidance
roboprobe/reporting/figures.py: one function per figure returning SVG text:discovery_curve_svg(points, reference_band=None),verdict_scatter_svg(runs, x, y),importance_bars_svg(report),interaction_heatmap_svg(matrix, names),risk_slice_svg(slice),volume_bar_svg(volumes).- Use
matplotlibwith theAggbackend set in-module (matplotlib.use("Agg")before pyplot import) — never at import time of other modules. - Theme (
reporting/theme.py): load colours/fonts fromweb/src/styles/tokens.jsoncopied into the package at build time (roboprobe/reporting/assets/tokens.json, produced by T-085a script) — one source of truth; CI check fails if the copy drifts. - Deterministic SVG:
rcParams["svg.hashsalt"] = "roboprobe",metadata={"Date": None, "Creator": None}; fonts as paths (svg.fonttype = "path") so offline rendering is identical. - Colour-blind safety: verdicts use colour + marker (○ PASS, ✕ FAIL, ◆ INVALID) mirroring doc 13 §1; UNCERTAIN region hatched (
hatch="//"). - Standards: respect the layering contracts (doc 16 §2) and conventions in doc 34; no hard-coded tunables — thresholds/defaults come from typed settings (doc 27); no magic numbers (ruff
PLR2004); public APIs typed (mypy strict) and documented.
Acceptance criteria
- Figures render without a display (Agg backend).
- Byte-identical SVGs for identical inputs.
- All figures accept empty data and render a labelled 'no data' placeholder.
- Token drift check in CI.
- Tests listed below added and green in CI; coverage of new code meets the gate in doc 18 §3.
- Docs, config reference and CHANGELOG
Unreleasedupdated where behaviour, keys or interfaces changed. - Definition of Done (doc 32 §3) satisfied.
Tests required
tests/unit/reporting/test_figures.py(snapshot hashes).- SHA-256 snapshot of each SVG for fixed fixture data.
Dependencies
Blocked by: #137 (T-075a)
Blocks: #140 (T-078b)
Parallelization notes
Files / paths owned by this task — avoid editing other paths; shared files (pyproject.toml entry points, cli/main.py, api/routers/__init__.py, router.tsx, docker/compose.yaml, ci.yml) are append-only:
backend/src/roboprobe/reporting/figures.pybackend/src/roboprobe/reporting/theme.pybackend/src/roboprobe/reporting/assets/tokens.json
Parallel with T-078b templates.
Definition of Done
Per doc 32 §3 and AGENTS.md §5: lint, format, mypy strict and import-linter green; tests added and passing; docs updated; PR template completed with Closes #<this issue>; Conventional Commit messages referencing T-078a (doc 16 §6); commits authored only by the repository owner identity (AGENTS.md §4); CI green; reviewer checklist (doc 32 §5.1) satisfied.
References
Design docs: doc 05 §12 · doc 13 §1.1 · doc 13 §3.9
Requirements: FR-DSH-007 (traceability: doc 28)
External:
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsBacklog
Activity
report.jsonand analysis artefacts #137roboprobe report <id> -o report.html#140