Skip to content

rust-guard: remove per-item secrecy Vec clones in PR/issue labeling#6641

Merged
lpcox merged 3 commits into
mainfrom
copilot/rust-guard-apply-sharedlabels
May 28, 2026
Merged

rust-guard: remove per-item secrecy Vec clones in PR/issue labeling#6641
lpcox merged 3 commits into
mainfrom
copilot/rust-guard-apply-sharedlabels

Conversation

Copilot AI commented May 28, 2026

Copy link
Copy Markdown
Contributor

label_response_items was still deep-cloning secrecy label vectors on every item for list_pull_requests and list_issues, unlike other response-item arms that already use SharedLabels. This update aligns those hot paths with the shared-label pattern and removes repeated default repo-name String cloning in list_issues via borrowed Cow<str>.

  • Shared secrecy labels in list_pull_requests

    • Hoist secrecy once per response into SharedLabels.
    • Use cheap Arc clones (secrecy_shared.clone()) inside the loop for non-search calls.
    • Keep search behavior unchanged by converting per-repo secrecy directly into SharedLabels.
  • Shared secrecy labels in list_issues

    • Apply the same hoist-and-share pattern as PRs.
    • Replace per-item secrecy.clone() with secrecy_shared.clone() in non-search calls.
  • Borrow default repo scope in list_issues

    • Switch per-item repo_full_name to Cow<'_, str>.
    • Borrow default_repo_full_name when item repo metadata is absent; own only when extracted from item data.
let secrecy_shared: SharedLabels = secrecy.into();

secrecy: if tool_name == "search_issues" {
    repo_visibility_secrecy_for_repo_id(&repo_full_name, ctx).into()
} else {
    secrecy_shared.clone()
},

Copilot AI changed the title [WIP] Update Rust Guard to apply SharedLabels to secrecy rust-guard: remove per-item secrecy Vec clones in PR/issue labeling May 28, 2026
Copilot finished work on behalf of lpcox May 28, 2026 16:14
Copilot AI requested a review from lpcox May 28, 2026 16:14
@lpcox lpcox marked this pull request as ready for review May 28, 2026 16:16
Copilot AI review requested due to automatic review settings May 28, 2026 16:16

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 optimizes Rust guard response-item labeling for pull requests and issues by avoiding repeated deep clones of secrecy labels in per-item loops.

Changes:

  • Converts per-response secrecy vectors into SharedLabels once and reuses cheap clones for PR and issue item labeling.
  • Uses Cow<str> in issue labeling to borrow the default repo scope when item repo metadata is absent.
  • Adds tests asserting GraphQL PR/issue responses without embedded repo metadata fall back to tool argument repo scope.
Show a summary per file
File Description
guards/github-guard/rust-guard/src/labels/response_items.rs Refactors PR/issue secrecy label reuse and issue repo-name fallback allocation behavior.
guards/github-guard/rust-guard/src/labels/mod.rs Adds assertions covering fallback descriptions for GraphQL PR and issue response labeling.

Copilot's findings

Tip

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

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@lpcox lpcox merged commit 19a5fd4 into main May 28, 2026
29 checks passed
@lpcox lpcox deleted the copilot/rust-guard-apply-sharedlabels branch May 28, 2026 16:20
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: Apply SharedLabels to secrecy in list_pull_requests and list_issues response_items arms

3 participants