|  | 
|  | 1 | +// Copyright 2025 Google LLC | 
|  | 2 | +// | 
|  | 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 4 | +// you may not use this file except in compliance with the License. | 
|  | 5 | +// You may obtain a copy of the License at | 
|  | 6 | +// | 
|  | 7 | +//     http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 8 | +// | 
|  | 9 | +// Unless required by applicable law or agreed to in writing, software | 
|  | 10 | +// distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 12 | +// See the License for the specific language governing permissions and | 
|  | 13 | +// limitations under the License. | 
|  | 14 | + | 
|  | 15 | +syntax = "proto3"; | 
|  | 16 | + | 
|  | 17 | +package cel.expr.conformance; | 
|  | 18 | + | 
|  | 19 | +import "cel/expr/checked.proto"; | 
|  | 20 | +import "google/protobuf/struct.proto"; | 
|  | 21 | +import "google/protobuf/descriptor.proto"; | 
|  | 22 | + | 
|  | 23 | +option cc_enable_arenas = true; | 
|  | 24 | +option go_package = "cel.dev/expr/conformance"; | 
|  | 25 | +option java_multiple_files = true; | 
|  | 26 | +option java_outer_classname = "EnvironmentProto"; | 
|  | 27 | +option java_package = "cel.dev.expr.conformance"; | 
|  | 28 | + | 
|  | 29 | +// Representation of a CEL Environment, defining what features and extensions | 
|  | 30 | +// are available for conformance testing. | 
|  | 31 | +message Environment { | 
|  | 32 | +  // Name of the environment | 
|  | 33 | +  string name = 1; | 
|  | 34 | + | 
|  | 35 | +  // Description for the current environment | 
|  | 36 | +  string description = 2; | 
|  | 37 | + | 
|  | 38 | +  // Sets the namespace (container) for the expression. | 
|  | 39 | +  // This is used to simplify resolution. | 
|  | 40 | +  // For example with container | 
|  | 41 | +  //   `google.rpc.context` | 
|  | 42 | +  //  an identifier of `google.rpc.context.AttributeContext` could be referred | 
|  | 43 | +  //  to simply as `AttributeContext` in the CEL expression. | 
|  | 44 | +  string container = 3; | 
|  | 45 | + | 
|  | 46 | +  // Import represents a type name that will be abbreviated by its simple name | 
|  | 47 | +  // making it easier to reference simple type names from packages other than | 
|  | 48 | +  // the expression container. | 
|  | 49 | +  // For ex: | 
|  | 50 | +  //   Import{name: 'google.rpc.Status'} | 
|  | 51 | +  // The above import will ensure that `google.rpc.Status` is available by the | 
|  | 52 | +  // simple name `Status` within CEL expressions. | 
|  | 53 | +  message Import { | 
|  | 54 | +    // Qualified type name which will be abbreviated | 
|  | 55 | +    string name = 1; | 
|  | 56 | +  } | 
|  | 57 | + | 
|  | 58 | +  // List of abbreviations to be added to the CEL environment | 
|  | 59 | +  repeated Import imports = 4; | 
|  | 60 | + | 
|  | 61 | +  // Set of options to subset a subsettable library | 
|  | 62 | +  LibrarySubset stdlib = 5; | 
|  | 63 | + | 
|  | 64 | +  // List of extensions to enable in the CEL environment. | 
|  | 65 | +  repeated Extension extensions = 6; | 
|  | 66 | + | 
|  | 67 | +  // ContextVariable represents a message type to be made available as a | 
|  | 68 | +  // context variable to the CEL environment. | 
|  | 69 | +  message ContextVariable { | 
|  | 70 | +    // Fully qualified type name of the context proto. | 
|  | 71 | +    string type_name = 1; | 
|  | 72 | +  } | 
|  | 73 | + | 
|  | 74 | +  // If set, adds a context declaration from a proto message. | 
|  | 75 | +  // | 
|  | 76 | +  // Context messages have all of their top-level fields available as variables | 
|  | 77 | +  // in the type checker. | 
|  | 78 | +  ContextVariable context_variable = 7; | 
|  | 79 | + | 
|  | 80 | +  // List of declarations to be configured in the CEL environment. | 
|  | 81 | +  // | 
|  | 82 | +  // Note: The CEL environment can be configured with either the | 
|  | 83 | +  // context_variable or a set of ident_decls provided as part of declarations. | 
|  | 84 | +  // Providing both will result in an error. | 
|  | 85 | +  repeated cel.expr.Decl declarations = 8; | 
|  | 86 | + | 
|  | 87 | +  // List of validators for validating the parsed ast. | 
|  | 88 | +  repeated Validator validators = 9; | 
|  | 89 | + | 
|  | 90 | +  // List of feature flags to be enabled or disabled. | 
|  | 91 | +  repeated Feature features = 10; | 
|  | 92 | + | 
|  | 93 | +  // Disables including the declarations from the standard CEL environment. | 
|  | 94 | +  // | 
|  | 95 | +  // NOTE: Do not disable the standard CEL declarations unless you are aware of | 
|  | 96 | +  // the implications and have discussed your use case on cel-discuss@ | 
|  | 97 | +  // or with the members of the cel-governance-team@ | 
|  | 98 | +  // | 
|  | 99 | +  // Deprecated: Use LibrarySubset to disable standard cel declarations instead: | 
|  | 100 | +  //   stdlib = LibrarySubset{ disable: true } | 
|  | 101 | +  bool disable_standard_cel_declarations = 11; | 
|  | 102 | + | 
|  | 103 | +  // If provided, uses the provided FileDescriptorSet to extend types available | 
|  | 104 | +  // the CEL expression. All "well-known" protobuf messages (google.protobuf.*) | 
|  | 105 | +  // are known to the CEL compiler, but all others must be provided for type | 
|  | 106 | +  // checking. | 
|  | 107 | +  google.protobuf.FileDescriptorSet message_type_extension = 12; | 
|  | 108 | + | 
|  | 109 | +  // When macro call tracking is enabled, the resulting SourceInfo in the | 
|  | 110 | +  // CheckedExpr will contain a collection of expressions representing the | 
|  | 111 | +  // function calls which were replaced by macros. | 
|  | 112 | +  // | 
|  | 113 | +  // Deprecated: Use Feature to enable macro call tracking | 
|  | 114 | +  //  Feature{ name: "cel.feature.macro_call_tracking", enabled: true } | 
|  | 115 | +  bool enable_macro_call_tracking = 13; | 
|  | 116 | +} | 
|  | 117 | + | 
|  | 118 | +// Represents a named validator with an optional map-based configuration object. | 
|  | 119 | +// Naming convention followed by validators: | 
|  | 120 | +//   <domain>.validator.<validator_name> | 
|  | 121 | +// For ex: | 
|  | 122 | +//   `cel.validator.timestamp` | 
|  | 123 | +// | 
|  | 124 | +// Note: the map-keys must directly correspond to the internal representation of | 
|  | 125 | +// the original validator, and should only use primitive scalar types as values | 
|  | 126 | +// at this time. | 
|  | 127 | +message Validator { | 
|  | 128 | +  string name = 1; | 
|  | 129 | + | 
|  | 130 | +  // Additional configurations to be included as part of the validation | 
|  | 131 | +  map<string, google.protobuf.Value> config = 2; | 
|  | 132 | +} | 
|  | 133 | + | 
|  | 134 | +// Represents a named boolean feature flag supported by CEL. | 
|  | 135 | +// Naming convention followed by features: | 
|  | 136 | +//   <domain>.feature.<feature_name> | 
|  | 137 | +// For ex: | 
|  | 138 | +//   `cel.feature.cross_type_numeric_comparisons` | 
|  | 139 | +message Feature { | 
|  | 140 | +  // Name of the feature flag. | 
|  | 141 | +  string name = 1; | 
|  | 142 | + | 
|  | 143 | +  // State of the feature flab. | 
|  | 144 | +  bool enabled = 2; | 
|  | 145 | +} | 
|  | 146 | + | 
|  | 147 | +// Extension represents a versioned extension library reference to enable in the | 
|  | 148 | +// CEL environment. | 
|  | 149 | +message Extension { | 
|  | 150 | +  // Name of the extension library. | 
|  | 151 | +  string name = 1; | 
|  | 152 | +  // Version of the extension library. | 
|  | 153 | +  string version = 2; | 
|  | 154 | +} | 
|  | 155 | + | 
|  | 156 | +// LibrarySubset indicates a subset of the macros and functions supported by a | 
|  | 157 | +// subsettable library. | 
|  | 158 | +message LibrarySubset { | 
|  | 159 | +  // Indicates whether the library has been disabled, typically only | 
|  | 160 | +  // used for default-enabled libraries like stdlib. | 
|  | 161 | +  bool disabled = 1; | 
|  | 162 | + | 
|  | 163 | +  // Disables macros for the given library. | 
|  | 164 | +  bool disable_macros = 2; | 
|  | 165 | + | 
|  | 166 | +  // Specifies a set of macro function names to include in the subset. | 
|  | 167 | +  repeated string include_macros = 3; | 
|  | 168 | + | 
|  | 169 | +  // Specifies a set of macro function names to exclude from the subset. | 
|  | 170 | +  // Note: if IncludeMacros is non-empty, then ExcludeFunctions is ignored. | 
|  | 171 | +  repeated string exclude_macros = 4; | 
|  | 172 | + | 
|  | 173 | +  // Specifies a set of functions to include in the subset. | 
|  | 174 | +  // | 
|  | 175 | +  // Note: the overloads specified in the subset need only specify their ID. | 
|  | 176 | +  // Note: if IncludeFunctions is non-empty, then ExcludeFunctions is ignored. | 
|  | 177 | +  repeated cel.expr.Decl include_functions = 5; | 
|  | 178 | + | 
|  | 179 | +  // Specifies the set of functions to exclude from the subset. | 
|  | 180 | +  // | 
|  | 181 | +  // Note: the overloads specified in the subset need only specify their ID. | 
|  | 182 | +  repeated cel.expr.Decl exclude_functions = 6; | 
|  | 183 | +} | 
0 commit comments