xref: /aosp_15_r20/external/googleapis/google/api/expr/v1beta1/eval.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2019 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
16syntax = "proto3";
17
18package google.api.expr.v1beta1;
19
20import "google/api/expr/v1beta1/value.proto";
21import "google/rpc/status.proto";
22
23option cc_enable_arenas = true;
24option go_package = "google.golang.org/genproto/googleapis/api/expr/v1beta1;expr";
25option java_multiple_files = true;
26option java_outer_classname = "EvalProto";
27option java_package = "com.google.api.expr.v1beta1";
28
29// The state of an evaluation.
30//
31// Can represent an initial, partial, or completed state of evaluation.
32message EvalState {
33  // A single evaluation result.
34  message Result {
35    // The expression this result is for.
36    IdRef expr = 1;
37
38    // The index in `values` of the resulting value.
39    int32 value = 2;
40  }
41
42  // The unique values referenced in this message.
43  repeated ExprValue values = 1;
44
45  // An ordered list of results.
46  //
47  // Tracks the flow of evaluation through the expression.
48  // May be sparse.
49  repeated Result results = 3;
50}
51
52// The value of an evaluated expression.
53message ExprValue {
54  // An expression can resolve to a value, error or unknown.
55  oneof kind {
56    // A concrete value.
57    Value value = 1;
58
59    // The set of errors in the critical path of evalution.
60    //
61    // Only errors in the critical path are included. For example,
62    // `(<error1> || true) && <error2>` will only result in `<error2>`,
63    // while `<error1> || <error2>` will result in both `<error1>` and
64    // `<error2>`.
65    //
66    // Errors cause by the presence of other errors are not included in the
67    // set. For example `<error1>.foo`, `foo(<error1>)`, and `<error1> + 1` will
68    // only result in `<error1>`.
69    //
70    // Multiple errors *might* be included when evaluation could result
71    // in different errors. For example `<error1> + <error2>` and
72    // `foo(<error1>, <error2>)` may result in `<error1>`, `<error2>` or both.
73    // The exact subset of errors included for this case is unspecified and
74    // depends on the implementation details of the evaluator.
75    ErrorSet error = 2;
76
77    // The set of unknowns in the critical path of evaluation.
78    //
79    // Unknown behaves identically to Error with regards to propagation.
80    // Specifically, only unknowns in the critical path are included, unknowns
81    // caused by the presence of other unknowns are not included, and multiple
82    // unknowns *might* be included included when evaluation could result in
83    // different unknowns. For example:
84    //
85    //     (<unknown[1]> || true) && <unknown[2]> -> <unknown[2]>
86    //     <unknown[1]> || <unknown[2]> -> <unknown[1,2]>
87    //     <unknown[1]>.foo -> <unknown[1]>
88    //     foo(<unknown[1]>) -> <unknown[1]>
89    //     <unknown[1]> + <unknown[2]> -> <unknown[1]> or <unknown[2[>
90    //
91    // Unknown takes precidence over Error in cases where a `Value` can short
92    // circuit the result:
93    //
94    //     <error> || <unknown> -> <unknown>
95    //     <error> && <unknown> -> <unknown>
96    //
97    // Errors take precidence in all other cases:
98    //
99    //     <unknown> + <error> -> <error>
100    //     foo(<unknown>, <error>) -> <error>
101    UnknownSet unknown = 3;
102  }
103}
104
105// A set of errors.
106//
107// The errors included depend on the context. See `ExprValue.error`.
108message ErrorSet {
109  // The errors in the set.
110  repeated google.rpc.Status errors = 1;
111}
112
113// A set of expressions for which the value is unknown.
114//
115// The unknowns included depend on the context. See `ExprValue.unknown`.
116message UnknownSet {
117  // The ids of the expressions with unknown values.
118  repeated IdRef exprs = 1;
119}
120
121// A reference to an expression id.
122message IdRef {
123  // The expression id.
124  int32 id = 1;
125}
126