Conversation
…rals Add `pub mod scope_names` to `labels/constants.rs` with GITHUB, USER, and GLOBAL constants, following the existing pattern of `label_constants`, `policy_integrity`, and `field_names` submodules. Replace all 15 bare scope string literals across: - `labels/constants.rs` — new submodule - `labels/helpers.rs` — project_github_label - `labels/tool_rules.rs` — 10 baseline_scope/integrity call sites - `lib.rs` — infer_scope_for_baseline, blocked override, metadata path, tests A typo (e.g. `"Github"`) in any of these locations would silently produce wrong DIFC labels with no compiler error. Using constants makes that class of bug impossible. Closes #4846 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR centralizes the Rust guard’s reserved scope tokens ("github", "user", "global") into a scope_names constants module and updates several labeling call sites to use those constants, reducing the risk of silent typos that would change DIFC labeling behavior.
Changes:
- Added
labels::constants::scope_names::{GITHUB, USER, GLOBAL}. - Replaced several hard-coded scope token literals in
lib.rs,labels/tool_rules.rs, andlabels/helpers.rswithscope_names::*. - Updated a few tests/assertions to reference
scope_names::GITHUB.
Show a summary per file
| File | Description |
|---|---|
| guards/github-guard/rust-guard/src/lib.rs | Uses scope_names for inferred baseline scope and metadata/blocked-tool scope handling. |
| guards/github-guard/rust-guard/src/labels/tool_rules.rs | Replaces hard-coded "user"/"github" baseline scope + integrity scoping with scope_names constants. |
| guards/github-guard/rust-guard/src/labels/helpers.rs | Updates project_github_label to use scope_names::GITHUB. |
| guards/github-guard/rust-guard/src/labels/constants.rs | Introduces the new scope_names module with the canonical reserved scope tokens. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 4/4 changed files
- Comments generated: 3
Comment on lines
+34
to
+36
| /// Canonical scope token strings used for baseline and integrity scoping. | ||
| /// | ||
| /// These are the three scope tokens used throughout the labeling system. |
Comment on lines
+39
to
+45
| pub mod scope_names { | ||
| /// Owner-scoped policy (GitHub-org-level resources) | ||
| pub const GITHUB: &str = "github"; | ||
| /// User-scoped policy (personal resources) | ||
| pub const USER: &str = "user"; | ||
| /// Global-scoped policy (cross-repo / no specific owner) | ||
| pub const GLOBAL: &str = "global"; |
| @@ -678,16 +678,16 @@ pub fn apply_tool_labels( | |||
| // Requires writer-level integrity to prevent low-trust agents from | |||
| // self-escalating by enabling additional tool groups. | |||
| // S = public (empty — no repository-scoped data); I = writer (global) | |||
Collaborator
|
@copilot address the review feedback |
- Clarify doc comment: scope_names holds reserved tokens only, not all scopes - Replace remaining bare "user" literals in response_items.rs, response_paths.rs, and mod.rs tests - Fix misleading comment in tool_rules.rs:680 (global -> github) Agent-Logs-Url: https://github.com/github/gh-aw-mcpg/sessions/0b9658de-7428-496f-8105-7b56860e54c0 Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Contributor
Addressed all three review findings in 52bf1c5:
|
This was referenced Apr 30, 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.
Summary
Closes #4846
Adds a
pub mod scope_namessubmodule tolabels/constants.rswith three constants —GITHUB,USER, andGLOBAL— and replaces all 15 bare scope string literals across the codebase with these constants.Root Cause
Scope tokens (
"github","user","global") were used as bare string literals in 15 places acrosslib.rs,labels/tool_rules.rs, andlabels/helpers.rs. A typo (e.g."Github") in any of these would silently produce wrong DIFC labels with no compiler error.Fix
All 15 call sites replaced:
labels/helpers.rs—project_github_labellabels/tool_rules.rs— 10baseline_scope/integritycall siteslib.rs—infer_scope_for_baseline, blocked override path, metadata path, 2 test assertionsTrade-offs
label_constants,policy_integrity, andfield_namessubmodule pattern — no new convention introducedgrep scope_names::finds every usageTest Status
✅ Rust tests: 345/345 passed (
cargo test)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.