fix: align linear token sequence semantics#113
Draft
jbachorik wants to merge 1 commit into
Draft
Conversation
There was a problem hiding this comment.
Pull request overview
This PR tightens and aligns the Linear Token Sequence (LTS) fast-path semantics with the intended Java/JDK regex behavior by (a) matching JDK-style whitespace for \s/\S, (b) making the bracket-tail shortcut enforce the literal-space delimiters it recognizes, and (c) preventing LTS admission of wildcard-dot patterns unless the pattern is globally DOTALL.
Changes:
- Align LTS whitespace/non-whitespace classification with JDK-style whitespace (and add JDK-differential regression coverage).
- Require literal spaces around the bracket-tail shortcut and add adversarial coverage.
- Refuse LTS routing for default-dot wildcard patterns (only allow wildcard LTS when globally DOTALL).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| reggie-runtime/src/test/java/com/datadoghq/reggie/runtime/LinearTokenSequenceMatcherTest.java | Adds JDK-differential tests for whitespace semantics, bracket-tail delimiter strictness, and DOTALL/default-dot routing. |
| reggie-runtime/src/main/java/com/datadoghq/reggie/runtime/RuntimeCompiler.java | Tightens LTS admission rules around wildcard-dot usage and DOTALL requirements. |
| reggie-runtime/src/main/java/com/datadoghq/reggie/runtime/LinearTokenSequenceMatcher.java | Updates LTS whitespace handling and enforces literal-space delimiters for the bracket-tail shortcut; adds SKIP_ANY_EXCEPT_NEWLINE execution path. |
| reggie-codegen/src/test/java/com/datadoghq/reggie/codegen/analysis/PatternCategorizerTest.java | Updates categorizer fixture to explicitly be DOTALL for bracket-tail shortcut eligibility. |
| reggie-codegen/src/main/java/com/datadoghq/reggie/codegen/analysis/PatternCategorizer.java | Splits dotall vs default-dot wildcard categorization; requires DOTALL .* for bracket-tail shortcut detection. |
| reggie-codegen/src/main/java/com/datadoghq/reggie/codegen/analysis/PatternAtom.java | Introduces ANY_STAR_EXCEPT_NEWLINE atom kind. |
| reggie-codegen/src/main/java/com/datadoghq/reggie/codegen/analysis/LinearTokenSequencePlan.java | Adds SKIP_ANY_EXCEPT_NEWLINE op kind and mapping from the new atom kind. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+582
to
+584
| private static boolean isJdkWhitespace(char ch) { | ||
| return ch == ' ' || ch == '\t' || ch == '\n' || ch == '\u000B' || ch == '\f' || ch == '\r'; | ||
| } |
Comment on lines
+818
to
+820
| if ((pattern.contains(".*") || pattern.contains(".{")) && !pattern.startsWith("(?s)")) { | ||
| return null; | ||
| } |
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.
Summary
Validation
Stacked on #112 (which is stacked on #111).