Skip to content

Implement refusal-labels guard policy and align health specVersion with MCP Gateway v1.14.0#7700

Merged
lpcox merged 3 commits into
mainfrom
copilot/update-compliance-specification
Jun 18, 2026
Merged

Implement refusal-labels guard policy and align health specVersion with MCP Gateway v1.14.0#7700
lpcox merged 3 commits into
mainfrom
copilot/update-compliance-specification

Conversation

Copilot AI commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Compliance review found two spec-drift gaps: refusal-labels was not implemented end-to-end in guard policy handling, and /health reported an outdated gateway spec version. This PR wires refusal-labels through policy parsing/validation and integrity evaluation, and updates reported specVersion to 1.14.0.

  • Guard policy model + normalization (Go)

    • Added refusal-labels to AllowOnlyPolicy and NormalizedGuardPolicy.
    • Extended allow-only JSON parsing to accept refusal-labels as:
      • array of strings, or
      • comma/newline-delimited expression string.
    • Normalization now deduplicates refusal-labels case-insensitively (same pattern as existing label/user fields).
  • WASM policy transport validation (Go)

    • Added refusal-labels to strict allow-only key allowlist.
    • Added validation/normalization for refusal-labels in payload shaping, including expression-string expansion into normalized label arrays.
  • Effective integrity computation (Rust guard)

    • Added refusal_labels to Rust AllowOnlyPolicy input and PolicyContext.
    • Added refusal-label matching helpers and demotion logic in post-integrity adjustments.
    • Enforced precedence semantics:
      • blocked-users remains highest precedence,
      • refusal-labels demotes to none and overrides trusted-user / approval-label promotion paths.
  • Health contract alignment

    • Updated MCPGatewaySpecVersion from 1.9.0 to 1.14.0 so /health.specVersion reflects current implemented spec target.
  • Coverage updates

    • Added focused Go and Rust tests for:
      • refusal-labels parse/normalize paths,
      • strict payload acceptance/rejection,
      • precedence behavior (blocked-users > refusal-labels > approval/trusted-user promotions).
// internal/server/unified.go
const MCPGatewaySpecVersion = "1.14.0"
{
  "allow-only": {
    "repos": "public",
    "min-integrity": "approved",
    "refusal-labels": "unsafe, needs-triage\nblocked"
  }
}

GitHub Advanced Security started work on behalf of lpcox June 18, 2026 00:59 View session
GitHub Advanced Security finished work on behalf of lpcox June 18, 2026 01:01
GitHub Advanced Security started work on behalf of lpcox June 18, 2026 01:09 View session
GitHub Advanced Security finished work on behalf of lpcox June 18, 2026 01:10
Copilot AI changed the title [WIP] Update MCP Gateway compliance for refusal-labels and specVersion Implement refusal-labels guard policy and align health specVersion with MCP Gateway v1.14.0 Jun 18, 2026
Copilot finished work on behalf of lpcox June 18, 2026 01:12
Copilot AI requested a review from lpcox June 18, 2026 01:12
@lpcox lpcox marked this pull request as ready for review June 18, 2026 01:17
Copilot AI review requested due to automatic review settings June 18, 2026 01:17

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.

Pull request overview

This PR closes spec-drift gaps by adding end-to-end support for the refusal-labels allow-only policy (parsing/normalization, strict transport shaping, and Rust guard integrity evaluation) and by updating /health.specVersion to report MCP Gateway spec 1.14.0.

Changes:

  • Update /health.specVersion to 1.14.0.
  • Extend Go guard policy model + JSON parsing/normalization + strict payload shaping to include refusal-labels (array or comma/newline expression).
  • Extend Rust GitHub guard policy context and integrity post-adjustments to demote items to none when matching a configured refusal label, with precedence tests.
Show a summary per file
File Description
internal/server/unified.go Bumps reported MCPGatewaySpecVersion to 1.14.0.
internal/guard/wasm_test.go Adds strict payload transport tests covering refusal-labels success, expression normalization, and type errors.
internal/guard/wasm_payload.go Allows refusal-labels key in strict allow-only payloads and normalizes it before WASM transport.
internal/config/guard_policy.go Adds RefusalLabels to policy structs and supports JSON unmarshal from list or expression string.
internal/config/guard_policy_validation.go Normalizes/dedups refusal-labels alongside other allow-only list fields.
internal/config/guard_policy_test.go Adds unit tests for refusal-label normalization and JSON unmarshal behavior.
guards/github-guard/rust-guard/src/tools.rs Formatting-only alignment in write operation list.
guards/github-guard/rust-guard/src/lib.rs Wires refusal_labels into Rust AllowOnlyPolicy and PolicyContext used by label_agent.
guards/github-guard/rust-guard/src/labels/tool_rules.rs Formatting-only refactors in imports/tests.
guards/github-guard/rust-guard/src/labels/response_paths.rs Formatting-only refactors in match arms and control flow.
guards/github-guard/rust-guard/src/labels/response_items.rs Formatting-only refactors in match arms and control flow.
guards/github-guard/rust-guard/src/labels/mod.rs Exposes refusal-label helpers for tests and adds refusal-label precedence tests.
guards/github-guard/rust-guard/src/labels/helpers.rs Adds refusal-label matching + demotion and integrates it into the post-integrity adjustment pipeline.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 12/13 changed files
  • Comments generated: 3

Comment on lines +192 to +197
if arr, ok := raw.([]interface{}); ok {
if err := config.ValidateStringArrayField(field, arr, false); err != nil {
return nil, err
}
return arr, nil
}
let integrity = ensure_integrity_baseline(repo_full_name, integrity, ctx);

// Steps 2–4: approval-label promotion → endorsement promotion → disapproval demotion.
// Post-adjustments: refusal demotionapproval/promotion/endorsement → demotions.
let integrity = ensure_integrity_baseline(repo_full_name, integrity, ctx);

// Steps 2–4: approval-label promotion → endorsement promotion → disapproval demotion.
// Post-adjustments: refusal demotionapproval/promotion/endorsement → demotions.
@lpcox

lpcox commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

@copilot address review feedback

Copilot AI commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address review feedback

Addressed in 84ba250.

  • Trimmed whitespace for array-form refusal-labels during WASM payload normalization so labels match reliably.
  • Updated both Rust post-adjustment order comments to match actual execution order.
  • Added a Go regression test covering trimming behavior for refusal-labels array entries.

GitHub Advanced Security started work on behalf of lpcox June 18, 2026 01:27 View session
GitHub Advanced Security finished work on behalf of lpcox June 18, 2026 01:28
Copilot finished work on behalf of lpcox June 18, 2026 01:29
@lpcox lpcox merged commit 1622b92 into main Jun 18, 2026
23 checks passed
@lpcox lpcox deleted the copilot/update-compliance-specification branch June 18, 2026 01:31
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.

3 participants