V2 - #31
Closed
scunningham wants to merge 1 commit into
Closed
V2#31scunningham wants to merge 1 commit into
scunningham wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a new “V2” AST parsing pipeline (using goccy/go-yaml AST), adds compiler version filtering, and refactors the compiler to operate on the new AST structures. It also updates bundled success-example YAMLs to include explicit origin: true and modernizes dependencies.
Changes:
- Added a new
pkg/astYAML parser + traversal (Walk) utilities, along with extensive unit tests. - Refactored
pkg/compilerto compile directly from parsedast.AstRuleT/ast.AstNodeinstead of the removedpkg/parser/pkg/schematypes. - Added semantic-version gating (
pkg/version) and updated YAML testdata examples to includeevent.origin.
Reviewed changes
Copilot reviewed 86 out of 87 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| go.mod | Updates Go version directive and dependencies for the new AST/parser/compiler work. |
| pkg/version/version.go | Adds compiler semantic version + constraint checking. |
| pkg/version/version_test.go | Unit tests for version constraint evaluation. |
| pkg/testdata/success_examples/41-nested.yaml | Updates nested example syntax to inline sequences/sets and include origin handling. |
| pkg/testdata/success_examples/30-negate-absolute.yaml | Adds event.origin: true to example. |
| pkg/testdata/success_examples/29-negate-slide.yaml | Adds event.origin: true to example. |
| pkg/testdata/success_examples/29-negate-slide-anchor-1.yaml | Adds event.origin: true to example. |
| pkg/testdata/success_examples/29-negate-slide-anchor-1-window.yaml | Adds event.origin: true to example. |
| pkg/testdata/success_examples/28-negate-anchor.yaml | Adds event.origin: true to example. |
| pkg/testdata/success_examples/28-negate-anchor-shorter.yaml | Adds event.origin: true to example. |
| pkg/testdata/success_examples/27-negate-window.yaml | Adds event.origin: true to example. |
| pkg/testdata/success_examples/27-negate-window-shorter.yaml | Adds event.origin: true to example. |
| pkg/testdata/success_examples/26-negate-window.yaml | Adds event.origin: true to example. |
| pkg/testdata/success_examples/25-negate-options-1x1.yaml | Adds event.origin: true to example. |
| pkg/testdata/success_examples/24-multiple-negatives.yaml | Adds event.origin: true to example. |
| pkg/testdata/success_examples/21-negative-example.yaml | Adds event.origin: true to example. |
| pkg/testdata/success_examples/20-bad-regex-example.yaml | Adds event.origin: true to example. |
| pkg/testdata/success_examples/19-bad-literal-block-example.yaml | Adds event.origin: true to example. |
| pkg/testdata/success_examples/18-jq-example.yaml | Adds event.origin: true to example. |
| pkg/testdata/success_examples/17-jq-example.yaml | Adds event.origin: true to example. |
| pkg/testdata/success_examples/16-regex-example.yaml | Adds event.origin: true to example. |
| pkg/testdata/success_examples/15-regex-example.yaml | Adds event.origin: true to example. |
| pkg/testdata/success_examples/14-string-example.yaml | Adds event.origin: true to example. |
| pkg/testdata/success_examples/13-string-example.yaml | Adds event.origin: true to example. |
| pkg/testdata/success_examples/09-sequence-negate-example.yaml | Adds event.origin: true to example. |
| pkg/testdata/success_examples/08-sequence-example-good-window.yaml | Adds event.origin: true to example. |
| pkg/testdata/success_examples/08-sequence-example-bad-window.yaml | Adds event.origin: true to example. |
| pkg/testdata/success_examples/04-set-1x1-example.yaml | Adds event.origin: true to example. |
| pkg/testdata/success_examples/03-set-negative-example.yaml | Adds event.origin: true to example. |
| pkg/testdata/success_examples/02-set-multiple-example-good-window.yaml | Adds event.origin: true to example. |
| pkg/testdata/success_examples/02-set-multiple-example-bad-window.yaml | Adds event.origin: true to example. |
| pkg/testdata/success_examples/01-set-single-example.yaml | Adds event.origin: true to example. |
| pkg/testdata/success_examples/00-rules-document-example.yaml | Removes terms indirection and adds origin: true in examples. |
| pkg/schema/schema.go | Removes old schema constants/types (now replaced by pkg/ast equivalents). |
| pkg/parser/parse.go | Removes legacy YAML parsing types/constants. |
| pkg/parser/parse_test.go | Removes legacy parser tests. |
| pkg/datasrc/parse.go | Switches YAML unmarshalling to goccy/go-yaml. |
| pkg/compiler/plugin.go | Removes legacy compiler plugin implementation tied to old AST types. |
| pkg/compiler/error.go | Centralizes compiler errors. |
| pkg/compiler/defaults.go | Introduces default plugin/runtime and noop runtime implementation. |
| pkg/compiler/compiler.go | Refactors compilation flow to parse rules via ast.ParseRules and walk AST rules. |
| pkg/compiler/compiler_log.go | Updates log matcher compilation to operate on *ast.AstMatchLeafT and handle counts by duplication. |
| pkg/compiler/compile_test.go | Adds a basic compilation test (currently more of a smoke test). |
| pkg/compiler/callbacks.go | Simplifies runtime/callback helpers and introduces a generic object assertion helper. |
| pkg/ast/walk.go | Adds depth-first rule walking with negate-context propagation. |
| pkg/ast/walk_test.go | Tests for AST walking behavior and error propagation. |
| pkg/ast/state.go | Adds parse state for stable addressing, origin counting, ranks, and node IDs. |
| pkg/ast/proto.go | Adds proto (intermediate) representation for parsing/validation before AST construction. |
| pkg/ast/proto_test.go | Unit tests for proto field validation/conversion helpers. |
| pkg/ast/parse.go | Adds top-level parsing entrypoints and error wrapping with token positions. |
| pkg/ast/parse_terms.go | Parses field terms vs child-node terms, including negate options and validation. |
| pkg/ast/parse_script.go | Parses script nodes and validates Lua via injected validator. |
| pkg/ast/parse_script_test.go | Tests script parsing, validation, and positional error reporting. |
| pkg/ast/parse_rules.go | Parses rule documents, adds compiler version constraint support and metadata-wrapped errors. |
| pkg/ast/parse_prom.go | Parses PromQL nodes with validator hooks. |
| pkg/ast/parse_prom_test.go | Tests PromQL parsing and validator error behavior. |
| pkg/ast/parse_node.go | Parses set/sequence nodes and constructs either inner nodes or leaf matchers. |
| pkg/ast/parse_node_test.go | Tests node parsing error cases and positional wrapping. |
| pkg/ast/parse_meta.go | Parses metadata with strict/tolerant behavior and minimal metadata parsing for diagnostics. |
| pkg/ast/parse_meta_test.go | Tests metadata parsing, validation, and error positions. |
| pkg/ast/parse_help.go | Helper conversions from YAML AST nodes (string/int/bool/duration/regex/jq). |
| pkg/ast/parse_help_test.go | Unit tests for YAML AST conversion helpers. |
| pkg/ast/parse_extract.go | Adds parsing/validation for extract clauses. |
| pkg/ast/parse_extract_test.go | Tests extract parsing, conflicts, duplicates, and validator behavior. |
| pkg/ast/parse_event.go | Parses event nodes including origin counting and “multiple origin” detection. |
| pkg/ast/parse_event_test.go | Tests event parsing behavior under strict/non-strict. |
| pkg/ast/parse_cre.go | Parses CRE metadata blocks and nested application definitions. |
| pkg/ast/parse_cre_test.go | Tests CRE parsing, strict-mode behavior, and error positions. |
| pkg/ast/opts.go | Adds parser options (strictness, limits, validators). |
| pkg/ast/opts_test.go | Tests parser option behavior. |
| pkg/ast/errors.go | Defines AST/parser error types and token-positioned parse error wrapper. |
| pkg/ast/errors_test.go | Unit tests for error wrappers and token position accessors. |
| pkg/ast/draw.go | Adds ASCII tree rendering for AST rules (with optional coloring/parent display). |
| pkg/ast/const.go | Centralizes parser keyword constants and defaults. |
| pkg/ast/ast_test.go | Replaces legacy AST integration tests with unit tests for new AST primitives/structs. |
| pkg/ast/ast_script.go | Removes legacy script-AST builder code tied to old parser/schema. |
| pkg/ast/ast_metrics.go | Removes legacy PromQL-AST builder code tied to old parser/schema. |
| pkg/ast/ast_machine.go | Removes legacy machine matcher AST builder code tied to old parser/schema. |
| pkg/ast/ast_log.go | Removes legacy log matcher AST builder code tied to old parser/schema. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
scunningham
force-pushed
the
v2
branch
2 times, most recently
from
May 19, 2026 15:18
78f554d to
6181792
Compare
- Remove parser phase and instead parse directly to AST - Refactor AST and data structures for simplicity and better error handling - Add more tests and test data - Add strict compiler mode - Add semantic versioning to the compiler engine and enforce version constraints in the rules
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.