Conversation
…ODE constant - Compute secrecy, token, and scope_kind_str before constructing PolicyContext so that scopes can be moved directly (no clone needed) - Add DIFC_MODE constant at top of lib.rs alongside POLICY_SCOPE_ALL and POLICY_SCOPE_PUBLIC, replacing the magic string literal "filter" - Eliminates an unnecessary Vec<PolicyScopeEntry> heap allocation per label_agent call in WASM (each entry has 3 String fields) Closes #4008 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Optimizes the Rust GitHub guard’s label_agent by removing an unnecessary clone and replaces a DIFC mode magic string with a named constant.
Changes:
- Reordered
label_agentlogic to compute scope-derived values before movingscopesintoPolicyContext, eliminatingscopes.clone(). - Introduced a
DIFC_MODEconstant and used it in the output instead of a local"filter"string literal.
Show a summary per file
| File | Description |
|---|---|
| guards/github-guard/rust-guard/src/lib.rs | Removes scopes.clone() via reordering and adds DIFC_MODE constant to replace a magic string. |
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: 0
This was referenced Apr 18, 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.
Addresses the two improvements raised in #4008.
Changes
1. Eliminate
scopes.clone()inlabel_agentPolicyContextwas constructed beforesecrecy,token, andscope_kindwere computed, forcing an unnecessaryscopes.clone(). The fix reorders the computation so that scope-derived values are extracted whilescopesis still owned, thenscopesis moved directly intoctx.PolicyScopeEntrycontains three heap-allocatedStringfields (scope_owner,scope_repo,scope_label). Eliminating theVec<PolicyScopeEntry>clone removes one heap allocation perlabel_agentcall — a meaningful saving in the WASM bump-allocator environment.2. Add
DIFC_MODEconstantReplaces the magic string literal
"filter"and its single-uselet difc_mode = "filter"binding with a named constantDIFC_MODEdeclared alongsidePOLICY_SCOPE_ALLandPOLICY_SCOPE_PUBLICat the top oflib.rs. This matches the existing convention and makes the value self-documenting and searchable.Test Status
All 308 Rust unit tests pass:
Go build and tests are blocked by a pre-existing infrastructure issue (
proxy.golang.orgfirewall block prevents Go 1.25.0 toolchain download) — not caused by this change.Closes #4008
Warning
The following domain was blocked by the firewall during workflow execution:
proxy.golang.orgTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.