Skip to content

feat(cli): residual-diff between two branches (#5)#41

Merged
pureliture merged 2 commits into
mainfrom
claude/residual-diff
Jun 19, 2026
Merged

feat(cli): residual-diff between two branches (#5)#41
pureliture merged 2 commits into
mainfrom
claude/residual-diff

Conversation

@pureliture

Copy link
Copy Markdown
Contributor

What

Add residual-diff — the difference in residual secrets between two branches,
computed as a finding_id set diff. No PR entity, new index, or storage change.

Why

finding_id is branch/commit-stable (#12 L1), so "what this branch added/removed"
is just residual(head) − residual(base) / residual(base) − residual(head) over
the existing per-branch residual. A PR is just a branch pair, so no PR-specific
machinery is needed.

Changes

  • runtime/branch_residual.py: ResidualDiff dataclass + pure residual_diff(base, head)
    helper (added / removed sorted, unchanged_count).
  • cli/commands/scan.py: residual-diff --repo --base --head reusing
    residual_for_repo for a single consistent snapshot read; fail-closed when a
    branch has no residual (an unscanned branch is not "0 added"); dynamodb-only
    with exit 2, mirroring residual.
  • Spec: docs/workbench/specs/residual-diff/ (research-grounded self-Q&A).

Test

  • uv run pytest — 684 passed (helper added/removed/unchanged/directional;
    CLI diff, missing-branch exit 2, jsonl exit 2).
  • governance.public_safety clean.

Related to #23 follow-on residual work.

…#5)

Compute the per-branch residual difference as a finding_id set diff (finding_id
is branch/commit-stable, #12 L1), so "what this branch added/removed" needs no
PR entity, new index, or storage change.

- branch_residual: ResidualDiff dataclass + pure residual_diff(base, head) helper
  (added = head − base, removed = base − head, unchanged_count = |base ∩ head|).
- scan.py: `residual-diff --repo --base --head` subcommand reusing
  residual_for_repo (single snapshot read); fail-closed when a branch has no
  residual (unscanned ≠ "0 added"); dynamodb-only, exit 2 guard like `residual`.

Spec: docs/workbench/specs/residual-diff/ (research-grounded self-Q&A).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces the residual-diff subcommand and helper functions to compute and display the difference in residual findings (added, removed, and unchanged secrets) between two branches of a repository. It includes design specifications, domain models, CLI integration, and comprehensive tests. The review feedback suggests deduplicating the missing branches list in the error message when both --base and --head refer to the same missing branch.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/security_scanner/cli/commands/scan.py Outdated
When --base and --head are the same missing branch, report it once instead of
twice (dict.fromkeys dedupe).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@pureliture pureliture merged commit 89d9b5a into main Jun 19, 2026
9 checks passed
@pureliture pureliture deleted the claude/residual-diff branch June 19, 2026 08:36
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