Optimize Rust guard label sharing and tool classification lookups#6846
Merged
Conversation
13 tasks
Copilot
AI
changed the title
[WIP] Optimize default secrecy hoisting in response_paths.rs
Optimize Rust guard label sharing and tool classification lookups
Jun 1, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR optimizes two Rust guard hot paths by (1) hoisting/sealing default secrecy labels into SharedLabels once per response instead of deep-cloning per item, and (2) switching tool classification lookups from linear scans to binary_search over sorted static lists.
Changes:
- Hoist
default_secrecyintoSharedLabelsin PR/issue response path labeling loops to avoid repeatedVec<String>clones. - Sort
WRITE_OPERATIONS/READ_WRITE_OPERATIONSand usebinary_search(...).is_ok()for faster tool classification. - Add regression tests to enforce sorted operation lists and verify PR/issue list item secrecy matches
default_labels.
Show a summary per file
| File | Description |
|---|---|
| guards/github-guard/rust-guard/src/tools.rs | Sorts tool operation lists, switches to binary search, and adds tests to prevent accidental unsorted regressions. |
| guards/github-guard/rust-guard/src/labels/response_paths.rs | Hoists default secrecy into SharedLabels before per-item loops and adds tests confirming list item secrecy matches default labels. |
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 Jun 2, 2026
Closed
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.
The Rust guard still deep-cloned per-response secrecy labels in the PR and issue path labeling hot paths, and tool classification still relied on linear scans over static operation lists. This change aligns both areas with the existing fast-path patterns already used elsewhere in the guard.
Shared secrecy hoisting in
response_paths.rsdefault_secrecyvalues toSharedLabelsbefore entering per-item loopsdefault_labels, avoiding repeatedVec<String>deep clones on collection responsesBinary-search classification in
tools.rsWRITE_OPERATIONSandREAD_WRITE_OPERATIONSlexicographicallycontains()withbinary_search(...).is_ok()inis_write_operationandis_read_write_operationRegression coverage
binary_searchcorrectness