Skip to content

Add support for declared opaque and abstract types in CEL env config - #2501

Open
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_1030307027
Open

copybara-service[bot] wants to merge 1 commit into
masterfrom
test_1030307027

Conversation

@copybara-service

Copy link
Copy Markdown

Add support for declared opaque and abstract types in CEL env config

Adds types declarations (opaque and abstract) to cel::Env config, YAML
serialization/deserialization, type checking, and EnvRuntime evaluation.

Type checking:

  • Declared types are resolved in dependency order with cycle detection,
    conflict checks (against protobuf, custom, built-in, well-known, variable,
    and container-qualified names), and an expanded type node limit to prevent
    exponential expansion.
  • Declared types are registered with the type checker so they can be used as
    type literals and resolved in variable and function declarations. Name
    segments may be CEL reserved words, which must be backtick-escaped in
    expressions.
  • Extracts ValidateTypeForDeclaration into checker/internal/type_validation
    so checker and env share the same validation logic.

Runtime:

  • EnvRuntime registers declared types as type-erased opaque types (owned by
    the runtime) and enables qualified type identifiers so expressions such as
    type(x) == foo.Bar evaluate.

Adds `types` declarations (`opaque` and `abstract`) to `cel::Env` config, YAML
serialization/deserialization, type checking, and `EnvRuntime` evaluation.

Type checking:
- Declared types are resolved in dependency order with cycle detection,
  conflict checks (against protobuf, custom, built-in, well-known, variable,
  and container-qualified names), and an expanded type node limit to prevent
  exponential expansion.
- Declared types are registered with the type checker so they can be used as
  type literals and resolved in variable and function declarations. Name
  segments may be CEL reserved words, which must be backtick-escaped in
  expressions.
- Extracts `ValidateTypeForDeclaration` into `checker/internal/type_validation`
  so checker and env share the same validation logic.

Runtime:
- `EnvRuntime` registers declared types as type-erased opaque types (owned by
  the runtime) and enables qualified type identifiers so expressions such as
  `type(x) == foo.Bar` evaluate.
PiperOrigin-RevId: 1030307027
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant