Skip to content

Remove redundant borrows from Rust guard labels - #16752

Merged
lpcox merged 2 commits into
mainfrom
copilot/rust-guard-remove-redundant-borrows
Nov 18, 2026
Merged

lpcox merged 2 commits into
mainfrom
copilot/rust-guard-remove-redundant-borrows

Conversation

@lpcox

@lpcox lpcox commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Rust guard label code produces 90 needless_borrow warnings and one test-only field_reassign_with_default warning, obscuring actionable Clippy findings.

  • Label computation: Remove redundant borrows across tool rules, backend enrichment, and response paths without changing behavior:
    apply_repo_visibility_secrecy(owner, repo, repo_id, secrecy, ctx)
  • Test setup: Initialize PolicyContext.blocked_users with struct update syntax instead of assigning after default().

@lpcox lpcox changed the title [WIP] Remove needless borrow clippy warnings in Rust guard labels Remove redundant borrows from Rust guard labels Nov 18, 2026
@lpcox
lpcox marked this pull request as ready for review November 18, 2026 15:32
Copilot AI adaptive review requested due to automatic review settings November 18, 2026 15:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The review reports no active issues, and the changes are limited to redundant-borrow cleanup and a test initializer simplification.

No open issues 🎉

What changed in this PR

This PR removes redundant Rust borrows from GitHub guard label computation and updates one test initializer to use struct update syntax, reducing Clippy warning noise without changing behavior.

Changes:

  • Removes unnecessary borrows across repository, issue, pull request, governance, and response label helpers.
  • Passes extracted issue references directly to author-association lookup.
  • Initializes PolicyContext.blocked_users directly in the affected test.
File Description
guards/​github-guard/​rust-guard/​src/​labels/​tool_rules.rs Removes redundant borrows throughout repository, issue, pull request, governance, and content label computation.
guards/​github-guard/​rust-guard/​src/​labels/​response_paths.rs Removes an unnecessary borrow when computing project-item integrity labels.
guards/​github-guard/​rust-guard/​src/​labels/​mod.rs Uses struct update syntax to initialize blocked_users in the test policy context.
guards/​github-guard/​rust-guard/​src/​labels/​backend.rs Passes the extracted issue reference directly to author-association lookup.

Review effort: Lite (adaptive)

@github-actions

Copy link
Copy Markdown
Contributor

🔒 mcpg Read-Only Stress — default

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: default (normal container isolation)

Part Surface Op Result Expected Status
A MCP reads (list_issues, list_pull_requests, get_file_contents, list_commits) data returned ALLOWED ✅
B MCP writes (add_issue_comment, star_repository, issue_write, create_branch, create_or_update_file, create_pull_request) all 7 absent from the 23-tool catalog ("unknown tool"), 0/7 leaked BLOCKED ⚠️
C CLI reads (github list_issues/list_pull_requests/get_file_contents/list_commits) data returned ALLOWED ✅
D CLI REST writes gh CLI not authenticated in this environment BLOCKED ⚠️
E CLI GraphQL mutations gh CLI not authenticated in this environment BLOCKED ⚠️

Overall: INCONCLUSIVE

⚠️ Part B: the backend GitHub MCP server is launched with GITHUB_READ_ONLY=1 (gh-aw framework default), so all 7 targeted write tools are entirely absent from the 23-tool catalog exposed through mcpg. Every attempt returned Error [-32602]: unknown tool "<name>", which proves backend/toolset configuration, not mcpg's own gateway-level DIFC/guard enforcement. No write leaked (0/7), but this surface structurally cannot exercise the gateway's independent blocking layer.

⚠️ Parts D/E: gh auth status reported You are not logged into any GitHub hosts — unauthenticated, so the token-scope write-blocking boundary could not be validated in this run.

No reaction, star, issue, comment, branch, file, or PR was created in any part. Result and detail logs written to /tmp/gh-aw/agent/readonly-stress-44331294261.txt and /tmp/gh-aw/agent/readonly-stress-result-44331294261.txt.

🔒 mcpg read-only stress (default AWF runtime) by Read-Only Stress: default runtime

@lpcox
lpcox merged commit 1b0f59b into main Nov 18, 2026
37 checks passed
@lpcox
lpcox deleted the copilot/rust-guard-remove-redundant-borrows branch November 18, 2026 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[rust-guard] Remove 90 needless_borrow clippy warnings in Rust guard labels code

3 participants