Skip to content

rust-guard: collapse duplicated repo-write match arms and add pre-emptive tool coverage#6587

Merged
lpcox merged 3 commits into
mainfrom
copilot/rust-guard-merge-match-arms
May 27, 2026
Merged

rust-guard: collapse duplicated repo-write match arms and add pre-emptive tool coverage#6587
lpcox merged 3 commits into
mainfrom
copilot/rust-guard-merge-match-arms

Conversation

Copilot AI commented May 27, 2026

Copy link
Copy Markdown
Contributor

apply_tool_labels had 12 consecutive repo-scoped write arms with identical S(repo) + writer behavior, creating avoidable duplication and making future additions error-prone. This PR consolidates those arms and adds explicit coverage for two pre-emptive write tool groups that previously had no direct tests.

  • Match-arm consolidation (repo-scoped writes)

    • Merged issue/PR writes, discussion comment write, granular issue/PR mutations, repo content writes, label/actions/workflow writes, Copilot/repo settings writes, comment edit/delete, and release management tools into a single arm.
    • Preserved grouping intent with inline category comments on tool-name clusters.
  • Pre-emptive write tool test coverage

    • Added apply_tool_labels_issue_comment_edit_delete_is_repo_scoped_write for:
      • update_issue_comment, delete_issue_comment
    • Added apply_tool_labels_release_management_is_repo_scoped_write for:
      • create_release, edit_release, delete_release
    • Both tests assert writer integrity and repo-visibility-derived secrecy behavior.
  • Behavior shape after refactor (unchanged semantics)

// === Repo-scoped write operations ===
"create_issue"
| "issue_write"
| "discussion_comment_write"
| "create_or_update_file"
| "label_write"
| "actions_run_trigger"
| "update_issue_comment"
| "create_release"
| /* ...remaining repo-scoped write tools... */ => {
    secrecy = apply_repo_visibility_secrecy(&owner, &repo, repo_id, secrecy, ctx);
    integrity = writer_integrity(repo_id, ctx);
}

Copilot AI changed the title [WIP] Merge 12 identical repo-scoped write match arms in apply_tool_labels rust-guard: collapse duplicated repo-write match arms and add pre-emptive tool coverage May 27, 2026
Copilot AI requested a review from lpcox May 27, 2026 15:11
Copilot finished work on behalf of lpcox May 27, 2026 15:11
@lpcox lpcox marked this pull request as ready for review May 27, 2026 15:20
Copilot AI review requested due to automatic review settings May 27, 2026 15:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the rust-guard tool labeling rules by consolidating many repo-scoped write tool match arms that shared identical secrecy/integrity behavior, and adds targeted tests for two pre-emptive write tool groups to ensure they get writer integrity and repo-visibility-derived secrecy handling.

Changes:

  • Collapsed multiple duplicated repo-scoped write match arms in apply_tool_labels into a single consolidated arm while preserving category grouping via inline comments.
  • Added unit tests covering repo-scoped write labeling for issue comment edit/delete and release management tools.
Show a summary per file
File Description
guards/github-guard/rust-guard/src/labels/tool_rules.rs Consolidates repo-scoped write tool labeling into one match arm and adds explicit unit tests for issue comment edit/delete and release management tool labeling.

Copilot's findings

Tip

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

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Comment thread guards/github-guard/rust-guard/src/labels/tool_rules.rs Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@lpcox lpcox merged commit 30bea4a into main May 27, 2026
16 checks passed
@lpcox lpcox deleted the copilot/rust-guard-merge-match-arms branch May 27, 2026 15: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.

[rust-guard] Rust Guard: Merge 12 identical repo-scoped write match arms in apply_tool_labels

3 participants