[Repo Assist] perf(rust-guard): eliminate redundant Vec deep-clones in get_file_contents and list_releases#6990
Conversation
…tents and list_releases Replace the `vec.clone().into()` pattern with `vec.into()` for SharedLabels construction in the get_file_contents and list_releases arms of label_response_paths. This continues the clean-up applied earlier to list_commits, list_pull_requests, and list_issues. The original code cloned the Vec into an Arc, then later consumed the original via a second Arc allocation. The fix builds the Arc once and uses O(1) refcount clones throughout the loop and default_labels. Also add unit tests for get_file_contents (default-branch merged integrity, non-default-branch writer integrity) and list_releases (merged integrity per item, empty secrecy for public repos), covering the security-relevant branching that was previously untested. Closes #6982 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR optimizes Rust guard response labeling by removing redundant deep clones when converting label vectors into SharedLabels (Arc-wrapped vectors), and adds unit tests to cover previously untested labeling branches for get_file_contents and list_releases.
Changes:
- Avoid deep-cloning label
Vecs by converting toSharedLabelsonce and reusing via cheapArcclones. - Apply the optimization to
get_file_contentsandlist_releasesarms inlabel_response_paths. - Add three new unit tests validating integrity/secrecy behavior for these two tool responses.
Show a summary per file
| File | Description |
|---|---|
| guards/github-guard/rust-guard/src/labels/response_paths.rs | Eliminates redundant Vec deep-clones in two labeling arms and adds targeted unit tests for integrity/secrecy branching. |
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: 1
| let merged_label = format!("{}octocat/hello", label_constants::MERGED_PREFIX); | ||
| let item_integrity = &result.labeled_paths[0].labels.integrity; |
|
@copilot address review feedback and fix failing ci check https://github.com/github/gh-aw-mcpg/actions/runs/26956017605/job/79543406045?pr=6990 |
Fixed in commit |
🤖 This PR was created by Repo Assist, an automated AI assistant.
Closes #6982
What
In
guards/github-guard/rust-guard/src/labels/response_paths.rs, two arms oflabel_response_pathsusedvec.clone().into()to create aSharedLabels(Arc<Vec<_>>), then separately moved the originalVecinto a secondSharedLabelsfordefault_labels. This allocates theVectwice — one deep clone plus one move into anArc.The fix converts the
Vecdirectly intoSharedLabelsonce (no clone), then uses O(1)Arcreference-count increments (SharedLabels::clone()) in the per-item loop and indefault_labels.This continues the clean-up applied earlier to
list_commits(2026-06-03) andlist_pull_requests/list_issues(2026-06-01), completing the pattern for all affected arms.Changes
get_file_contents: Replacesecrecy.clone().into()andfile_integrity.clone().into()with direct.into(). Updatedefault_labelsto move the already-constructedSharedLabelsinstead of re-converting the originals.list_releases: Replacedefault_secrecy.clone().into()with direct.into(). Updatedefault_labelsto movedefault_secrecy_shared.get_file_contents_default_branch_gets_merged_integrityget_file_contents_non_default_branch_gets_writer_integritylist_releases_produces_merged_integrity_per_itemTest Status
Rust tests: ✅ All 456 tests pass (
cargo testinguards/github-guard/rust-guard/)Go build: ✅
go build ./...succeedsGo tests:⚠️ Infrastructure failure —
testify@v1.11.1and OTel SDK packages are not in the local module cache and the network proxy is blocked in this environment. This is pre-existing and unrelated to the Rust changes in this PR.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