Skip to content

Refactor existing report flow to separate result building from rendering #1099

Open

Description

@andreasconrad-ruv

Current

Multiple outputs already reuse one scan. Rendering and writing also have separate helpers. This refactor tightens the existing boundaries:

  • report() formats output, but also calculates risk, partitions suppressed findings, and adjusts completeness. _render_report() repeats that processing for additional formats.
  • The scan graph and _scan_transitive() render the primary report. Primary and additional outputs therefore take different rendering paths.
  • _scan_multi_skill() still combines scanning, aggregation, rendering, and writing.

Proposed changes

Use the same flow for every output:

flowchart LR
    A["Scan skill<br/>Collect and merge analysis state"]
    B["Build scan results<br/>Determine scores, suppression,<br/>and completeness once"]
    C["Render report<br/>Format results as JSON, SARIF,<br/>Markdown, or terminal text"]
    D["Write report<br/>Write rendered content<br/>to stdout or a file"]

    A -->|"Complete<br/>scan<br/>state"| B
    B -->|"Format<br/>independent<br/>results"| C
    C -->|"Rendered<br/>content"| D
Loading
  • Keep _scan_skill() and _scan_transitive() focused on collecting and merging complete scan state.
  • Extract _build_scan_results() from report(). Build scoring, suppression, and completeness once from the complete state. Retain findings, component metadata, executable-script status, baseline information, and LLM telemetry.
  • Keep _render_report(). Render primary and additional formats from the same built results, without changing them or recalculating scan semantics.
  • Keep _scan_multi_skill() and move combined rendering into _render_multi_skill_report().
  • Rename _write_result() to _write_report(). Accept rendered content rather than scan state. Separate _render_reports() from _write_reports().
  • Centralize destination checks in _validate_report_destinations(). Preserve writer-compatible normalization, no-follow writing, duplicate detection, and input/baseline protection.

Acceptance criteria

  • Cover single, non-transitive, transitive, recursive, and multi-skill scans with local and remote inputs.
  • Multiple formats reuse one scan and the same built results.
  • Rendering does not mutate results. Format selection and report order do not change findings, scores, suppression, or completeness.
  • Extend tests/unit/test_cli_reports.py with tests for these guarantees, output selection, and byte preservation of inputs and baselines.
  • Keep existing output-selection behavior unchanged.

Scope

Implement after PR #1065 is merged, separately from its reviewer fixes. MCP registry scans are out of scope.

This is a refactor. Any change to implicit terminal output needs a separate behavior-change specification.

Activity

  1. changed the title [-]Refactor CLI scans into scan, build, render, and write stages[/-] [+]Refactor existing report flow to separate result building from rendering[/+] on Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions