{{ message }}
refactor(rust-guard): extract resolve_integrity_level helper + add promotion/demotion label tests#8506
Merged
Conversation
…omotion/demotion label tests - Extract shared parse-and-warn logic into resolve_integrity_level() so effective_disapproval_integrity and effective_endorser_min_integrity delegate to a single helper instead of duplicating 14 lines each. - Add four tests covering promotion_label and demotion_label flow through issue_integrity and pr_integrity. Closes #8485
Copilot
AI
changed the title
[WIP] Extract resolve_integrity_level helper and add tests
refactor(rust-guard): extract Jul 2, 2026
resolve_integrity_level helper + add promotion/demotion label tests
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces duplication in the Rust GitHub guard label/integrity logic by extracting a shared integrity-level parsing helper, and adds end-to-end tests to lock in the promotion/demotion label adjustment behavior within the issue_integrity / pr_integrity pipelines.
Changes:
- Extracts
resolve_integrity_levelto centralize “empty → default” and “unrecognized → warn + default” parsing for policy integrity strings. - Refactors
effective_disapproval_integrityandeffective_endorser_min_integrityto delegate to the new helper. - Adds four integration-style unit tests validating built-in
promotion_labelanddemotion_labeleffects for issues and PRs (including forked and merged PR scenarios).
Show a summary per file
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Low
The import is already brought into scope locally inside the functions that need it, making the module-level import redundant. Rust 1.96 correctly flags it as unused with -D warnings. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.

effective_disapproval_integrityandeffective_endorser_min_integrityduplicated an identical 14-line parse-and-warn body. The promotion/demotion label pipeline (apply_post_integrity_adjustments) also lacked end-to-end test coverage, meaning accidental removal of either adjustment step would go undetected.Changes
resolve_integrity_levelhelper — consolidates the shared "empty → default, unrecognised → warn + default" pattern into a single function; both callers now delegate in one line each:issue_integrity/pr_integritypipeline to verify:promotion_labelraises aNONE-association issue to writer (rank 3)demotion_labelcaps anOWNER-association issue to none (rank 1)promotion_labelraises a forked PR from reader (rank 2) to writer (rank 3)demotion_labelcaps a merged PR from merged (rank 4) to none (rank 1)