Skip to content

fix: align linear token sequence semantics#113

Draft
jbachorik wants to merge 1 commit into
agent/logs-reggie-l1bfrom
agent/logs-reggie-l1c
Draft

fix: align linear token sequence semantics#113
jbachorik wants to merge 1 commit into
agent/logs-reggie-l1bfrom
agent/logs-reggie-l1c

Conversation

@jbachorik

Copy link
Copy Markdown
Collaborator

Summary

  • aligns Linear Token Sequence \s and \S handling with default JDK whitespace semantics
  • makes the bracket-tail shortcut require the literal-space delimiters it recognizes
  • restricts wildcard LTS admission to globally DOTALL patterns, preserving default-dot semantics
  • adds JDK differential and adversarial regression coverage

Validation

  • `./gradlew jacocoVerify build`
  • focused LTS and categorizer tests after final cleanup
  • final implementation-plan validation and code review run independently

Stacked on #112 (which is stacked on #111).

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 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;
}
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