Repository navigation
Add run-to-run finding diff command and correlation engine - #93
Open
sheikhlimon wants to merge 3 commits into
Open
sheikhlimon wants to merge 3 commits into
sheikhlimon wants to merge 3 commits into
Conversation
sheikhlimon
force-pushed
the
feat/run-diff
branch
from
November 26, 2026 07:46
8d567ad to
bcb9451
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When reviewing pull requests across multiple pushes, developers currently see either individual review reports or aggregate finding counts. The CLI lacked a way to correlate findings between successive runs (e.g. Run 1 vs. Run 2) to answer:
Additionally, CI jobs had no mechanism to gate strictly on fresh regressions introduced in a PR without being blocked by pre-existing technical debt or legacy findings.
Approach
Pure Correlation Engine (
src/outcome.rs):diff_findings, which partitions findings between two runs intoresolved,persistent, andregressions.finding_fingerprintidentity first, followed by composite fallback(risk_domain, claim, primary_path, start_line). Matching open findings first prevents resolved duplicates from consuming baseline matches and turning unchanged issues into false regressions.RESOLVEDfindings against remaining open baseline findings. Unmatched resolved findings are omitted from the diff (treating them as historical resolutions from older runs).curr.finding_fingerprint.is_none() || prev.finding_fingerprint.is_none()). Conflicting fingerprints are strictly never paired by location.prev_matchedso duplicate occurrences never double-consume.REINTRODUCEDfindings as regressions while marking the baseline counterpart as accounted for.Terminal & JSON Formatter (
src/render.rs):render::diff, which prints summary counts followed by severity-sorted sections (Regressions,Resolved,Persistent) with claim, location, impact, fix remediation, and ID.SerializeonFindingDifffor full--jsonsupport.CLI Subcommand & Pagination (
src/lib.rs,src/api.rs):proofline diff:proofline diff --pr <NUM>(defaults to latest recorded run vs. immediate predecessor).proofline diff --pr <NUM> --base-run <N> --target-run <M>.proofline diff --base-review <UUID> --target-review <UUID>.--fail-on-regression: exits with code 3 (Verdict::Regressed) on fresh regressions, exits with code 2 (Verdict::NotComplete) if either target or baseline review is incomplete/unfinished, and exits 0 when clean.history_page) with targeted loop termination, ensuring PRs with extensive review histories reliably resolve predecessors and explicit run IDs while filtering runs by repository UUID.Proofline Self-Review & Evaluation
I installed the Proofline GitHub App on my fork repository and ran real review runs as I iterated on this branch (the review history and bot runs are recorded on sheikhlimon-dev/cli#1):
Fallback Matching Invariant:
In my initial fallback pass, I was pairing open findings that shared the same line and claim even when both had explicit, conflicting
finding_fingerprints. That meant a new regression introduced on an existing line could get falsely labeled as "persistent" and slip past CI. Proofline caught this in Run 1, and I updatedclaim_fallback_matchso fallback only engages when at least one side lacks a fingerprint (for older server revisions).Matching Priority & Duplicate Order:
Iteration order caused duplicate issues. If a run had both a resolved duplicate and an open finding with the same fingerprint, processing the resolved one first consumed the baseline match, which turned the still-open finding into a false regression. Proofline identified this edge case, and I split matching into two sequential passes so open target findings always claim baseline matches first, leaving only leftover matches for resolved rows.
CI Completion Guard:
Proofline caught that running
proofline diff --fail-on-regressionagainst a queued or in-progress review would see an empty finding list and exit 0 before the scan finished. I added a status check to returnVerdict::NotComplete(exit code 2) unless both the target and baseline reviews are completed.Pagination Bounds vs. Exhaustion:
Proofline flagged that stopping after a fixed number of history pages could miss older requested runs. For explicit lookups (
--base-runor--target-run), I updated the loop to continue following cursors until the requested runs are found or history is exhausted. For default lookups (latest vs predecessor), I bounded the search to 10 pages (SEARCH_PAGES = 10) to prevent unbounded sequential HTTP requests from hanging on busy PRs with dozens of automated pushes.Verification & Results
src/outcome.rs,src/render.rs):tests/http.rs):diff_categorizes_findings_and_honors_fail_on_regressionusing an in-process Axum mock server.--jsonserialization with fingerprint assertions in resolved and regressions,--fail-on-regressionexit code 3, explicit run selector overrides (--base-run 1 --target-run 2and--base-run 1 --target-run 3), and direct review comparisons.cargo fmt --check: Clean.cargo clippy --all-targets -- -D warnings: 0 warnings.cargo test: 148 passed (71 unit, 41 http integration, 14 local patch, 5 mcp, 6 sarif, 10 scan, 1 update).Reproducible Steps
Run the test suite:
Test CLI diffing locally: