From b617a14ccdf869b6b95d72dd923568e666fa2a5b Mon Sep 17 00:00:00 2001 From: Sokwhan Huh Date: Wed, 1 Jul 2026 14:40:39 -0700 Subject: [PATCH] Prepare for planner migration by shifting standard CEL builders to proxy the legacy runtime PiperOrigin-RevId: 941302789 --- bundle/src/main/java/dev/cel/bundle/BUILD.bazel | 1 + .../main/java/dev/cel/bundle/CelFactory.java | 16 ++++++++++++++++ .../src/main/java/dev/cel/runtime/BUILD.bazel | 1 + .../java/dev/cel/runtime/CelRuntimeFactory.java | 17 +++++++++++++++++ 4 files changed, 35 insertions(+) diff --git a/bundle/src/main/java/dev/cel/bundle/BUILD.bazel b/bundle/src/main/java/dev/cel/bundle/BUILD.bazel index 716442849..1c11bb34e 100644 --- a/bundle/src/main/java/dev/cel/bundle/BUILD.bazel +++ b/bundle/src/main/java/dev/cel/bundle/BUILD.bazel @@ -54,6 +54,7 @@ java_library( "//parser", "//runtime", "//runtime:runtime_planner_impl", + "@maven//:com_google_errorprone_error_prone_annotations", ], ) diff --git a/bundle/src/main/java/dev/cel/bundle/CelFactory.java b/bundle/src/main/java/dev/cel/bundle/CelFactory.java index ac589cfe6..79acccc93 100644 --- a/bundle/src/main/java/dev/cel/bundle/CelFactory.java +++ b/bundle/src/main/java/dev/cel/bundle/CelFactory.java @@ -14,6 +14,7 @@ package dev.cel.bundle; +import com.google.errorprone.annotations.InlineMe; import dev.cel.checker.CelCheckerLegacyImpl; import dev.cel.common.CelOptions; import dev.cel.compiler.CelCompiler; @@ -34,8 +35,23 @@ private CelFactory() {} * *

Note, the {@link CelOptions#current}, standard CEL function libraries, and linked message * evaluation are enabled by default. + * + *

Note: This standard builder currently proxies the legacy builder, which will be deprecated. + * Callers are strongly encouraged to migrate to the planner ({@link #plannerCelBuilder()}). */ + @InlineMe(replacement = "CelFactory.legacyCelBuilder()", imports = "dev.cel.bundle.CelFactory") public static CelBuilder standardCelBuilder() { + return legacyCelBuilder(); + } + + /** + * Creates a builder for configuring a legacy CEL using current parser for the parse, type-check, + * and eval of expressions. + * + *

Note: This legacy builder will be deprecated. Callers are strongly encouraged to migrate to + * the planner ({@link #plannerCelBuilder()}). + */ + public static CelBuilder legacyCelBuilder() { return CelImpl.newBuilder( CelCompilerImpl.newBuilder( CelParserImpl.newBuilder(), CelCheckerLegacyImpl.newBuilder()), diff --git a/runtime/src/main/java/dev/cel/runtime/BUILD.bazel b/runtime/src/main/java/dev/cel/runtime/BUILD.bazel index 17160e346..933758c04 100644 --- a/runtime/src/main/java/dev/cel/runtime/BUILD.bazel +++ b/runtime/src/main/java/dev/cel/runtime/BUILD.bazel @@ -922,6 +922,7 @@ java_library( ":runtime_legacy_impl", ":runtime_planner_impl", "//common:options", + "@maven//:com_google_errorprone_error_prone_annotations", ], ) diff --git a/runtime/src/main/java/dev/cel/runtime/CelRuntimeFactory.java b/runtime/src/main/java/dev/cel/runtime/CelRuntimeFactory.java index 6615b59e0..8fa40d716 100644 --- a/runtime/src/main/java/dev/cel/runtime/CelRuntimeFactory.java +++ b/runtime/src/main/java/dev/cel/runtime/CelRuntimeFactory.java @@ -14,6 +14,7 @@ package dev.cel.runtime; +import com.google.errorprone.annotations.InlineMe; import dev.cel.common.CelOptions; /** Helper class to construct new {@code CelRuntime} instances. */ @@ -24,8 +25,24 @@ public final class CelRuntimeFactory { * *

Note, the {@link CelOptions#current}, standard CEL function libraries, and linked message * evaluation are enabled by default. + * + *

Note: This standard runtime currently proxies the legacy runtime, which will be deprecated. + * Callers are strongly encouraged to migrate to the planner ({@link #plannerRuntimeBuilder()}). */ + @InlineMe( + replacement = "CelRuntimeFactory.legacyCelRuntimeBuilder()", + imports = "dev.cel.runtime.CelRuntimeFactory") public static CelRuntimeBuilder standardCelRuntimeBuilder() { + return legacyCelRuntimeBuilder(); + } + + /** + * Create a new builder for constructing a legacy {@code CelRuntime} instance. + * + *

Note: This legacy runtime will be deprecated. Callers are strongly encouraged to migrate to + * the planner ({@link #plannerRuntimeBuilder()}). + */ + public static CelRuntimeBuilder legacyCelRuntimeBuilder() { return CelRuntimeLegacyImpl.newBuilder() .setOptions(CelOptions.current().build()) // CEL-Internal-2