eval.proto 4.0 KB

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