Skip to content

Add diff_reviews helper for run-to-run finding comparison and scope gap reporting - #122

Open
chaos666888 wants to merge 1 commit into
prooflinedev:mainfrom
chaos666888:feat/review-diff
Open

chaos666888 wants to merge 1 commit into
prooflinedev:mainfrom
chaos666888:feat/review-diff

Conversation

@chaos666888

Copy link
Copy Markdown

Who this helps

Teams running Proofline in CI/CD pipelines, release automation, or coding-agent remediation loops often need to compare two runs (for example, PR run 1 vs run 2 after a fix push, or a baseline review vs a follow-up review) to answer:

  • Which findings were newly introduced?
  • Which findings persisted (and did any escalate from WARNING to SERIOUS or change comment-gate placement)?
  • Which findings were resolved—and where is the comparison incomplete because an environment was missing, failed, or lacked check receipts?

diff_reviews(baseline, current) provides a typed, offline, zero-network helper in proofline.diff that composes cleanly with both ProoflineClient and AsyncProoflineClient (CustomerReviewDetail or ReviewOutcome).

Decisions made

  • Honor finding_fingerprint strictly (no synthetic hashes): Per the OpenAPI contract, finding_fingerprint is absent when unretained and no replacement is derived. Active findings without a retained fingerprint (or with duplicate fingerprints inside one assessment) are surfaced explicitly in uncorrelated_baseline / uncorrelated_current with a typed reason (MISSING_FINGERPRINT / DUPLICATE_FINGERPRINT) instead of guessing matches or silently dropping items.
  • Refuse false resolution across incomplete or missing scopes: Reuses proofline.outcomes completion semantics (status == "COMPLETED", receipt_recorded, COMPLETE_CHECKS, COMPLETE_LIFECYCLES, and _code_assessment). If an environment or code assessment is missing or incomplete in either run, or if a review is an audit_mode scan or ReviewOutcome(review=None), diff_reviews emits explicit ScopeGap records (MISSING_IN_BASELINE, MISSING_IN_CURRENT, INCOMPLETE_BASELINE, INCOMPLETE_CURRENT, DUPLICATE_SCOPE, AUDIT_UNCOMPARABLE, MISSING_REVIEW) and sets has_gaps=True / complete=False rather than falsely claiming findings were resolved or introduced.
  • Strict lane isolation: Environment assessments correlate only within matching environment_display_name scopes; code_assessment correlates only in the "code" lane when assessment_count == 0 and never cross-matches environment assessments.
  • Respect recorded lifecycle state: Findings already recorded with lifecycle_state == "RESOLVED" are excluded from open-finding sets.
  • Minimal surface & contract preservation: Implemented as a pure helper module (proofline/diff.py) re-exported from proofline/__init__.py without modifying proofline/_generated/, openapi.public.json, or scripts/contracts.py (including preserving the SDK's outcome-vocabulary constraints).

How it was tested

Added tests/test_diff.py covering:

  • Introduced, resolved, persisting, WARNING -> SERIOUS escalation, SERIOUS -> WARNING de-escalation, placement changes (CHECK_ONLY -> INLINE), and ignoring already-RESOLVED records.
  • Missing (None / "") and duplicate finding_fingerprint isolation into uncorrelated_baseline / uncorrelated_current.
  • Missing environments and incomplete check receipts (receipt_recorded=False) producing ScopeGap without false resolution.
  • Duplicate environment_display_name (DUPLICATE_SCOPE) and audit_mode reviews (AUDIT_UNCOMPARABLE).
  • Code-only lane (assessment_count == 0) and ReviewOutcome unwrapping (including TIMED_OUT with review=None).

Verified all repository checks locally:

  • python scripts/generate.py --check — passed
  • python scripts/contracts.py — passed (Python operation and outcome-vocabulary contracts passed.)
  • ruff check . & ruff format --check . — passed (239 files formatted)
  • mypy proofline scripts — passed (Success: no issues found in 230 source files)
  • pytest -q — passed (223 passed)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant