Skip to content

Commit

Permalink
Sync CEL proto changes to cel spec. (google#16)
Browse files Browse the repository at this point in the history
* Sync CEL proto changes to cel spec.

* Sync CEL proto changes to cel spec.

* Sync CEL proto changes to cel spec.

* Sycn CEL proto changes to cel spec.
  • Loading branch information
ayas authored Apr 6, 2018
1 parent 4eb3819 commit 40a8512
Show file tree
Hide file tree
Showing 9 changed files with 459 additions and 527 deletions.
13 changes: 11 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# How to Contribute

We'd love to accept your patches and contributions to this project. There are
just a few small guidelines you need to follow.
We'd love to accept your patches and contributions to this project. There are a
few guidelines you need to follow.

## Contributor License Agreement

Expand All @@ -21,3 +21,12 @@ All submissions, including submissions by project members, require review. We
use GitHub pull requests for this purpose. Consult
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
information on using pull requests.

## What to expect from maintainers

Expect maintainers to respond to new issues or pull requests within a week.
For outstanding and ongoing issues and particularly for long-running
pull requests, expect the maintainers to review within a week of a
contributor asking for a new review. There is no commitment to resolution --
merging or closing a pull request, or fixing or closing an issue -- because some
issues will require more discussion than others.
6 changes: 6 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ http_archive(
strip_prefix = "protobuf-javalite",
urls = ["https://github.com/google/protobuf/archive/javalite.zip"],
)
new_http_archive(
name = "com_google_googleapis",
url = "https://github.com/googleapis/googleapis/archive/common-protos-1_3_1.zip",
strip_prefix = "googleapis-common-protos-1_3_1/",
build_file_content = "proto_library(name = 'rpc_status', srcs = ['google/rpc/status.proto'], deps = ['@com_google_protobuf//:any_proto', '@com_google_protobuf//:empty_proto'], visibility = ['//visibility:public'])"
)
701 changes: 211 additions & 490 deletions doc/langdef.md

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion proto/checked/v1/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ proto_library(
"checked.proto",
],
# cc_api_version = 2,
# go_api_version = 2,
# java_api_version = 2,
# js_api_version = 2,
deps = [
Expand Down
30 changes: 21 additions & 9 deletions proto/checked/v1/checked.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ option java_outer_classname = "CheckedProto";
option java_package = "com.google.api.expr.checked.v1";

import "proto/v1/syntax.proto";
import "google/protobuf/any.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/struct.proto";

Expand Down Expand Up @@ -51,6 +50,7 @@ message CheckedExpr {
}

// Represents a CEL type.
//
message Type {
// CEL primitive types.
enum PrimitiveType {
Expand Down Expand Up @@ -124,6 +124,15 @@ message Type {
repeated Type arg_types = 2;
}

// Application defined abstract type.
message AbstractType {
// The fully qualified name of this abstract type.
string name = 1;

// Parameter types for this abstract type.
repeated Type parameter_types = 2;
}

// The kind of type.
oneof type_kind {
// Dynamic type.
Expand Down Expand Up @@ -176,9 +185,11 @@ message Type {
// errors present in the expression.
protobuf.Empty error = 12;

// Extension type, used for extending the type-checking with additional
// types which are well-known for a particular application of CEL.
protobuf.Any extension = 13;
// Older member of the oneof which we do not support any longer.
// reserved 13; // Reserved keyword does not work with oneof.

// Abstract, application defined type.
AbstractType abstract_type = 14;
}
}

Expand All @@ -199,7 +210,7 @@ message Decl {

// The constant value of the identifier. If not specified, the identifier
// must be supplied at evaluation time.
google.api.expr.v1.Constant value = 2;
google.api.expr.v1.Literal value = 2;

// Documentation string for the identifier.
string doc = 3;
Expand Down Expand Up @@ -270,7 +281,8 @@ message Decl {
// The fully qualified name of the declaration.
//
// Declarations are organized in containers and this represents the full path
// to the declaration in its container, as in `google.api.expr.Decl`.
// to the declaration in its container, as in
// `google.api.expr.v1.checked.Decl`.
//
// Declarations used as [FunctionDecl.Overload][] parameters may or may not
// have a name depending on whether the overload is function declaration or a
Expand All @@ -296,10 +308,10 @@ message Reference {
// presented candidates must happen at runtime because of dynamic types. The
// type checker attempts to narrow down this list as much as possible.
//
// Empty for [Decl.IdentDecl][] references.
// Empty if this is not a reference to a [Decl.FunctionDecl][].
repeated string overload_id = 3;

// For references to constants, this may contain the value of the
// constant if known at compile time.
google.api.expr.v1.Constant value = 4;
}
google.api.expr.v1.Literal value = 4;
}
26 changes: 24 additions & 2 deletions proto/v1/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ proto_library(
"value.proto",
],
# cc_api_version = 2,
# go_api_version = 2,
# java_api_version = 2,
# js_api_version = 2,
deps = [
Expand All @@ -35,13 +34,36 @@ java_lite_proto_library(
deps = [":value_protos"],
)

proto_library(
name = "eval_protos",
srcs = [
"eval.proto",
],
# cc_api_version = 2,
# java_api_version = 2,
# js_api_version = 2,
deps = [
":value_protos",
"@com_google_googleapis//:rpc_status",
],
)

java_proto_library(
name = "eval_java_proto",
deps = [":eval_protos"],
)

java_lite_proto_library(
name = "eval_java_proto_lite",
deps = [":eval_protos"],
)

proto_library(
name = "syntax_protos",
srcs = [
"syntax.proto",
],
# cc_api_version = 2,
# go_api_version = 2,
# java_api_version = 2,
# js_api_version = 2,
deps = [
Expand Down
100 changes: 100 additions & 0 deletions proto/v1/eval.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
syntax = "proto3";

package google.api.expr.v1;

option cc_enable_arenas = true;
option java_multiple_files = true;
option java_outer_classname = "EvalProto";
option java_package = "com.google.api.expr.v1";

import "proto/v1/value.proto";
import "google/rpc/status.proto";

// The state of an evaluation.
//
// Can represent an inital, partial, or completed state of evaluation.
message EvalState {
// The unique values referenced in this message.
repeated ExprValue values = 1;

// A single evalution result.
message Result {
// The id of the expression this result if for.
int64 expr = 1;
// The index in `values` of the resulting value.
int64 value = 2;
}

// An ordered list of results.
//
// Tracks the flow of evaluation through the expression.
// May be sparse.
repeated Result results = 3;
}

// The value of an evaluated expression.
message ExprValue {
// An expression can resolve to a value, error or unknown.
oneof kind {
Value value = 1;

// The set of errors in the critical path of evalution.
//
// Only errors in the critical path are included. For example,
// `(<error1> || true) && <error2>` will only result in `<error2>`,
// while `<error1> || <error2>` will result in both `<error1>` and
// `<error2>`.
//
// Errors cause by the presence of other errors are not included in the
// set. For example `<error1>.foo`, `foo(<error1>)`, and `<error1> + 1` will
// only result in `<error1>`.
//
// Multiple errors *might* be included when evaluation could result
// in different errors. For example `<error1> + <error2>` and
// `foo(<error1>, <error2>)` may result in `<error1>`, `<error2>` or both.
// The exact subset of errors included for this case is unspecified and
// depends on the implementation details of the evaluator.
ErrorSet error = 2;

// The set of unknowns in the critical path of evaluation.
//
// Unknown behaves identically to Error with regards to propagation.
// Specifically, only unknowns in the critical path are included, unknowns
// caused by the presence of other unknowns are not included, and multiple
// unknowns *might* be included included when evaluation could result in
// different unknowns. For example:
//
// (<unknown[1]> || true) && <unknown[2]> -> <unknown[2]>
// <unknown[1]> || <unknown[2]> -> <unknown[1,2]>
// <unknown[1]>.foo -> <unknown[1]>
// foo(<unknown[1]>) -> <unknown[1]>
// <unknown[1]> + <unknown[2]> -> <unknown[1]> or <unknown[2[>
//
// Unknown takes precidence over Error in cases where a `Value` can short
// circuit the result:
//
// <error> || <unknown> -> <unknown>
// <error> && <unknown> -> <unknown>
//
// Errors take precidence in all other cases:
//
// <unknown> + <error> -> <error>
// foo(<unknown>, <error>) -> <error>
UnknownSet unknown = 3;
};
}

// A set of errors.
//
// The errors included depend on the context. See `ExprValue.error`.
message ErrorSet {
repeated google.rpc.Status errors = 1;
}

// A set of expressions for which the value is unknown.
//
// The unknowns included depend on the context. See `ExprValue.unknown`.
message UnknownSet {
// The ids of the expressions with unknown values.
repeated int64 exprs = 1;
}
24 changes: 9 additions & 15 deletions proto/v1/syntax.proto
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ message Expr {

// Required. Variants of expressions.
oneof expr_kind {
// A constant expression.
Constant const_expr = 3;
// A literal expression.
Literal literal_expr = 3;

// An identifier expression.
Ident ident_expr = 4;
Expand All @@ -207,7 +207,7 @@ message Expr {
// A list creation expression.
CreateList list_expr = 7;

// A map or message creation expression.
// A map or object creation expression.
CreateStruct struct_expr = 8;

// A comprehension expression.
Expand All @@ -217,27 +217,21 @@ message Expr {

// Represents a primitive literal.
//
// This is similar as the primitives supported in the well-known type
// `google.protobuf.Value`, but richer so it can represent CEL's full range of
// primitives.
// List, map, and objects need to be 'constructed' and thus have no
// literal representation.
//
// Lists and structs are not included as constants as these aggregate types may
// contain [Expr][] elements which require evaluation and are thus not constant.
//
// Examples of constants include: `"hello"`, `b'bytes'`, `1u`, `4.2`, `-2`,
// Examples of literals include: `"hello"`, `b'bytes'`, `1u`, `4.2`, `-2`,
// `true`, `null`.
message Constant {
// Required. The valid constant kinds.
oneof constant_kind {
message Literal {
// Required. The valid literal kinds.
oneof literal_kind {
protobuf.NullValue null_value = 1; // null value.
bool bool_value = 2; // boolean value.
int64 int64_value = 3; // int64 value.
uint64 uint64_value = 4; // uint64 value.
double double_value = 5; // double value.
string string_value = 6; // string value.
bytes bytes_value = 7; // bytes value.
protobuf.Duration duration_value = 8; // protobuf.Duration value.
protobuf.Timestamp timestamp_value = 9; // protobuf.Timestamp value.
}
}

Expand Down
Loading

0 comments on commit 40a8512

Please sign in to comment.