Define the canonical report contract in 2.0.0b6: report schema 2.10 plus
deterministic text/Markdown/SARIF/HTML projections.
- Canonical report builder:
codeclone/report/document/builder.py:build_report_document - Canonical inventory/integrity helpers:
codeclone/report/document/inventory.py,codeclone/report/document/integrity.py - Text renderer:
codeclone/report/renderers/text.py:render_text_report_document - Markdown renderer:
codeclone/report/renderers/markdown.py:render_markdown_report_document - SARIF renderer:
codeclone/report/renderers/sarif.py:render_sarif_report_document - HTML renderer:
codeclone/report/html/assemble.py:build_html_report - Shared CLI report meta:
codeclone/surfaces/cli/report_meta.py:_build_report_meta
Canonical top-level sections:
report_schema_versionmetainventoryfindingsmetricsderivedintegrity
Canonical section roles:
meta,inventory,findings,metricsare canonical truthderivedis a deterministic projection layerintegritycarries canonicalization metadata and digest
Current canonical report-only metric families include:
healthdead_codedependenciescoverage_adoptionapi_surfacecoverage_joinoverloaded_modulessecurity_surfaces
Dependency depth facts in the canonical report now include:
avg_depthp95_depthmax_depth
These describe the internal module dependency graph. They are report facts, not user-facing config knobs.
Current finding families include:
findings.groups.clones.{functions,blocks,segments}- optional
findings.groups.clones.suppressed.* findings.groups.structural.groupsfindings.groups.dead_code.groupsfindings.groups.design.groups
Refs:
codeclone/report/document/builder.py:build_report_documentcodeclone/report/document/_common.py:_design_findings_thresholds_payloadcodeclone/report/document/_findings_groups.py:_build_clone_groupscodeclone/report/document/_findings_groups.py:_build_structural_groups
- JSON is the source of truth for report semantics.
- Markdown, text, SARIF, HTML, and MCP projections must read canonical report facts rather than recompute them.
deriveddoes not replace canonical findings/metrics.- Design findings are built once in the canonical report using
meta.analysis_thresholds.design_findings; consumers must not synthesize them post-hoc. - Coverage Join is canonical current-run truth for that run, but not baseline truth.
security_surfacesis a report-only exact inventory of security-relevant capabilities and trust-boundary code. It does not claim vulnerabilities or exploitability.- Clone groups excluded by project policy are carried only under suppressed clone buckets and do not affect active findings, health, clone gating, or suggestions.
Refs:
codeclone/report/document/builder.py:build_report_documentcodeclone/report/derived.py:_health_snapshotcodeclone/report/overview.py:materialize_report_overviewcodeclone/report/suggestions.py:generate_suggestions
- Stable ordering for groups, items, suggestions, and hotlists.
derived.suggestions[*].finding_idreferences existing canonical finding IDs.derived.hotlists.*_idsreference existing canonical finding IDs.- SARIF artifacts, rules, and locations stay index-aligned.
integrity.digestis computed from canonical sections only;derivedis excluded.
Refs:
codeclone/report/document/integrity.py:_build_integrity_payloadcodeclone/report/document/inventory.py:_build_inventory_payloadcodeclone/report/renderers/sarif.py:render_sarif_report_document
| Condition | Behavior |
|---|---|
| Missing optional UI/meta fields | Renderer falls back to empty or (none)-style display |
| Untrusted baseline | Clone novelty resolves as current-run only |
| Missing source snippet in HTML | Safe fallback snippet block |
- Canonical payload is serialized with sorted keys for digest computation.
- Inventory file registry is normalized to relative paths.
- Structural findings are normalized, deduplicated, and sorted before serialization.
Refs:
codeclone/report/document/integrity.py:_build_integrity_payloadcodeclone/report/document/inventory.py:_build_inventory_payloadcodeclone/findings/structural/detectors.py:normalize_structural_findings
tests/test_report.py::test_report_json_compact_v21_contracttests/test_report.py::test_report_json_integrity_matches_canonical_sectionstests/test_report.py::test_report_json_integrity_ignores_derived_changestests/test_report_contract_coverage.py::test_report_document_rich_invariants_and_rendererstests/test_report_contract_coverage.py::test_markdown_and_sarif_reuse_prebuilt_report_documenttests/test_report_branch_invariants.py::test_overview_and_sarif_branch_invariants
- Human-facing wording in
derivedor HTML may evolve without a schema bump. - CSS/layout changes are not part of the canonical report contract.