Support rules with a script node interior type.#30
Merged
scunningham merged 2 commits intomainfrom Feb 25, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for script nodes as an interior node type in the rule parsing and AST building system. Script nodes are internal nodes that process events through embedded code (currently supporting Lua), with one input node that can be a sequence, set, promql, or another script node.
Changes:
- Added
NodeTypeScriptto the schema and parser types - Implemented script node parsing with validation for language, code, and input requirements
- Created AST building logic for script nodes with proper tree traversal
- Added test cases for successful script usage and failure scenarios
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/schema/schema.go | Added NodeTypeScript constant to supported node types |
| pkg/parser/parse.go | Added ParseScriptT struct and integrated script support into ParseTermT; refactored _parse and Unmarshal functions |
| pkg/parser/tree.go | Implemented nodeFromScript function with validation logic; added IsScriptNode predicate; refactored buildChildren for cleaner code structure |
| pkg/testdata/rules.go | Added test cases for script nodes (root-level failure, missing input failure, and two success cases with nested inputs) |
| pkg/parser/parse_test.go | Added test cases for script validation and a new TestStableHashStability test |
| pkg/ast/ast_script.go | New file implementing AST building for script nodes with buildScriptChildren and buildScriptNode functions |
| pkg/ast/ast.go | Refactored node building logic to support script nodes through buildChildrenNodes and buildLeafChild; added script case in buildStateMachine |
| pkg/ast/ast_test.go | Fixed gatherNodeAddresses to properly traverse all children; added script test cases |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tonymeehan
reviewed
Feb 24, 2026
tonymeehan
approved these changes
Feb 24, 2026
tonymeehan
approved these changes
Feb 25, 2026
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.
No description provided.