Skip to content

credencestack.reports

The one report engine. Every report (a run's evidence report with its six-pillar sections, the report inside a redacted export, the benchmark report, and from Forge the brittleness report and the generated-scenario section) is a Report built from the same blocks and rendered by the same templates, as a self-contained HTML page and as Markdown.

Responsibilities

  • The data model (model): a title block (kind, id, date, version, signature status), summary metric tiles, sections of blocks (paragraphs, bullets, tables, finding chips, collapsible groups, charts, <!-- WRITE: … --> markers), methods, limitations and the disclaimer.
  • Rendering (render.render_html, render.render_markdown): one Jinja template set under reports/templates/ (page.html.j2, components.html.j2, report.css.j2); Markdown walks the same tree.
  • Design tokens (tokens.json, read by render.tokens): colours, radii, fonts, type scale, spacing and chart series. The one source for reports, the website and the docs theme.
  • The chart style (charts): series colours, line styles, markers and bar hatches; PNGs saved without metadata.
  • Builders: evidence.evidence_report (from a run's bundle) and bench.bench_report (from a bench-<id>/).

Non-goals

  • Anything that needs a network request: HTML reports have no scripts, no external fonts, stylesheets or images, no analytics.
  • Showing confidential content: builders read only the shareable files (results.json already withholds it), never confidential/.

Public API

Name Kind Signature Purpose Errors Effects
Report model Report(kind, id, title, created, version, signature, details, metrics, …) One report. - data
render_html function render_html(report: Report) -> str The report as one self-contained HTML page. - none (pure)
render_markdown function render_markdown(report: Report) -> str The report as Markdown (same content as the HTML). - none (pure)
tokens type tokens The design tokens (colours, radii, fonts, type scale, spacing, chart series). - reads the packaged tokens.json
bench.write_report function write_report(results: Path, out: Path, *, charts: bool = True) -> list[Path] Write the charts, benchmark.md and benchmark.html into out. BenchReportError: the results directory is incomplete or matplotlib is missing. reads the bench results; writes benchmark.html, benchmark.md and charts

Tests

  • tests/integration/test_end_to_end_script.py
  • tests/unit/test_bench.py
  • tests/unit/test_brittleness.py
  • tests/unit/test_reports.py

Invariants and gotchas

  • Colour never carries meaning alone: pass and finding text has a symbol (✓, !) or a word, every chart series has its own line style and marker, and every bar series its own hatch.
  • Every text/background pair listed in tokens.json is checked against WCAG AA by tests/unit/test_reports.py.
  • Numbers use credencestack._internal.fmt, shared with the console: rates 83.3%, intervals [71.2–91.0], money 12.00 USD.
  • Telemetry: with OpenTelemetry on, the compliance matrix shows each epoch's trace ID; with otel.trace_url_template (CREDENCESTACK_OTEL_TRACE_URL_TEMPLATE) set, the ID links to your platform. The report never contacts it.
  • Fonts: the stacks name the website's fonts first (Space Grotesk, Inter, JetBrains Mono) and fall back to system fonts; nothing is downloaded.