Skip to content

[T-078b] Campaign HTML report (Jinja2) + roboprobe report <id> -o report.html #140

Closed

Description

@CodewithJha

Task T-078b · Milestone M6 — Analysis + risk · Size M · Priority P1 · Epic #6

Implements FR-DSH-007 · PR-08

Branch feat/t-078b-campaign-html-report-jinja2 — one task = one branch = one PR (doc 32 §6)

Summary

Implement reporting/render.py render_campaign_report(campaign_id, uow, store) -> Path with templates in reporting/templates/: summary, cases (rules, ranges, interaction badge), risk atlas figures, importance, run appendix with manifests/hashes; print stylesheet (A4, page break per case).

Context / motivation

M6 exit criterion: HTML report for a k2d campaign. Reports embed the manifests of runs they show (doc 21 §2).

Scope

In scope

  • Self-contained HTML (inline SVG + CSS, no external fetches) — renders offline.
  • cli/report.py.

Implementation guidance

  • roboprobe/reporting/render.py: def render_campaign_report(campaign_id: UUID, uow: UnitOfWork, store: ArtifactStore, *, out: Path | None = None) -> Path (doc 05 §12).
  • Templates: reporting/templates/campaign/{base,summary,cases,atlas,importance,appendix}.html.j2; Jinja2 Environment(autoescape=select_autoescape(["html", "j2"]), undefined=StrictUndefined).
  • Content: summary (campaign config, budget, counts, discovery curve, first failure), cases (per mode: label, class mix, ranges, best rule, interaction verdict, medoid/minimal run ids with replay CLI command), risk atlas (pair slices + volumes + robustness score), importance (SHAP, interactions, CV quality, low-confidence notice), appendix (each referenced run's manifest hash + artefact SHA-256, environment manifest).
  • Self-contained: inline SVG + inline CSS from reporting/assets/report.css (generated from tokens), no <script>, no external URLs (test parses HTML and asserts no http(s):// in src/href except doc links in footer).
  • Store the rendered file as artefact kind report and return its path; the CLI roboprobe report <campaign_id> -o report.html copies it.
  • 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

  • Report for the k2d demo campaign renders offline in a browser and prints sensibly.
  • No external network references (test parses HTML).
  • StrictUndefined: a missing template variable fails the test suite, not silently renders empty.
  • Labels containing <script> are escaped (XSS test).
  • Report includes manifest hashes for every run it cites (doc 21 §2).
  • Tests listed below added and green in CI; coverage of new code meets the gate in doc 18 §3.
  • Docs, config reference and CHANGELOG Unreleased updated where behaviour, keys or interfaces changed.
  • Definition of Done (doc 32 §3) satisfied.

Tests required

  • tests/integration/reporting/test_campaign_report.py.
  • HTML structure assertions with html.parser (no extra deps).

Dependencies

Blocked by: #139 (T-078a), #88 (T-043)

Blocks: #141 (T-079), #157 (T-084a)

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/render.py
  • backend/src/roboprobe/reporting/templates/**
  • backend/src/roboprobe/cli/report.py

Independent.

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-078b (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 §3.9 · doc 21 §2 · doc 22 §1 · doc 31 §3

Requirements: FR-DSH-007 · PR-08 (traceability: doc 28)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cliCommand-line interfacearea:reportingHTML/PDF reportsmilestone:M6M6 — Analysis + riskpriority:P1Required for milestone exitsize:M1-3 daystaskChild task of a milestone epictype:featureNew functionality

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions