Skip to content

Conversation

@scunningham
Copy link
Contributor

No description provided.

Copy link

Copilot AI left a comment

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 implements validation to prevent multiple origin nodes in rule definitions. An "origin" node marks the primary event source that triggers rule evaluation, and having multiple origin nodes would create ambiguous evaluation semantics.

Key Changes:

  • Changed origin tracking from boolean to counter to detect multiple origins
  • Added validation to reject rules with more than one origin node
  • Removed redundant origin tracking from PromQL node processing
  • Added test case for the multiple origin error scenario

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
pkg/ast/ast.go Replaced HasOrigin boolean with OriginCnt integer counter, added validation logic to check for multiple origins, and added ErrMultipleOrigin error
pkg/ast/ast_metrics.go Removed redundant origin tracking code from buildPromQLNode that was duplicating the tracking done elsewhere
pkg/ast/ast_test.go Added Fail_MultipleOrigin test case to verify the new validation catches multiple origin nodes
pkg/testdata/rules.go Added TestFailMultipleOrigin test data with two origin nodes to validate the error detection

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

@scunningham scunningham merged commit eb73b7e into main Jan 7, 2026
7 checks passed
@scunningham scunningham deleted the multiple_origin branch January 7, 2026 15:22
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