Skip to content

API Reference parrot_tools.s3.comparator

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_tools.s3.comparator

View source

GenericReportComparator — agnostic structural diff for S3-stored reports.

Provides two comparison modes:

  1. Generic structural JSON diff (always available).
  2. Parser-dispatch for scanner-aware comparison when scanner name is known. Currently dispatches to ScanComparator for CloudSploit; all other scanners fall back to generic diff.

Module implements Spec §3 Module 2 (FEAT-184).

Class GenericReportComparator

Structural diff engine for S3-stored report documents.

Supports two modes:

  • Generic (comparison_mode="generic"): Walks both dicts recursively and tracks keys added, removed, and changed with dotted-path notation.
  • Parser-dispatch (comparison_mode="parser_dispatch"): When scanner="cloudsploit", delegates to ScanComparator for richer, domain-aware comparison. Falls back to generic diff on any failure or for unknown scanners.
Parameter Type Default Description
max_changes int 50 Maximum number of change entries to include in the changes list. Larger diffs are truncated and the truncated flag is set to True. Defaults to 50.

Method GenericReportComparator.compare

Compare two report documents and return a structured diff.

Both inputs can be Python dicts or raw JSON bytes. Bytes are decoded via json.loads before comparison.

When scanner is "cloudsploit" and both inputs are valid CloudSploit scan results, the comparison is delegated to ScanComparator for domain-aware output. All other scanners (or any parse failure) fall back to generic structural diff.

compare(baseline: dict | bytes, current: dict | bytes, *, scanner: str | None = None) -> dict

Parameter Type Default Description
baseline dict | bytes Earlier (reference) report — dict or JSON bytes.
current dict | bytes Later report to compare against baseline.
scanner str | None None Scanner that produced the reports (e.g., "cloudsploit"). None triggers generic diff.

Returns: dict — Structured diff dict with keys: baseline_source, current_source, scanner, comparison_mode, summary, changes, truncated.

Attribute logger

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally