Skip to content

fix: add event filtering to prevent rule evaluation on irrelevant GitHub events #25

@dkargatzis

Description

@dkargatzis

Overview

Implement intelligent event filtering to prevent rule engine evaluation on irrelevant GitHub events. Currently, events like branch deletions trigger rule evaluation and post comments to closed/merged PRs, causing unnecessary processing and user confusion.

Problem Statement

  • Branch deletion events trigger rule evaluation for associated PRs
  • Closed or merged PRs receive rule violation comments
  • Events that don't require governance checks are processed unnecessarily
  • Wasted API calls and processing resources on irrelevant events

Requirements

Event Filtering Logic

  • Filter out events for closed/merged PRs unless explicitly required
  • Skip rule evaluation for branch deletion events
  • Ignore events for archived repositories
  • Filter events based on PR state (closed, merged, draft)
  • Skip processing for events that don't match rule event_types

Event Action Filtering

  • Process only relevant PR actions (opened, synchronize, reopened)
  • Skip rule evaluation for closed, locked, or converted_to_draft actions
  • Filter push events to only process when relevant to active PRs
  • Handle deployment events only for active environments

Implementation Points

  • Add event filtering in webhook handlers before event processor dispatch
  • Implement filtering logic in src/webhooks/handlers/ for each event type
  • Add PR state validation in src/event_processors/pull_request.py
  • Create event filter utility in src/core/utils/ for reusable filtering logic
  • Update event processors to check event relevance before rule evaluation

Filter Criteria

  • PR state: only process open PRs (skip closed, merged, draft unless specified)
  • Branch state: skip deleted branches and non-existent refs
  • Event action: only process actions that require rule evaluation
  • Repository state: skip archived or disabled repositories
  • Event age: optionally skip stale events beyond threshold

Implementation Notes

  • Add should_process_event() utility function for centralized filtering
  • Update webhook handlers to apply filters before dispatching to processors
  • Add configuration for filter behavior (strict vs permissive)
  • Log filtered events for debugging and monitoring
  • Maintain backward compatibility for existing event processing

Acceptance Criteria

  • Branch deletion events no longer trigger rule evaluation
  • Closed/merged PRs don't receive rule violation comments
  • Only relevant events trigger rule engine evaluation
  • Filtering logic is configurable and well-documented
  • Filtered events are logged for observability
  • No breaking changes to existing event processing for valid events
  • Performance improvement from reduced unnecessary processing

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    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