Skip to content

Integrity filter blocks triggering PR read on public repos with auto-approved min-integrity #2776

@lpcox

Description

@lpcox

Problem

When a workflow runs on a pull_request event on a public repository, the MCP gateway's auto-default policy sets min-integrity: approved. However, the triggering PR itself typically has unapproved integrity (it hasn't been approved yet — that's usually what the workflow is trying to do). This creates a chicken-and-egg problem: the agent cannot read the PR it was triggered to review because the PR does not yet meet the minimum integrity threshold.

Observed Behavior

PR: github/gh-aw#23425
Workflow: Smoke Claude (PR review bot)
Run: https://github.com/github/gh-aw/actions/runs/23707807704
Review: github/gh-aw#23425 (review)

The review posted by the workflow contains:

🔒 Integrity filter blocked 1 item

The workflow auto-defaulted min-integrity to approved because gh-aw is a public repository:

Configured min-integrity: (not set)
min-integrity not configured — automatically setting to 'approved' for public repository

Root Cause

The integrity labeling chain works like this:

  1. Public repo → no explicit min-integrity → auto-defaults to approved
  2. Triggering PRpull_request_read calls get_pull_request_facts → gets author_association → maps to integrity level
  3. Unreviewed PR → has unapproved integrity (no approving review yet)
  4. Guard evaluates: unapproved < approvedblocked

The guard logic in tool_rules.rs correctly assigns integrity based on review state:

  • merged → merged integrity
  • Has approving review → approved integrity
  • No approving review → unapproved (or contributor-floor based on author_association)

This is correct behavior for the guard, but creates a usability problem for PR-triggered workflows on public repos.

Impact

Any PR-triggered workflow on a public repo that:

  1. Does NOT explicitly set min-integrity in its frontmatter
  2. Needs to read the triggering PR (which is almost all PR workflows)

...will have the triggering PR blocked by the auto-applied approved minimum integrity policy. This affects PR review bots, CI check workflows, and any workflow that reads PR content to generate feedback.

Proposed Fix

The fix should be in the MCP gateway (gh-aw-mcpg), specifically in the integrity filtering logic. The triggering context should receive special treatment:

Option A: Exempt the triggering PR from integrity filtering

When the guard evaluates pull_request_read for the same PR that triggered the workflow, it should bypass the min-integrity check. The rationale: the workflow was intentionally triggered by this PR event, so blocking it from reading the trigger defeats the purpose.

Implementation: The gateway already knows the triggering context via GITHUB_EVENT_NAME, GITHUB_EVENT_PATH, and the PR number from the event payload. When pull_request_read targets the same owner/repo#number as the triggering event, skip the integrity floor check.

Option B: Set triggering PR integrity to the workflow's own integrity level

Instead of exempting, set the triggering PR's integrity to match the workflow's configured min-integrity. This preserves the filtering semantics while ensuring the trigger is always readable.

Option C: Lower auto-default for PR-triggered workflows

When a workflow is triggered by pull_request, auto-default min-integrity to unapproved instead of approved. This is the simplest fix but reduces the security posture for all PR-triggered workflows on public repos.

Recommendation

Option A is recommended — it's the most targeted fix. The triggering event is the workflow's reason for existing; blocking it is always wrong regardless of integrity level. Options B and C have broader side effects.

Artifacts

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions