Skip to content

Rust guard: share PR integrity labels and simplify visibility decoding - #17173

Merged
lpcox merged 2 commits into
mainfrom
copilot/rust-guard-improvement
Nov 23, 2026
Merged

lpcox merged 2 commits into
mainfrom
copilot/rust-guard-improvement

Conversation

@lpcox

@lpcox lpcox commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

PR status labeling rebuilt identical integrity vectors per item; PR content labeling cloned them before wrapping each in an Arc. Repository visibility decoding also used nested matches for early-return failures.

  • Shared integrity: Accept impl Into<SharedLabels> in repo_default_labels. Build integrity once per PR status/content response, clone the shared handle for items, and reuse it for defaults.
    let integrity: crate::SharedLabels = writer_integrity(&repo_full, ctx).into();
    repo_default_labels("pull-request-status", secrecy.clone(), integrity.clone())
  • Visibility decoding: Replace UTF-8 and JSON decoding matches with let...else, preserving warning messages and cached fallbacks.
  • Regression coverage: Verify allocation sharing, unchanged labels and item limits, and malformed-response fallbacks for unknown, public, and private visibility.

@lpcox lpcox changed the title [WIP] Update Rust Guard for performance improvement Rust guard: share PR integrity labels and simplify visibility decoding Nov 23, 2026
@lpcox
lpcox marked this pull request as ready for review November 23, 2026 16:16
Copilot AI adaptive review requested due to automatic review settings November 23, 2026 16:16
@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 data ALLOWED ✅
B MCP writes (reaction/star/issue/comment/branch/file/PR) all 7 target tools absent from catalog BLOCKED ⚠️
C CLI reads data ALLOWED ✅
D CLI REST writes (reaction/star/issue/comment) gh unauthenticated BLOCKED ⚠️
E CLI GraphQL mutations (addReaction/addStar/createIssue) gh unauthenticated BLOCKED ⚠️

Overall: INCONCLUSIVE

No write leaked in any part. Part B is INCONCLUSIVE because gh-aw sets GITHUB_READ_ONLY=1 for tools.github blocks, so the backend never registers write tools (add_issue_comment, star_repository, issue_write, create_branch, create_or_update_file, create_pull_request all absent from the 23-tool catalog) - this proves backend config, not mcpg's own DIFC/guard layer. Parts D/E are INCONCLUSIVE because gh is unauthenticated in this environment (gh auth status reports not logged in; a live POST attempt returned an auth error, not a permission/gateway error), so the token-scope write boundary could not be exercised.

No destructive actions, retries, or cleanup were attempted.

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

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

No active review issues block the allocation-sharing and visibility-decoding changes.

No open issues 🎉

What changed in this PR

This PR reduces repeated allocations in Rust guard pull-request labeling and simplifies repository visibility decoding while preserving existing behavior.

Changes:

  • Share integrity labels across PR status/content items and default labels.
  • Replace decoding matches with let...else, retaining warnings and cached fallbacks.
  • Add regression tests for allocation sharing, label values, item limits, and malformed-response handling.
File Description
guards/​github-guard/​rust-guard/​src/​labels/​response_paths.rs Reuses shared integrity labels and tests allocation sharing and labeling behavior.
guards/​github-guard/​rust-guard/​src/​labels/​backend.rs Simplifies decoding failure branches and tests cached visibility fallbacks.

Review effort: Balanced (adaptive)

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] Rust Guard: hoist per-item integrity build out of PR-status labeling; let-else in repo visibility lookup

3 participants