rust-guard: remove per-item secrecy Vec clones in PR/issue labeling#6641
Merged
Conversation
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
Contributor
There was a problem hiding this comment.
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
SharedLabelsonce 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
This was referenced May 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
label_response_itemswas still deep-cloning secrecy label vectors on every item forlist_pull_requestsandlist_issues, unlike other response-item arms that already useSharedLabels. This update aligns those hot paths with the shared-label pattern and removes repeated default repo-nameStringcloning inlist_issuesvia borrowedCow<str>.Shared secrecy labels in
list_pull_requestssecrecyonce per response intoSharedLabels.Arcclones (secrecy_shared.clone()) inside the loop for non-search calls.SharedLabels.Shared secrecy labels in
list_issuessecrecy.clone()withsecrecy_shared.clone()in non-search calls.Borrow default repo scope in
list_issuesrepo_full_nametoCow<'_, str>.default_repo_full_namewhen item repo metadata is absent; own only when extracted from item data.