{{ message }}
[Repo Assist] refactor(rust-guard): remove PathLabelEntry, use PathLabel directly; simplify secrecy conditions#8139
Merged
lpcox merged 1 commit intoJun 26, 2026
Conversation
…simplify secrecy conditions Closes #8131 - Remove PathLabelEntry struct from response_paths.rs (was identical to crate::PathLabel) and update PathLabelResult.labeled_paths to use Vec<crate::PathLabel> directly. This eliminates the allocation+copy loop in lib.rs that converted between the two identical types. - Remove the 8-line conversion loop from label_resource in lib.rs; path_result.labeled_paths is now a zero-cost move into PathLabeledOutput. - Replace 3-way positive secrecy conditions in response_items.rs with single negative checks: 'tool_name != search_pull_requests' and 'tool_name != search_issues'. Mirrors the pattern already used in response_paths.rs and makes the intent explicit: all tools in each match arm use shared repo secrecy except the search variants. Adds a clarifying comment at each site. All 534 Rust unit tests pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the Rust GitHub guard’s response-labeling pipeline to remove a redundant path-label wrapper type and to simplify secrecy selection logic, reducing unnecessary allocations and making tool handling more future-proof.
Changes:
- Removed the redundant
PathLabelEntrytype and switchedPathLabelResult.labeled_pathsto use the canonicalcrate::PathLabeldirectly. - Eliminated the
Vec<PathLabel>“identity conversion” inlabel_responseby movingpath_result.labeled_pathsinto the output struct. - Simplified PR/issue shared-repo secrecy conditions in
response_items.rsusing a negative check (!= search_*) consistent with existing patterns.
Show a summary per file
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Low
This was referenced Jun 27, 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.

🤖 This PR was created by Repo Assist, an automated AI assistant.
Closes #8131
Problem
response_paths.rsdefinedPathLabelEntry— a struct structurally identical to thePathLabeltype already defined inlib.rs(both carrypath: Stringandlabels: ResourceLabels). Because they were separate types,label_resourceinlib.rshad to pay a needless allocation + copy loop to rename the type:Additionally, the secrecy conditions in
response_items.rsfor PRs and issues used 3-way positive match arms that enumerated every tool except the search variant, whileresponse_paths.rsalready used the simpler negative check pattern (tool_name != "search_*").Changes
labels/response_paths.rsPathLabelEntrystruct definition (it was identical tocrate::PathLabel)PathLabelResult.labeled_pathsfromVec<PathLabelEntry>toVec<crate::PathLabel>PathLabelEntry { ... }→crate::PathLabel { ... }lib.rspath_result.labeled_pathsis now a zero-cost move intoPathLabeledOutputlabels/response_items.rstool_name == "list_pull_requests" || tool_name == "pull_request_read" || tool_name == "get_pull_request"→tool_name != "search_pull_requests"(mirrorsresponse_paths.rspattern; future tool names automatically included)tool_name == "list_issues" || tool_name == "get_issue" || tool_name == "issue_read"→tool_name != "search_issues"(same motivation)Why This Matters
Performance (Task 8): Eliminates one
Vecheap allocation and copy perlabel_resourceresponse — the loop iterated every labeled path and cloned field values into a newVec<PathLabel>. The new code is a single zero-cost ownership transfer.Correctness/Maintainability (Task 3): The 3-way positive conditions were inconsistent with the already-established negative-check pattern in
response_paths.rs. More importantly, adding a new tool name to the outermatcharm (e.g.,get_pull_request_v2) would silently fall through tovec![]secrecy — the negative-check pattern fixes this by defaulting to shared-repo secrecy for any non-search tool.Test Status
cargo test— all 534 Rust unit tests passproxy.golang.orgforbidden in sandbox — infrastructure limitation, unrelated to these changes which are Rust-only)Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
proxy.golang.orgSee Network Configuration for more information.
Add this agentic workflows to your repo
To install this agentic workflow, run