Repository navigation
[Repo Assist] fix(rust-guard): dedup governance_tools test array + add COMMENT_NODE_ID constant - #12960
Conversation
…_ID constant Closes #12952 - Add pub(crate) const GOVERNANCE_TOOLS test-only array in tool_rules.rs tests module, shared by three governance-scoping test functions that previously copy-pasted the same 4-element tool list. - Add field_names::COMMENT_NODE_ID constant in constants.rs and use it at the 4 production .get("commentNodeID") call sites in the discussion_comment_write and pull_request_review_write match arms, matching the existing field_names centralization convention. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
The focused refactoring is complete, consistent, and preserves existing behavior.
Pull request overview
Centralizes repeated Rust guard constants without changing behavior.
Changes:
- Adds
COMMENT_NODE_IDand uses it for production JSON lookups. - Deduplicates governance tool lists across tests.
File summaries
| File | Description |
|---|---|
labels/tool_rules.rs |
Reuses constants in label logic and tests. |
labels/constants.rs |
Defines the canonical comment node ID field name. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
🔒 mcpg Read-Only Stress — gVisorSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
No write of any kind leaked. All reads (Parts A, C) succeeded as expected.
|
🔒 mcpg Read-Only Stress — defaultSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE Notes:
|
🤖 This pull request was created by Repo Assist, an automated AI assistant.
Closes #12952
Root cause
Two small maintainability gaps in
guards/github-guard/rust-guard/src/labels/tool_rules.rs:repository_ruleset_read,custom_properties_read,custom_properties_write,create_repository_ruleset) was copy-pasted verbatim across three test functions. Adding a new governance tool would require updating all three lists, with a silent risk of missing one."commentNodeID"was duplicated across 4 production.get(...)call sites in thediscussion_comment_writeandpull_request_review_writematch arms, following none of the existingfield_namescentralization used elsewhere in the file (e.g.METHOD,IS_ERROR,FULL_NAME).Fix
const GOVERNANCE_TOOLS: [&str; 4]insidemod tests, and updated the three governance test functions (apply_tool_labels_repo_governance_tools_are_scoped,apply_tool_labels_governance_tools_are_repo_scoped,apply_tool_labels_governance_tools_are_org_and_enterprise_scoped) to reference it instead of repeating the literal array.pub const COMMENT_NODE_ID: &str = "commentNodeID";to thefield_namesmodule inconstants.rs, and replaced all 4 production.get("commentNodeID")call sites with.get(field_names::COMMENT_NODE_ID).Test-fixture JSON literals (e.g.
"commentNodeID": "DIC_..."insideserde_json::json!macros) were intentionally left as-is — those are JSON object keys in test data, not.get()calls, so replacing them would add no safety benefit.Trade-offs
None — purely internal test/production deduplication with no behavior change. Both improvements are small, low-risk, and match patterns already established elsewhere in the codebase (e.g. the
[labels, milestones, branches]dedup from 2026-09-02).Test Status
cargo build: ✅ passescargo test: ✅ 666/666 passedcargo clippy --all-targets -- -D warnings: ✅ cleancargo fmt -- --check: no diff introduced by this change (pre-existing unrelated formatting diffs exist elsewhere in the crate, e.g.backend.rs,mod.rs)Add this agentic workflow to your repo
To install this agentic workflow, run