Skip to content

V2 - #31

Closed
scunningham wants to merge 1 commit into
mainfrom
v2
Closed

V2#31
scunningham wants to merge 1 commit into
mainfrom
v2

Conversation

@scunningham

Copy link
Copy Markdown
Contributor

No description provided.

@scunningham
scunningham requested a review from Copilot May 19, 2026 14:23

Copilot AI left a comment

Copy link
Copy Markdown

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 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/ast YAML parser + traversal (Walk) utilities, along with extensive unit tests.
  • Refactored pkg/compiler to compile directly from parsed ast.AstRuleT/ast.AstNode instead of the removed pkg/parser/pkg/schema types.
  • Added semantic-version gating (pkg/version) and updated YAML testdata examples to include event.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.

Comment thread pkg/ast/parse_extract.go Outdated
Comment thread pkg/ast/parse_prom.go
Comment thread pkg/version/version.go Outdated
Comment thread pkg/ast/proto.go
Comment thread pkg/compiler/compile_test.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 87 out of 88 changed files in this pull request and generated 5 comments.

Comment thread pkg/ast/parse_terms.go Outdated
Comment thread pkg/ast/draw.go Outdated
Comment thread pkg/compiler/compiler_log.go
Comment thread go.mod
Comment thread pkg/ast/parse_terms.go

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 87 out of 88 changed files in this pull request and generated 5 comments.

Comment thread pkg/ast/state.go
Comment thread pkg/ast/state.go
Comment thread pkg/ast/draw.go Outdated
Comment thread pkg/ast/parse_rules.go
Comment thread pkg/compiler/compile_test.go

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 87 out of 88 changed files in this pull request and generated 8 comments.

Comment thread pkg/compiler/compiler_log.go
Comment thread pkg/compiler/compiler_log.go
Comment thread pkg/ast/parse_node.go
Comment thread pkg/ast/parse_script.go
Comment thread pkg/ast/parse_extract_test.go Outdated
Comment thread pkg/compiler/compile_test.go
Comment thread pkg/ast/walk.go Outdated
Comment thread pkg/ast/parse_node.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

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

Comment thread pkg/ast/parse_node.go Outdated
Comment thread pkg/compiler/compiler_log.go
Comment thread pkg/compiler/callbacks.go
Comment thread pkg/compiler/compile_test.go

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 87 out of 88 changed files in this pull request and generated 3 comments.

Comment thread pkg/compiler/callbacks.go
Comment thread pkg/compiler/compiler_log.go
Comment thread pkg/compiler/compile_test.go
  - 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
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.

2 participants