Skip to content

feat(python-cli-parity): compare pull request scans with base scans - #1766

Merged
John-David Dalton (jdalton) merged 1 commit into
v1.xfrom
jdalton/surf-2230-pr-baselines
Dec 1, 2026
Merged

John-David Dalton (jdalton) merged 1 commit into
v1.xfrom
jdalton/surf-2230-pr-baselines

Conversation

@jdalton

@jdalton John-David Dalton (jdalton) commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Python CLI behavior

The Python CLI already compares a pull request scan with a selected baseline. It accepts a base scan ID or commit SHA; for a SHA, it prefers an exact scan and can fall back to the nearest scanned first-parent ancestor with a warning. Without an override, it uses a matching repository head scan when available. Python baseline selection

What this adds to Socket CLI

This PR adds automatic baseline comparison to Socket CLI's socket ci. For a pull request, it uses CI's base SHA to find the scan for the repository and target branch, then compares that scan with the PR scan through the diff-scan API. A blocking finding in a new or changed package fails the check.

Socket CLI requires an exact baseline match. If CI omits the base SHA or the base commit has no scan, the command reports what's missing and stops rather than comparing against an unrelated scan. The lookup uses the PR context from #1772. The Socket API token needs full-scans:list, diff-scans:create, and diff-scans:list.

Slides

Compare to the right scan. Socket uses the scan for the exact version of the code the pull request is based on.

Which scan does Socket use?. A pull request into main is based on commit A. A newer scan exists for commit B. main at commit A. Socket picks this scan. It matches the saved version the pull request is based on. main at commit B. This scan is newer, but it is for a different saved version of the code.

What the check does. When there is a match. Socket compares the scans. The check fails if a new or changed package has a problem your rules block. When a scan is missing. Socket says which scan it needs. Run a scan for that saved version first.

@cursor

cursor Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
New isolated CI helper with tests; no changes to existing CI handlers in this diff.

Overview
Introduces selectBaselineScan and findBaselineScan so CI can pick a baseline full scan by exact commit SHA for a given org, repo, and branch (via fetchOrgFullScanList, newest-first page of up to 100).

Fails closed when the checkout has no commit SHA or when no scan exists for that hash, with messages that tell users to scan the base commit first. Unit tests cover exact-match selection, missing SHA, and missing scan cases. .gitignore is updated so the new files stay tracked.

Reviewed by Cursor Bugbot for commit 78a47bb. Configure here.

@jdalton
John-David Dalton (jdalton) enabled stacked auto-merge (squash) November 25, 2026 18:43

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 78a47bb. Configure here.

@jdalton John-David Dalton (jdalton) changed the title feat(ci): select exact PR scan baselines feat(python-cli-parity): select PR scan baselines Nov 25, 2026
@jdalton John-David Dalton (jdalton) changed the title feat(python-cli-parity): select PR scan baselines feat(python-cli-parity): compare PR scans with base scans Nov 25, 2026
@jdalton John-David Dalton (jdalton) changed the title feat(python-cli-parity): compare PR scans with base scans feat(python-cli-parity): compare pull request scans with base scans Nov 25, 2026
@jdalton
John-David Dalton (jdalton) changed the base branch from v1.x to jdalton/surf-2240-ci-pr-context-stack November 25, 2026 22:49
@jdalton
John-David Dalton (jdalton) force-pushed the jdalton/surf-2230-pr-baselines branch 2 times, most recently from 8dfdee2 to 0a38ea8 Compare November 30, 2026 23:03
@jdalton
John-David Dalton (jdalton) force-pushed the jdalton/surf-2230-pr-baselines branch 2 times, most recently from 06c8d05 to 67c11c7 Compare December 1, 2026 16:50
Base automatically changed from jdalton/surf-2240-ci-pr-context-stack to v1.x December 1, 2026 16:56
@jdalton
John-David Dalton (jdalton) force-pushed the jdalton/surf-2230-pr-baselines branch 12 times, most recently from 2d52a82 to f0cccb6 Compare December 1, 2026 18:22
Allow the Windows Python shim test more time.
@jdalton
John-David Dalton (jdalton) merged commit 6ceeeb2 into v1.x Dec 1, 2026
10 checks passed
@jdalton
John-David Dalton (jdalton) deleted the jdalton/surf-2230-pr-baselines branch December 1, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants