Skip to content

Implement diff correctness gates - #21

Merged
mt4110 merged 3 commits into
mainfrom
feat/phase221-230-diff-correctness-v1
May 15, 2026
Merged

mt4110 merged 3 commits into
mainfrom
feat/phase221-230-diff-correctness-v1

Conversation

@mt4110

@mt4110 mt4110 commented May 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Add PR diff scope with explicit base/head refs and merge-base resolution
  • Replace text-only diff parsing with NUL-safe raw/numstat collection and typed path metadata
  • Add diff correctness findings for unsafe paths, binary files, submodules, symlinks, LFS pointers, path collisions, and large diff fail-closed behavior
  • Update CI/docs/config defaults so generated code decays by default and PR scans use merge-base diffs

Validation

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace
  • git diff --check

Notes

  • Special path, binary, submodule, symlink, LFS, Unicode normalization, and large-diff fixtures are covered.
  • The existing untracked design docs zip is intentionally excluded.

Behavior Change

  • [generated_code].mode now defaults to decay rather than exclude; repos that need the previous skip semantics should pin generated_code.mode = "exclude" in policy.

@mt4110 mt4110 self-assigned this May 15, 2026
@mt4110 mt4110 added the main mainブランチ label May 15, 2026
@mt4110
mt4110 marked this pull request as ready for review May 15, 2026 05:42
Copilot AI review requested due to automatic review settings May 15, 2026 05:42

Copilot AI 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.

Pull request overview

Adds a "diff correctness" check pipeline that replaces the text-only patch parser with a NUL-safe raw/numstat collection pass plus typed file metadata (path id, file kind, path-safety flags), introduces a pr scope using merge-base(base, head)…head, switches the default generated-code mode to decay, and wires CI/docs to use the new merge-base flow with fail-closed enforce semantics.

Changes:

  • New DiffOptions, ScopeMode::Pr, DiffFileMetadata, FileKind, PathSafetyFlag, evaluate_diff_correctness (DIFF-001..010) and --head-ref CLI flag with merge-base resolution and on-demand git fetch.
  • NUL-safe parse_raw_status_z + apply_numstat_z + patch sample collector, symlink/LFS classification, case-insensitive (with NFC normalization) collision detection, and a fail-closed report when the changed-file limit is exceeded.
  • CI workflow drops the manual git reset PR materialization in favor of --scope pr with --base-ref/--head-ref, default [generated_code].mode flips from exclude to decay, and docs/config examples updated.

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
crates/patchgate-core/src/runner.rs Core diff pipeline rewrite, new diff-correctness checks, PR scope, metadata, classification
crates/patchgate-core/src/model.rs Adds DiffCorrectness check id, plugin file metadata fields, raw-path-id-aware evidence digest
crates/patchgate-core/src/lib.rs Re-exports new diff types
crates/patchgate-core/Cargo.toml + Cargo.lock Adds unicode-normalization dep
crates/patchgate-core/tests/scope_mode_boundaries.rs New PR scope + special-path/binary/submodule/symlink/LFS fixtures
crates/patchgate-core/tests/runner_integration_flow.rs Bumps expected check count from 3→4
crates/patchgate-config/src/types.rs Default generated_code.mode → decay
crates/patchgate-config/src/lib.rs Allows pr in scope.mode; default test updated
crates/patchgate-cli/src/main.rs --head-ref flag, PR base/head resolution + fetch, fail-closed report path, enforce overrides on_exceed
config/policy.toml.example Documents pr scope and decay default
docs/02_config_reference.md, docs/03_cli_reference.md, README.md Doc updates for new scope/flags/defaults
docs/patchgate-action.yml Switches workflow to --scope pr with merge-base, drops manual git reset

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/patchgate-core/src/runner.rs
Comment thread crates/patchgate-cli/src/main.rs
Comment thread crates/patchgate-cli/src/main.rs Outdated
Comment thread crates/patchgate-core/src/runner.rs
Comment thread crates/patchgate-cli/src/main.rs
Comment thread crates/patchgate-config/src/types.rs
Comment thread crates/patchgate-core/src/runner.rs

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e30d71e3da

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/patchgate-core/src/runner.rs Outdated
@mt4110

mt4110 commented May 15, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@mt4110
mt4110 merged commit 054958b into main May 15, 2026
18 checks passed
@mt4110
mt4110 deleted the feat/phase221-230-diff-correctness-v1 branch May 15, 2026 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

main mainブランチ

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants