Skip to content

Commit 4a7da56

Browse files
l46kokcopybara-github
authored andcommitted
Expose the verifier's counterexamples as structured CelWitness values
PiperOrigin-RevId: 1004026905
1 parent b6a64ff commit 4a7da56

20 files changed

Lines changed: 2382 additions & 1754 deletions

‎verifier/README.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ public class PolicyVerifierExample {
224224
System.out.println(result.message());
225225
// Output:
226226
// Equivalence violation detected. Counterexample input:
227-
// country = "a"
228227
// role = "editor"
228+
// country = "a"
229229
// port = 443
230230
break;
231231
case INCONCLUSIVE:
@@ -241,7 +241,8 @@ public class PolicyVerifierExample {
241241
When checking whether an expression is satisfiable using `isSatisfiable`, the
242242
verifier returns `VERIFIED` if there exists at least one input combination
243243
where the expression evaluates to `true`. Furthermore, `result.message()`
244-
provides concrete satisfying model assignments (witness/test case generation).
244+
provides concrete satisfying model assignments (witness/test case generation),
245+
and `result.witness()` exposes them as CEL runtime values.
245246

246247
```java
247248
import dev.cel.common.CelAbstractSyntaxTree;

‎verifier/src/main/java/dev/cel/verifier/BUILD.bazel‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ java_library(
1515
"CelVerificationResult.java",
1616
"CelVerifier.java",
1717
"CelVerifierBuilder.java",
18+
"CelWitness.java",
1819
],
1920
tags = [
2021
],
@@ -23,6 +24,7 @@ java_library(
2324
"//common:cel_ast",
2425
"//common/types:type_providers",
2526
"@maven//:com_google_errorprone_error_prone_annotations",
27+
"@maven//:com_google_guava_guava",
2628
],
2729
)
2830

@@ -112,7 +114,10 @@ java_library(
112114

113115
java_library(
114116
name = "type_system",
115-
srcs = ["CelZ3TypeSystem.java"],
117+
srcs = [
118+
"CelZ3Exprs.java",
119+
"CelZ3TypeSystem.java",
120+
],
116121
compatible_with = [],
117122
tags = [
118123
],
@@ -157,10 +162,14 @@ java_library(
157162
"CelAstAlphaHasher.java",
158163
"CelAstToZ3Translator.java",
159164
"CelVerifierZ3Impl.java",
165+
"CelZ3ComprehensionTranslator.java",
160166
"CelZ3CounterexampleGenerator.java",
161167
"CelZ3ExtensionalityAxioms.java",
162168
"CelZ3FunctionRegistry.java",
163169
"CelZ3OperatorTranslator.java",
170+
"CelZ3StructTranslator.java",
171+
"CelZ3TranslationContext.java",
172+
"CelZ3TypeConstraintGenerator.java",
164173
"TranslatedValue.java",
165174
],
166175
compatible_with = [],
@@ -179,10 +188,13 @@ java_library(
179188
"//common/ast",
180189
"//common/ast:cel_block",
181190
"//common/internal:cel_descriptor_pools",
191+
"//common/internal:proto_time_utils",
182192
"//common/internal:well_known_proto",
183193
"//common/types",
184194
"//common/types:cel_types",
185195
"//common/types:type_providers",
196+
"//common/values",
197+
"//common/values:cel_byte_string",
186198
"//optimizer",
187199
"//optimizer:optimization_exception",
188200
"//optimizer:optimizer_builder",

0 commit comments

Comments
 (0)