feat: add native compiled pattern state API#116
Draft
jbachorik wants to merge 1 commit into
Draft
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new intentionally narrow “native compiled pattern” API for the named linear-token-sequence (LTS) profile in reggie-runtime, enabling span extraction without materializing inputs or touching the general compiler/cache paths.
Changes:
- Introduces new public native-compilation API types (
ReggieCompiledPattern, request/flag/result/rejection types) that only use the direct named-only LTS admission path. - Adds
ReggieMatchStateto hold per-input, single-thread-confined match state that stores only absolute spans (no retained input). - Extends
LinearTokenSequenceMatcherwith workspace reuse and named-group index helpers, plus tests validating cache non-mutation, span behavior, and parallel state usage.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| reggie-runtime/src/test/java/com/datadoghq/reggie/runtime/ReggieCompiledPatternTest.java | Adds coverage for new native compiled-pattern API behavior (admission/rejection, spans, cache invariants, parallel state). |
| reggie-runtime/src/main/java/com/datadoghq/reggie/runtime/ReggieMatchState.java | Implements single-thread-confined match state that stores spans only and exposes group span APIs. |
| reggie-runtime/src/main/java/com/datadoghq/reggie/runtime/ReggieCompileRequest.java | Adds immutable request record for the native compilation profile. |
| reggie-runtime/src/main/java/com/datadoghq/reggie/runtime/ReggieCompileFlag.java | Defines the restricted native-profile flags (NONE, DOTALL) and maps to ReggieFlags. |
| reggie-runtime/src/main/java/com/datadoghq/reggie/runtime/ReggieCompiledPattern.java | Adds entry point for native compilation and state creation. |
| reggie-runtime/src/main/java/com/datadoghq/reggie/runtime/ReggieCompilationResult.java | Adds admitted/rejected result wrapper for native compilation attempts. |
| reggie-runtime/src/main/java/com/datadoghq/reggie/runtime/ReggieCompilationRejection.java | Adds public rejection reasons for native compilation. |
| reggie-runtime/src/main/java/com/datadoghq/reggie/runtime/LinearTokenSequenceMatcher.java | Exposes workspace reuse + group helpers needed by ReggieMatchState. |
| reggie-runtime/src/main/java/com/datadoghq/reggie/ReggieFlags.java | Adds ReggieFlags.NONE constant. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+40
to
+45
| if (compilation.matcher() != null) { | ||
| return ReggieCompilationResult.admitted(new ReggieCompiledPattern(compilation.matcher())); | ||
| } | ||
| return ReggieCompilationResult.rejected( | ||
| ReggieCompilationRejection.valueOf(compilation.rejection().name())); | ||
| } |
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
Adds a deliberately narrow native compiled-pattern API for the named linear-token-sequence profile:
NONEandDOTALLnative-profile flags;String, subsequence,MatchResult, fallback matcher, or compiler-cache entry.The API invokes only the L1e direct native-admission path. Rejection remains explicit and never falls through to the general compiler or JDK fallback.
Validation
./gradlew :reggie-runtime:test --tests com.datadoghq.reggie.runtime.ReggieCompiledPatternTest --tests com.datadoghq.reggie.runtime.NamedOnlyLtsAdmissionTest./gradlew :reggie-runtime:test./gradlew spotlessApply./gradlew jacocoVerify build