eval.proto 4.1 KB

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