Skip to content

feat: add native compiled pattern state API#116

Draft
jbachorik wants to merge 1 commit into
agent/logs-reggie-l1efrom
agent/logs-reggie-l1f
Draft

feat: add native compiled pattern state API#116
jbachorik wants to merge 1 commit into
agent/logs-reggie-l1efrom
agent/logs-reggie-l1f

Conversation

@jbachorik

Copy link
Copy Markdown
Collaborator

Summary

Adds a deliberately narrow native compiled-pattern API for the named linear-token-sequence profile:

  • immutable request/result/pattern types with only NONE and DOTALL native-profile flags;
  • a per-input, single-thread-confined match state that retains spans but never the input;
  • whole-match and named-group absolute span access without creating a 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
  • final implementation-plan validation: clean
  • final independent code review: clean

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

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 ReggieMatchState to hold per-input, single-thread-confined match state that stores only absolute spans (no retained input).
  • Extends LinearTokenSequenceMatcher with 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()));
}
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