Forráskód Böngészése

Implement realtime WebSocket client (chatto.realtime.v1)

Chatto's live-event channel is a binary-protobuf WebSocket at
/api/realtime. Replace the previous stub in realtime.py with a real
implementation.

Vendored proto sources (proto/) and scripts/generate_pb.sh fetch the
upstream .proto files and regenerate Python bindings under
src/chattolib/_pb/. The _pb package inserts itself onto sys.path so
the generated `from chatto.api.v1 import ...` imports resolve without
polluting host projects' top-level namespace.

- RealtimeConnection async context manager: opens the WS, exchanges
  the RealtimeClientHello (bearer token from ChattoClient, session
  cookie in the WS upgrade headers), receives the ServerHello, then
  sends RealtimeSubscribeEvents.
- .events() async iterator decodes RealtimeServerFrame variants
  (event, heartbeat, subscribed, pong, error, close). Fatal errors
  and close frames raise ChattoRealtimeError / ChattoRealtimeCloseError.
- .ping(nonce) sends a client ping for explicit RTT checks.
- stream_events(client) module-level async iterator handles connect,
  drain, and cleanup for the common case.
- RealtimeEvent dataclass exposes id/created_at/actor_id/kind/payload;
  kind is the protobuf oneof case name (message_posted, reaction_added,
  presence_changed, notification_created, ...).

Deps and tooling:
- websockets>=13 and protobuf>=5.28 added to the [realtime] extra.
- pyproject: ruff extend-exclude and mypy follow_imports=skip for
  chattolib._pb so generated modules don't fight the type checker.
- tests/test_realtime.py: URL helper, event wrapping, exception
  fields, protobuf frame roundtrips (10 tests, all passing).

Live-verified against Chatto HQ (0.4.2) with the RoboChatto account:
handshake succeeded, capabilities advertised
(chatto.realtime.events.live.v1, heartbeat.v1, ping.v1), a
presence_changed event decoded end-to-end, connection closed cleanly.

README updated with a Realtime section; CLAUDE.md refreshed with the
new package layout, realtime service row, and _pb regeneration notes.
TheCodemancer 3 hónapja
szülő
commit
b7d1e04eba
31 módosított fájl, 6921 hozzáadás és 41 törlés
  1. 13 5
      CLAUDE.md
  2. 28 2
      README.md
  3. 5130 0
      proto/buf/validate/validate.proto
  4. 98 0
      proto/chatto/api/v1/notification_preferences.proto
  5. 33 0
      proto/chatto/api/v1/permissions.proto
  6. 42 0
      proto/chatto/api/v1/presence.proto
  7. 47 0
      proto/chatto/api/v1/user_status.proto
  8. 24 0
      proto/chatto/api/v1/users.proto
  9. 105 0
      proto/chatto/api/v1/viewer.proto
  10. 584 0
      proto/chatto/realtime/v1/realtime.proto
  11. 8 0
      pyproject.toml
  12. 71 0
      scripts/generate_pb.sh
  13. 14 0
      src/chattolib/__init__.py
  14. 21 0
      src/chattolib/_pb/__init__.py
  15. 0 0
      src/chattolib/_pb/buf/__init__.py
  16. 0 0
      src/chattolib/_pb/buf/validate/__init__.py
  17. 30 0
      src/chattolib/_pb/buf/validate/validate_pb2.py
  18. 0 0
      src/chattolib/_pb/chatto/__init__.py
  19. 0 0
      src/chattolib/_pb/chatto/api/__init__.py
  20. 0 0
      src/chattolib/_pb/chatto/api/v1/__init__.py
  21. 27 0
      src/chattolib/_pb/chatto/api/v1/notification_preferences_pb2.py
  22. 38 0
      src/chattolib/_pb/chatto/api/v1/permissions_pb2.py
  23. 43 0
      src/chattolib/_pb/chatto/api/v1/presence_pb2.py
  24. 50 0
      src/chattolib/_pb/chatto/api/v1/user_status_pb2.py
  25. 38 0
      src/chattolib/_pb/chatto/api/v1/users_pb2.py
  26. 30 0
      src/chattolib/_pb/chatto/api/v1/viewer_pb2.py
  27. 0 0
      src/chattolib/_pb/chatto/realtime/__init__.py
  28. 0 0
      src/chattolib/_pb/chatto/realtime/v1/__init__.py
  29. 30 0
      src/chattolib/_pb/chatto/realtime/v1/realtime_pb2.py
  30. 291 34
      src/chattolib/realtime.py
  31. 126 0
      tests/test_realtime.py

+ 13 - 5
CLAUDE.md

@@ -34,9 +34,10 @@ mypy src/chattolib
 
 ## Architecture
 
-The library uses **httpx** for async HTTP. Realtime events are a separate
-protobuf WebSocket protocol (`chatto.realtime.v1`); the current release ships
-only a stub for that channel.
+The library uses **httpx** for async HTTP. Realtime events use a separate
+binary-protobuf WebSocket protocol (`chatto.realtime.v1`) served at
+`/api/realtime`, implemented in `realtime.py` on top of `websockets` and
+generated protobuf bindings.
 
 ### Package layout: `src/chattolib/`
 
@@ -44,7 +45,14 @@ only a stub for that channel.
 - **_transport.py** — Connect JSON transport helpers (URL building, headers, error decoding).
 - **types.py** — Dataclasses and `StrEnum` types mirroring the protobuf messages, with `.parse(dict)` classmethods that consume Connect JSON.
 - **exceptions.py** — `ChattoError`, `ChattoConnectError` (wraps Connect protocol errors), `ChattoAuthError`.
-- **realtime.py** — Placeholder for the future protobuf realtime WebSocket client.
+- **realtime.py** — Protobuf realtime WebSocket client. `stream_events(client)` yields `RealtimeEvent(kind, payload, ...)` values. Errors surface as `ChattoRealtimeError` / `ChattoRealtimeCloseError`.
+- **_pb/** — Vendored, generated Python protobuf bindings for
+  `chatto.realtime.v1` and its transitive imports. Regenerate with
+  `scripts/generate_pb.sh` (needs `protoc` on PATH); the script fetches the
+  latest `.proto` sources from `chattocorp/chatto` and rewrites the bindings.
+  The `_pb/__init__.py` inserts its own directory onto `sys.path` so the
+  generated `from chatto.api.v1 import ...` imports resolve without polluting
+  the top-level namespace of dependent projects.
 
 ### Connect protocol conventions
 
@@ -79,7 +87,7 @@ only a stub for that channel.
 | Push | `PushNotificationService` | `Subscribe`, `Unsubscribe` |
 | Assets | `AssetService` | `GetAsset`, `BatchGetAssets` |
 | Voice calls | `VoiceCallService` | `ListActiveCalls`, `GetActiveCall`, `BatchGetActiveCalls`, `JoinCall`, `LeaveCall`, `GetCallToken` |
-| Realtime (WS) | `chatto.realtime.v1` protobuf WS | Not yet implemented in Python — see `realtime.py` and the follow-up bean |
+| Realtime (WS) | `chatto.realtime.v1` protobuf WS | `stream_events(client)` / `RealtimeConnection` — full frame set: hello, subscribe, event, heartbeat, ping/pong, error, close |
 
 ### Naming conventions
 

+ 28 - 2
README.md

@@ -5,8 +5,9 @@
 > Chattolib versions track the Chatto server version they target. **0.4.2**
 > targets Chatto 0.4.2's ConnectRPC API. The upstream server dropped GraphQL
 > in favour of a protobuf-first Connect API (see ADR-042 in chattocorp/chatto),
-> and this release is a full rewrite for that transport. The library speaks
-> Connect JSON over HTTP; realtime WebSocket support is a follow-up.
+> and this release is a full rewrite for that transport. Request/response
+> traffic uses Connect JSON over HTTP; the realtime channel is a binary
+> protobuf WebSocket at `/api/realtime` (needs the ``[realtime]`` extra).
 
 ## Install
 
@@ -38,6 +39,31 @@ async def main():
 asyncio.run(main())
 ```
 
+## Realtime
+
+Install with the extra:
+
+```bash
+pip install 'chattolib[realtime]'
+```
+
+Then stream live events:
+
+```python
+from chattolib import stream_events
+
+async with await ChattoClient.login("username", "password") as client:
+    async for event in stream_events(client):
+        print(event.kind, event.actor_id, event.payload)
+```
+
+`event.kind` names the protobuf ``oneof`` case (`message_posted`,
+`reaction_added`, `presence_changed`, `notification_created`, …).
+`event.payload` is the concrete protobuf sub-message — access its fields
+directly (e.g. `event.payload.room_id`). Realtime events are invalidation
+signals; use the corresponding Connect RPC (`GetRoomEventsAround`,
+`GetNotification`, `GetUser`, …) to hydrate the referenced resource.
+
 ## Escape hatch
 
 `ChattoClient.call(service, method, request)` invokes any Connect RPC by full

+ 5130 - 0
proto/buf/validate/validate.proto

@@ -0,0 +1,5130 @@
+// Copyright 2023-2026 Buf Technologies, Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto2";
+
+// [Protovalidate](https://protovalidate.com/) is the semantic validation library for Protobuf.
+// It provides standard annotations to validate common rules on messages and fields, as well as the ability to use [CEL](https://cel.dev) to write custom rules.
+// It's the next generation of [protoc-gen-validate](https://github.com/bufbuild/protoc-gen-validate).
+//
+// This package provides the options, messages, and enums that power Protovalidate.
+// Apply its options to messages, fields, and oneofs in your Protobuf schemas to add validation rules:
+//
+// ```proto
+// message User {
+//   string id = 1 [(buf.validate.field).string.uuid = true];
+//   string first_name = 2 [(buf.validate.field).string.max_len = 64];
+//   string last_name = 3 [(buf.validate.field).string.max_len = 64];
+//
+//   option (buf.validate.message).cel = {
+//     id: "first_name_requires_last_name"
+//     message: "last_name must be present if first_name is present"
+//     expression: "!has(this.first_name) || has(this.last_name)"
+//   };
+// }
+// ```
+//
+// These rules are enforced at runtime by language-specific libraries.
+// See the [developer quickstart](https://protovalidate.com/quickstart/) to get started, or go directly to the runtime library for your language:
+// [Go](https://github.com/bufbuild/protovalidate-go),
+// [JavaScript/TypeScript](https://github.com/bufbuild/protovalidate-es),
+// [Java](https://github.com/bufbuild/protovalidate-java),
+// [Python](https://github.com/bufbuild/protovalidate-python),
+// or [C++](https://github.com/bufbuild/protovalidate-cc).
+package buf.validate;
+
+import "google/protobuf/descriptor.proto";
+import "google/protobuf/duration.proto";
+import "google/protobuf/field_mask.proto";
+import "google/protobuf/timestamp.proto";
+
+option go_package = "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate";
+option java_multiple_files = true;
+option java_outer_classname = "ValidateProto";
+option java_package = "build.buf.validate";
+
+// MessageOptions is an extension to google.protobuf.MessageOptions. It allows
+// the addition of validation rules at the message level. These rules can be
+// applied to incoming messages to ensure they meet certain criteria before
+// being processed.
+extend google.protobuf.MessageOptions {
+  // Rules specify the validations to be performed on this message. By default,
+  // no validation is performed against a message.
+  optional MessageRules message = 1159;
+}
+
+// OneofOptions is an extension to google.protobuf.OneofOptions. It allows
+// the addition of validation rules on a oneof. These rules can be
+// applied to incoming messages to ensure they meet certain criteria before
+// being processed.
+extend google.protobuf.OneofOptions {
+  // Rules specify the validations to be performed on this oneof. By default,
+  // no validation is performed against a oneof.
+  optional OneofRules oneof = 1159;
+}
+
+// FieldOptions is an extension to google.protobuf.FieldOptions. It allows
+// the addition of validation rules at the field level. These rules can be
+// applied to incoming messages to ensure they meet certain criteria before
+// being processed.
+extend google.protobuf.FieldOptions {
+  // Rules specify the validations to be performed on this field. By default,
+  // no validation is performed against a field.
+  optional FieldRules field = 1159;
+
+  // Specifies predefined rules. When extending a standard rule message,
+  // this adds additional CEL expressions that apply when the extension is used.
+  //
+  // ```proto
+  // extend buf.validate.Int32Rules {
+  //   bool is_zero [(buf.validate.predefined).cel = {
+  //     id: "int32.is_zero",
+  //     message: "must be zero",
+  //     expression: "!rule || this == 0",
+  //   }];
+  // }
+  //
+  // message Foo {
+  //   int32 reserved = 1 [(buf.validate.field).int32.(is_zero) = true];
+  // }
+  // ```
+  optional PredefinedRules predefined = 1160;
+}
+
+// `Rule` represents a validation rule written in the Common Expression
+// Language (CEL) syntax. Each Rule includes a unique identifier, an
+// optional error message, and the CEL expression to evaluate. For more
+// information, [see our documentation](https://buf.build/docs/protovalidate/schemas/custom-rules/).
+//
+// ```proto
+// message Foo {
+//   option (buf.validate.message).cel = {
+//     id: "foo.bar"
+//     message: "bar must be greater than 0"
+//     expression: "this.bar > 0"
+//   };
+//   int32 bar = 1;
+// }
+// ```
+message Rule {
+  // `id` is a string that serves as a machine-readable name for this Rule.
+  // It should be unique within its scope, which could be either a message or a field.
+  optional string id = 1;
+
+  // `message` is an optional field that provides a human-readable error message
+  // for this Rule when the CEL expression evaluates to false. If a
+  // non-empty message is provided, any strings resulting from the CEL
+  // expression evaluation are ignored.
+  optional string message = 2;
+
+  // `expression` is the actual CEL expression that will be evaluated for
+  // validation. This string must resolve to either a boolean or a string
+  // value. If the expression evaluates to false or a non-empty string, the
+  // validation is considered failed, and the message is rejected.
+  optional string expression = 3;
+}
+
+// MessageRules represents validation rules that are applied to the entire message.
+// It includes disabling options and a list of Rule messages representing Common Expression Language (CEL) validation rules.
+message MessageRules {
+  // `cel_expression` is a repeated field CEL expressions. Each expression specifies a validation
+  // rule to be applied to this message. These rules are written in Common Expression Language (CEL) syntax.
+  //
+  // This is a simplified form of the `cel` Rule field, where only `expression` is set. This allows for
+  // simpler syntax when defining CEL Rules where `id` and `message` derived from the `expression`. `id` will
+  // be same as the `expression`.
+  //
+  // For more information, [see our documentation](https://buf.build/docs/protovalidate/schemas/custom-rules/).
+  //
+  // ```proto
+  // message MyMessage {
+  //   // The field `foo` must be greater than 42.
+  //   option (buf.validate.message).cel_expression = "this.foo > 42";
+  //   // The field `foo` must be less than 84.
+  //   option (buf.validate.message).cel_expression = "this.foo < 84";
+  //   optional int32 foo = 1;
+  // }
+  // ```
+  repeated string cel_expression = 5;
+  // `cel` is a repeated field of type Rule. Each Rule specifies a validation rule to be applied to this message.
+  // These rules are written in Common Expression Language (CEL) syntax. For more information,
+  // [see our documentation](https://buf.build/docs/protovalidate/schemas/custom-rules/).
+  //
+  //
+  // ```proto
+  // message MyMessage {
+  //   // The field `foo` must be greater than 42.
+  //   option (buf.validate.message).cel = {
+  //     id: "my_message.value",
+  //     message: "must be greater than 42",
+  //     expression: "this.foo > 42",
+  //   };
+  //   optional int32 foo = 1;
+  // }
+  // ```
+  repeated Rule cel = 3;
+
+  // `oneof` is a repeated field of type MessageOneofRule that specifies a list of fields
+  // of which at most one can be present. If `required` is also specified, then exactly one
+  // of the specified fields _must_ be present.
+  //
+  // This will enforce oneof-like constraints with a few features not provided by
+  // actual Protobuf oneof declarations:
+  //   1. Repeated and map fields are allowed in this validation. In a Protobuf oneof,
+  //      only scalar fields are allowed.
+  //   2. Fields with implicit presence are allowed. In a Protobuf oneof, all member
+  //      fields have explicit presence. This means that, for the purpose of determining
+  //      how many fields are set, explicitly setting such a field to its zero value is
+  //      effectively the same as not setting it at all.
+  //   3. This will always generate validation errors for a message unmarshalled from
+  //      serialized data that sets more than one field. With a Protobuf oneof, when
+  //      multiple fields are present in the serialized form, earlier values are usually
+  //      silently ignored when unmarshalling, with only the last field being set when
+  //      unmarshalling completes.
+  //
+  // Note that adding a field to a `oneof` will also set the IGNORE_IF_ZERO_VALUE on the fields. This means
+  // only the field that is set will be validated and the unset fields are not validated according to the field rules.
+  // This behavior can be overridden by setting `ignore` against a field.
+  //
+  // ```proto
+  // message MyMessage {
+  //   // Only one of `field1` or `field2` _can_ be present in this message.
+  //   option (buf.validate.message).oneof = { fields: ["field1", "field2"] };
+  //   // Exactly one of `field3` or `field4` _must_ be present in this message.
+  //   option (buf.validate.message).oneof = { fields: ["field3", "field4"], required: true };
+  //   string field1 = 1;
+  //   bytes field2 = 2;
+  //   bool field3 = 3;
+  //   int32 field4 = 4;
+  // }
+  // ```
+  repeated MessageOneofRule oneof = 4;
+
+  reserved 1;
+  reserved "disabled";
+}
+
+message MessageOneofRule {
+  // A list of field names to include in the oneof. All field names must be
+  // defined in the message. At least one field must be specified, and
+  // duplicates are not permitted.
+  repeated string fields = 1;
+  // If true, one of the fields specified _must_ be set.
+  optional bool required = 2;
+}
+
+// The `OneofRules` message type enables you to manage rules for
+// oneof fields in your protobuf messages.
+message OneofRules {
+  // If `required` is true, exactly one field of the oneof must be set. A
+  // validation error is returned if no fields in the oneof are set. Further rules
+  // should be placed on the fields themselves to ensure they are valid values,
+  // such as `min_len` or `gt`.
+  //
+  // ```proto
+  // message MyMessage {
+  //   oneof value {
+  //     // Either `a` or `b` must be set. If `a` is set, it must also be
+  //     // non-empty; whereas if `b` is set, it can still be an empty string.
+  //     option (buf.validate.oneof).required = true;
+  //     string a = 1 [(buf.validate.field).string.min_len = 1];
+  //     string b = 2;
+  //   }
+  // }
+  // ```
+  optional bool required = 1;
+}
+
+// FieldRules encapsulates the rules for each type of field. Depending on
+// the field, the correct set should be used to ensure proper validations.
+message FieldRules {
+  // `cel_expression` is a repeated field CEL expressions. Each expression specifies a validation
+  // rule to be applied to this message. These rules are written in Common Expression Language (CEL) syntax.
+  //
+  // This is a simplified form of the `cel` Rule field, where only `expression` is set. This allows for
+  // simpler syntax when defining CEL Rules where `id` and `message` derived from the `expression`. `id` will
+  // be same as the `expression`.
+  //
+  // For more information, [see our documentation](https://buf.build/docs/protovalidate/schemas/custom-rules/).
+  //
+  // ```proto
+  // message MyMessage {
+  //   // The field `value` must be greater than 42.
+  //   optional int32 value = 1 [(buf.validate.field).cel_expression = "this > 42"];
+  // }
+  // ```
+  repeated string cel_expression = 29;
+  // `cel` is a repeated field used to represent a textual expression
+  // in the Common Expression Language (CEL) syntax. For more information,
+  // [see our documentation](https://buf.build/docs/protovalidate/schemas/custom-rules/).
+  //
+  // ```proto
+  // message MyMessage {
+  //   // The field `value` must be greater than 42.
+  //   optional int32 value = 1 [(buf.validate.field).cel = {
+  //     id: "my_message.value",
+  //     message: "must be greater than 42",
+  //     expression: "this > 42",
+  //   }];
+  // }
+  // ```
+  repeated Rule cel = 23;
+  // If `required` is true, the field must be set. A validation error is returned
+  // if the field is not set.
+  //
+  // ```proto
+  // syntax="proto3";
+  //
+  // message FieldsWithPresence {
+  //   // Requires any string to be set, including the empty string.
+  //   optional string link = 1 [
+  //     (buf.validate.field).required = true
+  //   ];
+  //   // Requires true or false to be set.
+  //   optional bool disabled = 2 [
+  //     (buf.validate.field).required = true
+  //   ];
+  //   // Requires a message to be set, including the empty message.
+  //   SomeMessage msg = 4 [
+  //     (buf.validate.field).required = true
+  //   ];
+  // }
+  // ```
+  //
+  // All fields in the example above track presence. By default, Protovalidate
+  // ignores rules on those fields if no value is set. `required` ensures that
+  // the fields are set and valid.
+  //
+  // Fields that don't track presence are always validated by Protovalidate,
+  // whether they are set or not. It is not necessary to add `required`. It
+  // can be added to indicate that the field cannot be the zero value.
+  //
+  // ```proto
+  // syntax="proto3";
+  //
+  // message FieldsWithoutPresence {
+  //   // `string.email` always applies, even to an empty string.
+  //   string link = 1 [
+  //     (buf.validate.field).string.email = true
+  //   ];
+  //   // `repeated.min_items` always applies, even to an empty list.
+  //   repeated string labels = 2 [
+  //     (buf.validate.field).repeated.min_items = 1
+  //   ];
+  //   // `required`, for fields that don't track presence, indicates
+  //   // the value of the field can't be the zero value.
+  //   int32 zero_value_not_allowed = 3 [
+  //     (buf.validate.field).required = true
+  //   ];
+  // }
+  // ```
+  //
+  // To learn which fields track presence, see the
+  // [Field Presence cheat sheet](https://protobuf.dev/programming-guides/field_presence/#cheat).
+  //
+  // Note: While field rules can be applied to repeated items, map keys, and map
+  // values, the elements are always considered to be set. Consequently,
+  // specifying `repeated.items.required` is redundant.
+  optional bool required = 25;
+  // Ignore validation rules on the field if its value matches the specified
+  // criteria. See the `Ignore` enum for details.
+  //
+  // ```proto
+  // message UpdateRequest {
+  //   // The uri rule only applies if the field is not an empty string.
+  //   string url = 1 [
+  //     (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE,
+  //     (buf.validate.field).string.uri = true
+  //   ];
+  // }
+  // ```
+  optional Ignore ignore = 27;
+
+  oneof type {
+    // Scalar Field Types
+    FloatRules float = 1;
+    DoubleRules double = 2;
+    Int32Rules int32 = 3;
+    Int64Rules int64 = 4;
+    UInt32Rules uint32 = 5;
+    UInt64Rules uint64 = 6;
+    SInt32Rules sint32 = 7;
+    SInt64Rules sint64 = 8;
+    Fixed32Rules fixed32 = 9;
+    Fixed64Rules fixed64 = 10;
+    SFixed32Rules sfixed32 = 11;
+    SFixed64Rules sfixed64 = 12;
+    BoolRules bool = 13;
+    StringRules string = 14;
+    BytesRules bytes = 15;
+
+    // Complex Field Types
+    EnumRules enum = 16;
+    RepeatedRules repeated = 18;
+    MapRules map = 19;
+
+    // Well-Known Field Types
+    AnyRules any = 20;
+    DurationRules duration = 21;
+    FieldMaskRules field_mask = 28;
+    TimestampRules timestamp = 22;
+  }
+
+  reserved 24, 26;
+  reserved "skipped", "ignore_empty";
+}
+
+// PredefinedRules are custom rules that can be re-used with
+// multiple fields.
+message PredefinedRules {
+  // `cel` is a repeated field used to represent a textual expression
+  // in the Common Expression Language (CEL) syntax. For more information,
+  // [see our documentation](https://buf.build/docs/protovalidate/schemas/predefined-rules/).
+  //
+  // ```proto
+  // message MyMessage {
+  //   // The field `value` must be greater than 42.
+  //   optional int32 value = 1 [(buf.validate.predefined).cel = {
+  //     id: "my_message.value",
+  //     message: "must be greater than 42",
+  //     expression: "this > 42",
+  //   }];
+  // }
+  // ```
+  repeated Rule cel = 1;
+
+  reserved 24, 26;
+  reserved "skipped", "ignore_empty";
+}
+
+// Specifies how `FieldRules.ignore` behaves, depending on the field's value, and
+// whether the field tracks presence.
+enum Ignore {
+  // Ignore rules if the field tracks presence and is unset. This is the default
+  // behavior.
+  //
+  // In proto3, only message fields, members of a Protobuf `oneof`, and fields
+  // with the `optional` label track presence. Consequently, the following fields
+  // are always validated, whether a value is set or not:
+  //
+  // ```proto
+  // syntax="proto3";
+  //
+  // message RulesApply {
+  //   string email = 1 [
+  //     (buf.validate.field).string.email = true
+  //   ];
+  //   int32 age = 2 [
+  //     (buf.validate.field).int32.gt = 0
+  //   ];
+  //   repeated string labels = 3 [
+  //     (buf.validate.field).repeated.min_items = 1
+  //   ];
+  // }
+  // ```
+  //
+  // In contrast, the following fields track presence, and are only validated if
+  // a value is set:
+  //
+  // ```proto
+  // syntax="proto3";
+  //
+  // message RulesApplyIfSet {
+  //   optional string email = 1 [
+  //     (buf.validate.field).string.email = true
+  //   ];
+  //   oneof ref {
+  //     string reference = 2 [
+  //       (buf.validate.field).string.uuid = true
+  //     ];
+  //     string name = 3 [
+  //       (buf.validate.field).string.min_len = 4
+  //     ];
+  //   }
+  //   SomeMessage msg = 4 [
+  //     (buf.validate.field).cel = {/* ... */}
+  //   ];
+  // }
+  // ```
+  //
+  // To ensure that such a field is set, add the `required` rule.
+  //
+  // To learn which fields track presence, see the
+  // [Field Presence cheat sheet](https://protobuf.dev/programming-guides/field_presence/#cheat).
+  IGNORE_UNSPECIFIED = 0;
+
+  // Ignore rules if the field is unset, or set to the zero value.
+  //
+  // The zero value depends on the field type:
+  // - For strings, the zero value is the empty string.
+  // - For bytes, the zero value is empty bytes.
+  // - For bool, the zero value is false.
+  // - For numeric types, the zero value is zero.
+  // - For enums, the zero value is the first defined enum value.
+  // - For repeated fields, the zero is an empty list.
+  // - For map fields, the zero is an empty map.
+  // - For message fields, absence of the message (typically a null-value) is considered zero value.
+  //
+  // For fields that track presence (e.g. adding the `optional` label in proto3),
+  // this a no-op and behavior is the same as the default `IGNORE_UNSPECIFIED`.
+  IGNORE_IF_ZERO_VALUE = 1;
+
+  // Always ignore rules, including the `required` rule.
+  //
+  // This is useful for ignoring the rules of a referenced message, or to
+  // temporarily ignore rules during development.
+  //
+  // ```proto
+  // message MyMessage {
+  //   // The field's rules will always be ignored, including any validations
+  //   // on value's fields.
+  //   MyOtherMessage value = 1 [
+  //     (buf.validate.field).ignore = IGNORE_ALWAYS
+  //   ];
+  // }
+  // ```
+  IGNORE_ALWAYS = 3;
+
+  reserved 2;
+  reserved "IGNORE_EMPTY", "IGNORE_DEFAULT", "IGNORE_IF_DEFAULT_VALUE", "IGNORE_IF_UNPOPULATED";
+}
+
+// FloatRules describes the rules applied to `float` values. These
+// rules may also be applied to the `google.protobuf.FloatValue` Well-Known-Type.
+message FloatRules {
+  // `const` requires the field value to exactly match the specified value. If
+  // the field value doesn't match, an error message is generated.
+  //
+  // ```proto
+  // message MyFloat {
+  //   // value must equal 42.0
+  //   float value = 1 [(buf.validate.field).float.const = 42.0];
+  // }
+  // ```
+  optional float const = 1 [(predefined).cel = {
+    id: "float.const"
+    expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
+  }];
+
+  oneof less_than {
+    // `lt` requires the field value to be less than the specified value (field <
+    // value). If the field value is equal to or greater than the specified value,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MyFloat {
+    //   // must be less than 10.0
+    //   float value = 1 [(buf.validate.field).float.lt = 10.0];
+    // }
+    // ```
+    float lt = 2 [(predefined).cel = {
+      id: "float.lt"
+      expression:
+        "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this >= rules.lt)"
+        "? 'must be less than %s'.format([rules.lt]) : ''"
+    }];
+
+    // `lte` requires the field value to be less than or equal to the specified
+    // value (field <= value). If the field value is greater than the specified
+    // value, an error message is generated.
+    //
+    // ```proto
+    // message MyFloat {
+    //   // must be less than or equal to 10.0
+    //   float value = 1 [(buf.validate.field).float.lte = 10.0];
+    // }
+    // ```
+    float lte = 3 [(predefined).cel = {
+      id: "float.lte"
+      expression:
+        "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this > rules.lte)"
+        "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
+    }];
+  }
+
+  oneof greater_than {
+    // `gt` requires the field value to be greater than the specified value
+    // (exclusive). If the value of `gt` is larger than a specified `lt` or
+    // `lte`, the range is reversed, and the field value must be outside the
+    // specified range. If the field value doesn't meet the required conditions,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MyFloat {
+    //   // must be greater than 5.0 [float.gt]
+    //   float value = 1 [(buf.validate.field).float.gt = 5.0];
+    //
+    //   // must be greater than 5 and less than 10.0 [float.gt_lt]
+    //   float other_value = 2 [(buf.validate.field).float = { gt: 5.0, lt: 10.0 }];
+    //
+    //   // must be greater than 10 or less than 5.0 [float.gt_lt_exclusive]
+    //   float another_value = 3 [(buf.validate.field).float = { gt: 10.0, lt: 5.0 }];
+    // }
+    // ```
+    float gt = 4 [
+      (predefined).cel = {
+        id: "float.gt"
+        expression:
+          "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this <= rules.gt)"
+          "? 'must be greater than %s'.format([rules.gt]) : ''"
+      },
+      (predefined).cel = {
+        id: "float.gt_lt"
+        expression:
+          "has(rules.lt) && rules.lt >= rules.gt && (this.isNan() || this >= rules.lt || this <= rules.gt)"
+          "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "float.gt_lt_exclusive"
+        expression:
+          "has(rules.lt) && rules.lt < rules.gt && (this.isNan() || (rules.lt <= this && this <= rules.gt))"
+          "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "float.gt_lte"
+        expression:
+          "has(rules.lte) && rules.lte >= rules.gt && (this.isNan() || this > rules.lte || this <= rules.gt)"
+          "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
+      },
+      (predefined).cel = {
+        id: "float.gt_lte_exclusive"
+        expression:
+          "has(rules.lte) && rules.lte < rules.gt && (this.isNan() || (rules.lte < this && this <= rules.gt))"
+          "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
+      }
+    ];
+
+    // `gte` requires the field value to be greater than or equal to the specified
+    // value (exclusive). If the value of `gte` is larger than a specified `lt`
+    // or `lte`, the range is reversed, and the field value must be outside the
+    // specified range. If the field value doesn't meet the required conditions,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MyFloat {
+    //   // must be greater than or equal to 5.0 [float.gte]
+    //   float value = 1 [(buf.validate.field).float.gte = 5.0];
+    //
+    //   // must be greater than or equal to 5.0 and less than 10.0 [float.gte_lt]
+    //   float other_value = 2 [(buf.validate.field).float = { gte: 5.0, lt: 10.0 }];
+    //
+    //   // must be greater than or equal to 10.0 or less than 5.0 [float.gte_lt_exclusive]
+    //   float another_value = 3 [(buf.validate.field).float = { gte: 10.0, lt: 5.0 }];
+    // }
+    // ```
+    float gte = 5 [
+      (predefined).cel = {
+        id: "float.gte"
+        expression:
+          "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this < rules.gte)"
+          "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
+      },
+      (predefined).cel = {
+        id: "float.gte_lt"
+        expression:
+          "has(rules.lt) && rules.lt >= rules.gte && (this.isNan() || this >= rules.lt || this < rules.gte)"
+          "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "float.gte_lt_exclusive"
+        expression:
+          "has(rules.lt) && rules.lt < rules.gte && (this.isNan() || (rules.lt <= this && this < rules.gte))"
+          "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "float.gte_lte"
+        expression:
+          "has(rules.lte) && rules.lte >= rules.gte && (this.isNan() || this > rules.lte || this < rules.gte)"
+          "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
+      },
+      (predefined).cel = {
+        id: "float.gte_lte_exclusive"
+        expression:
+          "has(rules.lte) && rules.lte < rules.gte && (this.isNan() || (rules.lte < this && this < rules.gte))"
+          "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
+      }
+    ];
+  }
+
+  // `in` requires the field value to be equal to one of the specified values.
+  // If the field value isn't one of the specified values, an error message
+  // is generated.
+  //
+  // ```proto
+  // message MyFloat {
+  //   // must be in list [1.0, 2.0, 3.0]
+  //   float value = 1 [(buf.validate.field).float = { in: [1.0, 2.0, 3.0] }];
+  // }
+  // ```
+  repeated float in = 6 [(predefined).cel = {
+    id: "float.in"
+    expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
+  }];
+
+  // `not_in` requires the field value to not be equal to any of the specified
+  // values. If the field value is one of the specified values, an error
+  // message is generated.
+  //
+  // ```proto
+  // message MyFloat {
+  //   // value must not be in list [1.0, 2.0, 3.0]
+  //   float value = 1 [(buf.validate.field).float = { not_in: [1.0, 2.0, 3.0] }];
+  // }
+  // ```
+  repeated float not_in = 7 [(predefined).cel = {
+    id: "float.not_in"
+    expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
+  }];
+
+  // `finite` requires the field value to be finite. If the field value is
+  // infinite or NaN, an error message is generated.
+  optional bool finite = 8 [(predefined).cel = {
+    id: "float.finite"
+    expression: "rules.finite ? (this.isNan() || this.isInf() ? 'must be finite' : '') : ''"
+  }];
+
+  // `example` specifies values that the field may have. These values SHOULD
+  // conform to other rules. `example` values will not impact validation
+  // but may be used as helpful guidance on how to populate the given field.
+  //
+  // ```proto
+  // message MyFloat {
+  //   float value = 1 [
+  //     (buf.validate.field).float.example = 1.0,
+  //     (buf.validate.field).float.example = inf
+  //   ];
+  // }
+  // ```
+  repeated float example = 9 [(predefined).cel = {
+    id: "float.example"
+    expression: "true"
+  }];
+
+  // Extension fields that have the (buf.validate.predefined) option set
+  // will be treated as predefined field rules.
+  // See https://protovalidate.com/schemas/predefined-rules/
+  extensions 1000 to max;
+}
+
+// DoubleRules describes the rules applied to `double` values. These
+// rules may also be applied to the `google.protobuf.DoubleValue` Well-Known-Type.
+message DoubleRules {
+  // `const` requires the field value to exactly match the specified value. If
+  // the field value doesn't match, an error message is generated.
+  //
+  // ```proto
+  // message MyDouble {
+  //   // value must equal 42.0
+  //   double value = 1 [(buf.validate.field).double.const = 42.0];
+  // }
+  // ```
+  optional double const = 1 [(predefined).cel = {
+    id: "double.const"
+    expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
+  }];
+  oneof less_than {
+    // `lt` requires the field value to be less than the specified value (field <
+    // value). If the field value is equal to or greater than the specified
+    // value, an error message is generated.
+    //
+    // ```proto
+    // message MyDouble {
+    //   // must be less than 10.0
+    //   double value = 1 [(buf.validate.field).double.lt = 10.0];
+    // }
+    // ```
+    double lt = 2 [(predefined).cel = {
+      id: "double.lt"
+      expression:
+        "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this >= rules.lt)"
+        "? 'must be less than %s'.format([rules.lt]) : ''"
+    }];
+
+    // `lte` requires the field value to be less than or equal to the specified value
+    // (field <= value). If the field value is greater than the specified value,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MyDouble {
+    //   // must be less than or equal to 10.0
+    //   double value = 1 [(buf.validate.field).double.lte = 10.0];
+    // }
+    // ```
+    double lte = 3 [(predefined).cel = {
+      id: "double.lte"
+      expression:
+        "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this > rules.lte)"
+        "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
+    }];
+  }
+  oneof greater_than {
+    // `gt` requires the field value to be greater than the specified value
+    // (exclusive). If the value of `gt` is larger than a specified `lt` or `lte`,
+    // the range is reversed, and the field value must be outside the specified
+    // range. If the field value doesn't meet the required conditions, an error
+    // message is generated.
+    //
+    // ```proto
+    // message MyDouble {
+    //   // must be greater than 5.0 [double.gt]
+    //   double value = 1 [(buf.validate.field).double.gt = 5.0];
+    //
+    //   // must be greater than 5 and less than 10.0 [double.gt_lt]
+    //   double other_value = 2 [(buf.validate.field).double = { gt: 5.0, lt: 10.0 }];
+    //
+    //   // must be greater than 10 or less than 5.0 [double.gt_lt_exclusive]
+    //   double another_value = 3 [(buf.validate.field).double = { gt: 10.0, lt: 5.0 }];
+    // }
+    // ```
+    double gt = 4 [
+      (predefined).cel = {
+        id: "double.gt"
+        expression:
+          "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this <= rules.gt)"
+          "? 'must be greater than %s'.format([rules.gt]) : ''"
+      },
+      (predefined).cel = {
+        id: "double.gt_lt"
+        expression:
+          "has(rules.lt) && rules.lt >= rules.gt && (this.isNan() || this >= rules.lt || this <= rules.gt)"
+          "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "double.gt_lt_exclusive"
+        expression:
+          "has(rules.lt) && rules.lt < rules.gt && (this.isNan() || (rules.lt <= this && this <= rules.gt))"
+          "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "double.gt_lte"
+        expression:
+          "has(rules.lte) && rules.lte >= rules.gt && (this.isNan() || this > rules.lte || this <= rules.gt)"
+          "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
+      },
+      (predefined).cel = {
+        id: "double.gt_lte_exclusive"
+        expression:
+          "has(rules.lte) && rules.lte < rules.gt && (this.isNan() || (rules.lte < this && this <= rules.gt))"
+          "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
+      }
+    ];
+
+    // `gte` requires the field value to be greater than or equal to the specified
+    // value (exclusive). If the value of `gte` is larger than a specified `lt` or
+    // `lte`, the range is reversed, and the field value must be outside the
+    // specified range. If the field value doesn't meet the required conditions,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MyDouble {
+    //   // must be greater than or equal to 5.0 [double.gte]
+    //   double value = 1 [(buf.validate.field).double.gte = 5.0];
+    //
+    //   // must be greater than or equal to 5.0 and less than 10.0 [double.gte_lt]
+    //   double other_value = 2 [(buf.validate.field).double = { gte: 5.0, lt: 10.0 }];
+    //
+    //   // must be greater than or equal to 10.0 or less than 5.0 [double.gte_lt_exclusive]
+    //   double another_value = 3 [(buf.validate.field).double = { gte: 10.0, lt: 5.0 }];
+    // }
+    // ```
+    double gte = 5 [
+      (predefined).cel = {
+        id: "double.gte"
+        expression:
+          "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this < rules.gte)"
+          "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
+      },
+      (predefined).cel = {
+        id: "double.gte_lt"
+        expression:
+          "has(rules.lt) && rules.lt >= rules.gte && (this.isNan() || this >= rules.lt || this < rules.gte)"
+          "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "double.gte_lt_exclusive"
+        expression:
+          "has(rules.lt) && rules.lt < rules.gte && (this.isNan() || (rules.lt <= this && this < rules.gte))"
+          "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "double.gte_lte"
+        expression:
+          "has(rules.lte) && rules.lte >= rules.gte && (this.isNan() || this > rules.lte || this < rules.gte)"
+          "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
+      },
+      (predefined).cel = {
+        id: "double.gte_lte_exclusive"
+        expression:
+          "has(rules.lte) && rules.lte < rules.gte && (this.isNan() || (rules.lte < this && this < rules.gte))"
+          "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
+      }
+    ];
+  }
+  // `in` requires the field value to be equal to one of the specified values.
+  // If the field value isn't one of the specified values, an error message is
+  // generated.
+  //
+  // ```proto
+  // message MyDouble {
+  //   // must be in list [1.0, 2.0, 3.0]
+  //   double value = 1 [(buf.validate.field).double = { in: [1.0, 2.0, 3.0] }];
+  // }
+  // ```
+  repeated double in = 6 [(predefined).cel = {
+    id: "double.in"
+    expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
+  }];
+
+  // `not_in` requires the field value to not be equal to any of the specified
+  // values. If the field value is one of the specified values, an error
+  // message is generated.
+  //
+  // ```proto
+  // message MyDouble {
+  //   // value must not be in list [1.0, 2.0, 3.0]
+  //   double value = 1 [(buf.validate.field).double = { not_in: [1.0, 2.0, 3.0] }];
+  // }
+  // ```
+  repeated double not_in = 7 [(predefined).cel = {
+    id: "double.not_in"
+    expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
+  }];
+
+  // `finite` requires the field value to be finite. If the field value is
+  // infinite or NaN, an error message is generated.
+  optional bool finite = 8 [(predefined).cel = {
+    id: "double.finite"
+    expression: "rules.finite ? (this.isNan() || this.isInf() ? 'must be finite' : '') : ''"
+  }];
+
+  // `example` specifies values that the field may have. These values SHOULD
+  // conform to other rules. `example` values will not impact validation
+  // but may be used as helpful guidance on how to populate the given field.
+  //
+  // ```proto
+  // message MyDouble {
+  //   double value = 1 [
+  //     (buf.validate.field).double.example = 1.0,
+  //     (buf.validate.field).double.example = inf
+  //   ];
+  // }
+  // ```
+  repeated double example = 9 [(predefined).cel = {
+    id: "double.example"
+    expression: "true"
+  }];
+
+  // Extension fields that have the (buf.validate.predefined) option set
+  // will be treated as predefined field rules.
+  // See https://protovalidate.com/schemas/predefined-rules/
+  extensions 1000 to max;
+}
+
+// Int32Rules describes the rules applied to `int32` values. These
+// rules may also be applied to the `google.protobuf.Int32Value` Well-Known-Type.
+message Int32Rules {
+  // `const` requires the field value to exactly match the specified value. If
+  // the field value doesn't match, an error message is generated.
+  //
+  // ```proto
+  // message MyInt32 {
+  //   // value must equal 42
+  //   int32 value = 1 [(buf.validate.field).int32.const = 42];
+  // }
+  // ```
+  optional int32 const = 1 [(predefined).cel = {
+    id: "int32.const"
+    expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
+  }];
+  oneof less_than {
+    // `lt` requires the field value to be less than the specified value (field
+    // < value). If the field value is equal to or greater than the specified
+    // value, an error message is generated.
+    //
+    // ```proto
+    // message MyInt32 {
+    //   // must be less than 10
+    //   int32 value = 1 [(buf.validate.field).int32.lt = 10];
+    // }
+    // ```
+    int32 lt = 2 [(predefined).cel = {
+      id: "int32.lt"
+      expression:
+        "!has(rules.gte) && !has(rules.gt) && this >= rules.lt"
+        "? 'must be less than %s'.format([rules.lt]) : ''"
+    }];
+
+    // `lte` requires the field value to be less than or equal to the specified
+    // value (field <= value). If the field value is greater than the specified
+    // value, an error message is generated.
+    //
+    // ```proto
+    // message MyInt32 {
+    //   // must be less than or equal to 10
+    //   int32 value = 1 [(buf.validate.field).int32.lte = 10];
+    // }
+    // ```
+    int32 lte = 3 [(predefined).cel = {
+      id: "int32.lte"
+      expression:
+        "!has(rules.gte) && !has(rules.gt) && this > rules.lte"
+        "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
+    }];
+  }
+  oneof greater_than {
+    // `gt` requires the field value to be greater than the specified value
+    // (exclusive). If the value of `gt` is larger than a specified `lt` or
+    // `lte`, the range is reversed, and the field value must be outside the
+    // specified range. If the field value doesn't meet the required conditions,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MyInt32 {
+    //   // must be greater than 5 [int32.gt]
+    //   int32 value = 1 [(buf.validate.field).int32.gt = 5];
+    //
+    //   // must be greater than 5 and less than 10 [int32.gt_lt]
+    //   int32 other_value = 2 [(buf.validate.field).int32 = { gt: 5, lt: 10 }];
+    //
+    //   // must be greater than 10 or less than 5 [int32.gt_lt_exclusive]
+    //   int32 another_value = 3 [(buf.validate.field).int32 = { gt: 10, lt: 5 }];
+    // }
+    // ```
+    int32 gt = 4 [
+      (predefined).cel = {
+        id: "int32.gt"
+        expression:
+          "!has(rules.lt) && !has(rules.lte) && this <= rules.gt"
+          "? 'must be greater than %s'.format([rules.gt]) : ''"
+      },
+      (predefined).cel = {
+        id: "int32.gt_lt"
+        expression:
+          "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)"
+          "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "int32.gt_lt_exclusive"
+        expression:
+          "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)"
+          "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "int32.gt_lte"
+        expression:
+          "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)"
+          "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
+      },
+      (predefined).cel = {
+        id: "int32.gt_lte_exclusive"
+        expression:
+          "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)"
+          "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
+      }
+    ];
+
+    // `gte` requires the field value to be greater than or equal to the specified value
+    // (exclusive). If the value of `gte` is larger than a specified `lt` or
+    // `lte`, the range is reversed, and the field value must be outside the
+    // specified range. If the field value doesn't meet the required conditions,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MyInt32 {
+    //   // must be greater than or equal to 5 [int32.gte]
+    //   int32 value = 1 [(buf.validate.field).int32.gte = 5];
+    //
+    //   // must be greater than or equal to 5 and less than 10 [int32.gte_lt]
+    //   int32 other_value = 2 [(buf.validate.field).int32 = { gte: 5, lt: 10 }];
+    //
+    //   // must be greater than or equal to 10 or less than 5 [int32.gte_lt_exclusive]
+    //   int32 another_value = 3 [(buf.validate.field).int32 = { gte: 10, lt: 5 }];
+    // }
+    // ```
+    int32 gte = 5 [
+      (predefined).cel = {
+        id: "int32.gte"
+        expression:
+          "!has(rules.lt) && !has(rules.lte) && this < rules.gte"
+          "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
+      },
+      (predefined).cel = {
+        id: "int32.gte_lt"
+        expression:
+          "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)"
+          "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "int32.gte_lt_exclusive"
+        expression:
+          "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)"
+          "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "int32.gte_lte"
+        expression:
+          "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)"
+          "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
+      },
+      (predefined).cel = {
+        id: "int32.gte_lte_exclusive"
+        expression:
+          "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)"
+          "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
+      }
+    ];
+  }
+
+  // `in` requires the field value to be equal to one of the specified values.
+  // If the field value isn't one of the specified values, an error message is
+  // generated.
+  //
+  // ```proto
+  // message MyInt32 {
+  //   // must be in list [1, 2, 3]
+  //   int32 value = 1 [(buf.validate.field).int32 = { in: [1, 2, 3] }];
+  // }
+  // ```
+  repeated int32 in = 6 [(predefined).cel = {
+    id: "int32.in"
+    expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
+  }];
+
+  // `not_in` requires the field value to not be equal to any of the specified
+  // values. If the field value is one of the specified values, an error message
+  // is generated.
+  //
+  // ```proto
+  // message MyInt32 {
+  //   // value must not be in list [1, 2, 3]
+  //   int32 value = 1 [(buf.validate.field).int32 = { not_in: [1, 2, 3] }];
+  // }
+  // ```
+  repeated int32 not_in = 7 [(predefined).cel = {
+    id: "int32.not_in"
+    expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
+  }];
+
+  // `example` specifies values that the field may have. These values SHOULD
+  // conform to other rules. `example` values will not impact validation
+  // but may be used as helpful guidance on how to populate the given field.
+  //
+  // ```proto
+  // message MyInt32 {
+  //   int32 value = 1 [
+  //     (buf.validate.field).int32.example = 1,
+  //     (buf.validate.field).int32.example = -10
+  //   ];
+  // }
+  // ```
+  repeated int32 example = 8 [(predefined).cel = {
+    id: "int32.example"
+    expression: "true"
+  }];
+
+  // Extension fields that have the (buf.validate.predefined) option set
+  // will be treated as predefined field rules.
+  // See https://protovalidate.com/schemas/predefined-rules/
+  extensions 1000 to max;
+}
+
+// Int64Rules describes the rules applied to `int64` values. These
+// rules may also be applied to the `google.protobuf.Int64Value` Well-Known-Type.
+message Int64Rules {
+  // `const` requires the field value to exactly match the specified value. If
+  // the field value doesn't match, an error message is generated.
+  //
+  // ```proto
+  // message MyInt64 {
+  //   // value must equal 42
+  //   int64 value = 1 [(buf.validate.field).int64.const = 42];
+  // }
+  // ```
+  optional int64 const = 1 [(predefined).cel = {
+    id: "int64.const"
+    expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
+  }];
+  oneof less_than {
+    // `lt` requires the field value to be less than the specified value (field <
+    // value). If the field value is equal to or greater than the specified value,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MyInt64 {
+    //   // must be less than 10
+    //   int64 value = 1 [(buf.validate.field).int64.lt = 10];
+    // }
+    // ```
+    int64 lt = 2 [(predefined).cel = {
+      id: "int64.lt"
+      expression:
+        "!has(rules.gte) && !has(rules.gt) && this >= rules.lt"
+        "? 'must be less than %s'.format([rules.lt]) : ''"
+    }];
+
+    // `lte` requires the field value to be less than or equal to the specified
+    // value (field <= value). If the field value is greater than the specified
+    // value, an error message is generated.
+    //
+    // ```proto
+    // message MyInt64 {
+    //   // must be less than or equal to 10
+    //   int64 value = 1 [(buf.validate.field).int64.lte = 10];
+    // }
+    // ```
+    int64 lte = 3 [(predefined).cel = {
+      id: "int64.lte"
+      expression:
+        "!has(rules.gte) && !has(rules.gt) && this > rules.lte"
+        "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
+    }];
+  }
+  oneof greater_than {
+    // `gt` requires the field value to be greater than the specified value
+    // (exclusive). If the value of `gt` is larger than a specified `lt` or
+    // `lte`, the range is reversed, and the field value must be outside the
+    // specified range. If the field value doesn't meet the required conditions,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MyInt64 {
+    //   // must be greater than 5 [int64.gt]
+    //   int64 value = 1 [(buf.validate.field).int64.gt = 5];
+    //
+    //   // must be greater than 5 and less than 10 [int64.gt_lt]
+    //   int64 other_value = 2 [(buf.validate.field).int64 = { gt: 5, lt: 10 }];
+    //
+    //   // must be greater than 10 or less than 5 [int64.gt_lt_exclusive]
+    //   int64 another_value = 3 [(buf.validate.field).int64 = { gt: 10, lt: 5 }];
+    // }
+    // ```
+    int64 gt = 4 [
+      (predefined).cel = {
+        id: "int64.gt"
+        expression:
+          "!has(rules.lt) && !has(rules.lte) && this <= rules.gt"
+          "? 'must be greater than %s'.format([rules.gt]) : ''"
+      },
+      (predefined).cel = {
+        id: "int64.gt_lt"
+        expression:
+          "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)"
+          "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "int64.gt_lt_exclusive"
+        expression:
+          "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)"
+          "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "int64.gt_lte"
+        expression:
+          "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)"
+          "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
+      },
+      (predefined).cel = {
+        id: "int64.gt_lte_exclusive"
+        expression:
+          "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)"
+          "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
+      }
+    ];
+
+    // `gte` requires the field value to be greater than or equal to the specified
+    // value (exclusive). If the value of `gte` is larger than a specified `lt`
+    // or `lte`, the range is reversed, and the field value must be outside the
+    // specified range. If the field value doesn't meet the required conditions,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MyInt64 {
+    //   // must be greater than or equal to 5 [int64.gte]
+    //   int64 value = 1 [(buf.validate.field).int64.gte = 5];
+    //
+    //   // must be greater than or equal to 5 and less than 10 [int64.gte_lt]
+    //   int64 other_value = 2 [(buf.validate.field).int64 = { gte: 5, lt: 10 }];
+    //
+    //   // must be greater than or equal to 10 or less than 5 [int64.gte_lt_exclusive]
+    //   int64 another_value = 3 [(buf.validate.field).int64 = { gte: 10, lt: 5 }];
+    // }
+    // ```
+    int64 gte = 5 [
+      (predefined).cel = {
+        id: "int64.gte"
+        expression:
+          "!has(rules.lt) && !has(rules.lte) && this < rules.gte"
+          "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
+      },
+      (predefined).cel = {
+        id: "int64.gte_lt"
+        expression:
+          "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)"
+          "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "int64.gte_lt_exclusive"
+        expression:
+          "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)"
+          "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "int64.gte_lte"
+        expression:
+          "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)"
+          "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
+      },
+      (predefined).cel = {
+        id: "int64.gte_lte_exclusive"
+        expression:
+          "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)"
+          "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
+      }
+    ];
+  }
+
+  // `in` requires the field value to be equal to one of the specified values.
+  // If the field value isn't one of the specified values, an error message is
+  // generated.
+  //
+  // ```proto
+  // message MyInt64 {
+  //   // must be in list [1, 2, 3]
+  //   int64 value = 1 [(buf.validate.field).int64 = { in: [1, 2, 3] }];
+  // }
+  // ```
+  repeated int64 in = 6 [(predefined).cel = {
+    id: "int64.in"
+    expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
+  }];
+
+  // `not_in` requires the field value to not be equal to any of the specified
+  // values. If the field value is one of the specified values, an error
+  // message is generated.
+  //
+  // ```proto
+  // message MyInt64 {
+  //   // value must not be in list [1, 2, 3]
+  //   int64 value = 1 [(buf.validate.field).int64 = { not_in: [1, 2, 3] }];
+  // }
+  // ```
+  repeated int64 not_in = 7 [(predefined).cel = {
+    id: "int64.not_in"
+    expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
+  }];
+
+  // `example` specifies values that the field may have. These values SHOULD
+  // conform to other rules. `example` values will not impact validation
+  // but may be used as helpful guidance on how to populate the given field.
+  //
+  // ```proto
+  // message MyInt64 {
+  //   int64 value = 1 [
+  //     (buf.validate.field).int64.example = 1,
+  //     (buf.validate.field).int64.example = -10
+  //   ];
+  // }
+  // ```
+  repeated int64 example = 9 [(predefined).cel = {
+    id: "int64.example"
+    expression: "true"
+  }];
+
+  // Extension fields that have the (buf.validate.predefined) option set
+  // will be treated as predefined field rules.
+  // See https://protovalidate.com/schemas/predefined-rules/
+  extensions 1000 to max;
+}
+
+// UInt32Rules describes the rules applied to `uint32` values. These
+// rules may also be applied to the `google.protobuf.UInt32Value` Well-Known-Type.
+message UInt32Rules {
+  // `const` requires the field value to exactly match the specified value. If
+  // the field value doesn't match, an error message is generated.
+  //
+  // ```proto
+  // message MyUInt32 {
+  //   // value must equal 42
+  //   uint32 value = 1 [(buf.validate.field).uint32.const = 42];
+  // }
+  // ```
+  optional uint32 const = 1 [(predefined).cel = {
+    id: "uint32.const"
+    expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
+  }];
+  oneof less_than {
+    // `lt` requires the field value to be less than the specified value (field <
+    // value). If the field value is equal to or greater than the specified value,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MyUInt32 {
+    //   // must be less than 10
+    //   uint32 value = 1 [(buf.validate.field).uint32.lt = 10];
+    // }
+    // ```
+    uint32 lt = 2 [(predefined).cel = {
+      id: "uint32.lt"
+      expression:
+        "!has(rules.gte) && !has(rules.gt) && this >= rules.lt"
+        "? 'must be less than %s'.format([rules.lt]) : ''"
+    }];
+
+    // `lte` requires the field value to be less than or equal to the specified
+    // value (field <= value). If the field value is greater than the specified
+    // value, an error message is generated.
+    //
+    // ```proto
+    // message MyUInt32 {
+    //   // must be less than or equal to 10
+    //   uint32 value = 1 [(buf.validate.field).uint32.lte = 10];
+    // }
+    // ```
+    uint32 lte = 3 [(predefined).cel = {
+      id: "uint32.lte"
+      expression:
+        "!has(rules.gte) && !has(rules.gt) && this > rules.lte"
+        "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
+    }];
+  }
+  oneof greater_than {
+    // `gt` requires the field value to be greater than the specified value
+    // (exclusive). If the value of `gt` is larger than a specified `lt` or
+    // `lte`, the range is reversed, and the field value must be outside the
+    // specified range. If the field value doesn't meet the required conditions,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MyUInt32 {
+    //   // must be greater than 5 [uint32.gt]
+    //   uint32 value = 1 [(buf.validate.field).uint32.gt = 5];
+    //
+    //   // must be greater than 5 and less than 10 [uint32.gt_lt]
+    //   uint32 other_value = 2 [(buf.validate.field).uint32 = { gt: 5, lt: 10 }];
+    //
+    //   // must be greater than 10 or less than 5 [uint32.gt_lt_exclusive]
+    //   uint32 another_value = 3 [(buf.validate.field).uint32 = { gt: 10, lt: 5 }];
+    // }
+    // ```
+    uint32 gt = 4 [
+      (predefined).cel = {
+        id: "uint32.gt"
+        expression:
+          "!has(rules.lt) && !has(rules.lte) && this <= rules.gt"
+          "? 'must be greater than %s'.format([rules.gt]) : ''"
+      },
+      (predefined).cel = {
+        id: "uint32.gt_lt"
+        expression:
+          "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)"
+          "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "uint32.gt_lt_exclusive"
+        expression:
+          "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)"
+          "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "uint32.gt_lte"
+        expression:
+          "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)"
+          "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
+      },
+      (predefined).cel = {
+        id: "uint32.gt_lte_exclusive"
+        expression:
+          "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)"
+          "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
+      }
+    ];
+
+    // `gte` requires the field value to be greater than or equal to the specified
+    // value (exclusive). If the value of `gte` is larger than a specified `lt`
+    // or `lte`, the range is reversed, and the field value must be outside the
+    // specified range. If the field value doesn't meet the required conditions,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MyUInt32 {
+    //   // must be greater than or equal to 5 [uint32.gte]
+    //   uint32 value = 1 [(buf.validate.field).uint32.gte = 5];
+    //
+    //   // must be greater than or equal to 5 and less than 10 [uint32.gte_lt]
+    //   uint32 other_value = 2 [(buf.validate.field).uint32 = { gte: 5, lt: 10 }];
+    //
+    //   // must be greater than or equal to 10 or less than 5 [uint32.gte_lt_exclusive]
+    //   uint32 another_value = 3 [(buf.validate.field).uint32 = { gte: 10, lt: 5 }];
+    // }
+    // ```
+    uint32 gte = 5 [
+      (predefined).cel = {
+        id: "uint32.gte"
+        expression:
+          "!has(rules.lt) && !has(rules.lte) && this < rules.gte"
+          "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
+      },
+      (predefined).cel = {
+        id: "uint32.gte_lt"
+        expression:
+          "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)"
+          "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "uint32.gte_lt_exclusive"
+        expression:
+          "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)"
+          "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "uint32.gte_lte"
+        expression:
+          "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)"
+          "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
+      },
+      (predefined).cel = {
+        id: "uint32.gte_lte_exclusive"
+        expression:
+          "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)"
+          "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
+      }
+    ];
+  }
+
+  // `in` requires the field value to be equal to one of the specified values.
+  // If the field value isn't one of the specified values, an error message is
+  // generated.
+  //
+  // ```proto
+  // message MyUInt32 {
+  //   // must be in list [1, 2, 3]
+  //   uint32 value = 1 [(buf.validate.field).uint32 = { in: [1, 2, 3] }];
+  // }
+  // ```
+  repeated uint32 in = 6 [(predefined).cel = {
+    id: "uint32.in"
+    expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
+  }];
+
+  // `not_in` requires the field value to not be equal to any of the specified
+  // values. If the field value is one of the specified values, an error
+  // message is generated.
+  //
+  // ```proto
+  // message MyUInt32 {
+  //   // value must not be in list [1, 2, 3]
+  //   uint32 value = 1 [(buf.validate.field).uint32 = { not_in: [1, 2, 3] }];
+  // }
+  // ```
+  repeated uint32 not_in = 7 [(predefined).cel = {
+    id: "uint32.not_in"
+    expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
+  }];
+
+  // `example` specifies values that the field may have. These values SHOULD
+  // conform to other rules. `example` values will not impact validation
+  // but may be used as helpful guidance on how to populate the given field.
+  //
+  // ```proto
+  // message MyUInt32 {
+  //   uint32 value = 1 [
+  //     (buf.validate.field).uint32.example = 1,
+  //     (buf.validate.field).uint32.example = 10
+  //   ];
+  // }
+  // ```
+  repeated uint32 example = 8 [(predefined).cel = {
+    id: "uint32.example"
+    expression: "true"
+  }];
+
+  // Extension fields that have the (buf.validate.predefined) option set
+  // will be treated as predefined field rules.
+  // See https://protovalidate.com/schemas/predefined-rules/
+  extensions 1000 to max;
+}
+
+// UInt64Rules describes the rules applied to `uint64` values. These
+// rules may also be applied to the `google.protobuf.UInt64Value` Well-Known-Type.
+message UInt64Rules {
+  // `const` requires the field value to exactly match the specified value. If
+  // the field value doesn't match, an error message is generated.
+  //
+  // ```proto
+  // message MyUInt64 {
+  //   // value must equal 42
+  //   uint64 value = 1 [(buf.validate.field).uint64.const = 42];
+  // }
+  // ```
+  optional uint64 const = 1 [(predefined).cel = {
+    id: "uint64.const"
+    expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
+  }];
+  oneof less_than {
+    // `lt` requires the field value to be less than the specified value (field <
+    // value). If the field value is equal to or greater than the specified value,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MyUInt64 {
+    //   // must be less than 10
+    //   uint64 value = 1 [(buf.validate.field).uint64.lt = 10];
+    // }
+    // ```
+    uint64 lt = 2 [(predefined).cel = {
+      id: "uint64.lt"
+      expression:
+        "!has(rules.gte) && !has(rules.gt) && this >= rules.lt"
+        "? 'must be less than %s'.format([rules.lt]) : ''"
+    }];
+
+    // `lte` requires the field value to be less than or equal to the specified
+    // value (field <= value). If the field value is greater than the specified
+    // value, an error message is generated.
+    //
+    // ```proto
+    // message MyUInt64 {
+    //   // must be less than or equal to 10
+    //   uint64 value = 1 [(buf.validate.field).uint64.lte = 10];
+    // }
+    // ```
+    uint64 lte = 3 [(predefined).cel = {
+      id: "uint64.lte"
+      expression:
+        "!has(rules.gte) && !has(rules.gt) && this > rules.lte"
+        "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
+    }];
+  }
+  oneof greater_than {
+    // `gt` requires the field value to be greater than the specified value
+    // (exclusive). If the value of `gt` is larger than a specified `lt` or
+    // `lte`, the range is reversed, and the field value must be outside the
+    // specified range. If the field value doesn't meet the required conditions,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MyUInt64 {
+    //   // must be greater than 5 [uint64.gt]
+    //   uint64 value = 1 [(buf.validate.field).uint64.gt = 5];
+    //
+    //   // must be greater than 5 and less than 10 [uint64.gt_lt]
+    //   uint64 other_value = 2 [(buf.validate.field).uint64 = { gt: 5, lt: 10 }];
+    //
+    //   // must be greater than 10 or less than 5 [uint64.gt_lt_exclusive]
+    //   uint64 another_value = 3 [(buf.validate.field).uint64 = { gt: 10, lt: 5 }];
+    // }
+    // ```
+    uint64 gt = 4 [
+      (predefined).cel = {
+        id: "uint64.gt"
+        expression:
+          "!has(rules.lt) && !has(rules.lte) && this <= rules.gt"
+          "? 'must be greater than %s'.format([rules.gt]) : ''"
+      },
+      (predefined).cel = {
+        id: "uint64.gt_lt"
+        expression:
+          "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)"
+          "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "uint64.gt_lt_exclusive"
+        expression:
+          "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)"
+          "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "uint64.gt_lte"
+        expression:
+          "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)"
+          "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
+      },
+      (predefined).cel = {
+        id: "uint64.gt_lte_exclusive"
+        expression:
+          "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)"
+          "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
+      }
+    ];
+
+    // `gte` requires the field value to be greater than or equal to the specified
+    // value (exclusive). If the value of `gte` is larger than a specified `lt`
+    // or `lte`, the range is reversed, and the field value must be outside the
+    // specified range. If the field value doesn't meet the required conditions,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MyUInt64 {
+    //   // must be greater than or equal to 5 [uint64.gte]
+    //   uint64 value = 1 [(buf.validate.field).uint64.gte = 5];
+    //
+    //   // must be greater than or equal to 5 and less than 10 [uint64.gte_lt]
+    //   uint64 other_value = 2 [(buf.validate.field).uint64 = { gte: 5, lt: 10 }];
+    //
+    //   // must be greater than or equal to 10 or less than 5 [uint64.gte_lt_exclusive]
+    //   uint64 another_value = 3 [(buf.validate.field).uint64 = { gte: 10, lt: 5 }];
+    // }
+    // ```
+    uint64 gte = 5 [
+      (predefined).cel = {
+        id: "uint64.gte"
+        expression:
+          "!has(rules.lt) && !has(rules.lte) && this < rules.gte"
+          "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
+      },
+      (predefined).cel = {
+        id: "uint64.gte_lt"
+        expression:
+          "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)"
+          "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "uint64.gte_lt_exclusive"
+        expression:
+          "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)"
+          "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "uint64.gte_lte"
+        expression:
+          "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)"
+          "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
+      },
+      (predefined).cel = {
+        id: "uint64.gte_lte_exclusive"
+        expression:
+          "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)"
+          "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
+      }
+    ];
+  }
+  // `in` requires the field value to be equal to one of the specified values.
+  // If the field value isn't one of the specified values, an error message is
+  // generated.
+  //
+  // ```proto
+  // message MyUInt64 {
+  //   // must be in list [1, 2, 3]
+  //   uint64 value = 1 [(buf.validate.field).uint64 = { in: [1, 2, 3] }];
+  // }
+  // ```
+  repeated uint64 in = 6 [(predefined).cel = {
+    id: "uint64.in"
+    expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
+  }];
+
+  // `not_in` requires the field value to not be equal to any of the specified
+  // values. If the field value is one of the specified values, an error
+  // message is generated.
+  //
+  // ```proto
+  // message MyUInt64 {
+  //   // value must not be in list [1, 2, 3]
+  //   uint64 value = 1 [(buf.validate.field).uint64 = { not_in: [1, 2, 3] }];
+  // }
+  // ```
+  repeated uint64 not_in = 7 [(predefined).cel = {
+    id: "uint64.not_in"
+    expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
+  }];
+
+  // `example` specifies values that the field may have. These values SHOULD
+  // conform to other rules. `example` values will not impact validation
+  // but may be used as helpful guidance on how to populate the given field.
+  //
+  // ```proto
+  // message MyUInt64 {
+  //   uint64 value = 1 [
+  //     (buf.validate.field).uint64.example = 1,
+  //     (buf.validate.field).uint64.example = -10
+  //   ];
+  // }
+  // ```
+  repeated uint64 example = 8 [(predefined).cel = {
+    id: "uint64.example"
+    expression: "true"
+  }];
+
+  // Extension fields that have the (buf.validate.predefined) option set
+  // will be treated as predefined field rules.
+  // See https://protovalidate.com/schemas/predefined-rules/
+  extensions 1000 to max;
+}
+
+// SInt32Rules describes the rules applied to `sint32` values.
+message SInt32Rules {
+  // `const` requires the field value to exactly match the specified value. If
+  // the field value doesn't match, an error message is generated.
+  //
+  // ```proto
+  // message MySInt32 {
+  //   // value must equal 42
+  //   sint32 value = 1 [(buf.validate.field).sint32.const = 42];
+  // }
+  // ```
+  optional sint32 const = 1 [(predefined).cel = {
+    id: "sint32.const"
+    expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
+  }];
+  oneof less_than {
+    // `lt` requires the field value to be less than the specified value (field
+    // < value). If the field value is equal to or greater than the specified
+    // value, an error message is generated.
+    //
+    // ```proto
+    // message MySInt32 {
+    //   // must be less than 10
+    //   sint32 value = 1 [(buf.validate.field).sint32.lt = 10];
+    // }
+    // ```
+    sint32 lt = 2 [(predefined).cel = {
+      id: "sint32.lt"
+      expression:
+        "!has(rules.gte) && !has(rules.gt) && this >= rules.lt"
+        "? 'must be less than %s'.format([rules.lt]) : ''"
+    }];
+
+    // `lte` requires the field value to be less than or equal to the specified
+    // value (field <= value). If the field value is greater than the specified
+    // value, an error message is generated.
+    //
+    // ```proto
+    // message MySInt32 {
+    //   // must be less than or equal to 10
+    //   sint32 value = 1 [(buf.validate.field).sint32.lte = 10];
+    // }
+    // ```
+    sint32 lte = 3 [(predefined).cel = {
+      id: "sint32.lte"
+      expression:
+        "!has(rules.gte) && !has(rules.gt) && this > rules.lte"
+        "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
+    }];
+  }
+  oneof greater_than {
+    // `gt` requires the field value to be greater than the specified value
+    // (exclusive). If the value of `gt` is larger than a specified `lt` or
+    // `lte`, the range is reversed, and the field value must be outside the
+    // specified range. If the field value doesn't meet the required conditions,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MySInt32 {
+    //   // must be greater than 5 [sint32.gt]
+    //   sint32 value = 1 [(buf.validate.field).sint32.gt = 5];
+    //
+    //   // must be greater than 5 and less than 10 [sint32.gt_lt]
+    //   sint32 other_value = 2 [(buf.validate.field).sint32 = { gt: 5, lt: 10 }];
+    //
+    //   // must be greater than 10 or less than 5 [sint32.gt_lt_exclusive]
+    //   sint32 another_value = 3 [(buf.validate.field).sint32 = { gt: 10, lt: 5 }];
+    // }
+    // ```
+    sint32 gt = 4 [
+      (predefined).cel = {
+        id: "sint32.gt"
+        expression:
+          "!has(rules.lt) && !has(rules.lte) && this <= rules.gt"
+          "? 'must be greater than %s'.format([rules.gt]) : ''"
+      },
+      (predefined).cel = {
+        id: "sint32.gt_lt"
+        expression:
+          "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)"
+          "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "sint32.gt_lt_exclusive"
+        expression:
+          "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)"
+          "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "sint32.gt_lte"
+        expression:
+          "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)"
+          "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
+      },
+      (predefined).cel = {
+        id: "sint32.gt_lte_exclusive"
+        expression:
+          "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)"
+          "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
+      }
+    ];
+
+    // `gte` requires the field value to be greater than or equal to the specified
+    // value (exclusive). If the value of `gte` is larger than a specified `lt`
+    // or `lte`, the range is reversed, and the field value must be outside the
+    // specified range. If the field value doesn't meet the required conditions,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MySInt32 {
+    //  // must be greater than or equal to 5 [sint32.gte]
+    //  sint32 value = 1 [(buf.validate.field).sint32.gte = 5];
+    //
+    //  // must be greater than or equal to 5 and less than 10 [sint32.gte_lt]
+    //  sint32 other_value = 2 [(buf.validate.field).sint32 = { gte: 5, lt: 10 }];
+    //
+    //  // must be greater than or equal to 10 or less than 5 [sint32.gte_lt_exclusive]
+    //  sint32 another_value = 3 [(buf.validate.field).sint32 = { gte: 10, lt: 5 }];
+    // }
+    // ```
+    sint32 gte = 5 [
+      (predefined).cel = {
+        id: "sint32.gte"
+        expression:
+          "!has(rules.lt) && !has(rules.lte) && this < rules.gte"
+          "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
+      },
+      (predefined).cel = {
+        id: "sint32.gte_lt"
+        expression:
+          "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)"
+          "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "sint32.gte_lt_exclusive"
+        expression:
+          "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)"
+          "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "sint32.gte_lte"
+        expression:
+          "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)"
+          "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
+      },
+      (predefined).cel = {
+        id: "sint32.gte_lte_exclusive"
+        expression:
+          "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)"
+          "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
+      }
+    ];
+  }
+
+  // `in` requires the field value to be equal to one of the specified values.
+  // If the field value isn't one of the specified values, an error message is
+  // generated.
+  //
+  // ```proto
+  // message MySInt32 {
+  //   // must be in list [1, 2, 3]
+  //   sint32 value = 1 [(buf.validate.field).sint32 = { in: [1, 2, 3] }];
+  // }
+  // ```
+  repeated sint32 in = 6 [(predefined).cel = {
+    id: "sint32.in"
+    expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
+  }];
+
+  // `not_in` requires the field value to not be equal to any of the specified
+  // values. If the field value is one of the specified values, an error
+  // message is generated.
+  //
+  // ```proto
+  // message MySInt32 {
+  //   // value must not be in list [1, 2, 3]
+  //   sint32 value = 1 [(buf.validate.field).sint32 = { not_in: [1, 2, 3] }];
+  // }
+  // ```
+  repeated sint32 not_in = 7 [(predefined).cel = {
+    id: "sint32.not_in"
+    expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
+  }];
+
+  // `example` specifies values that the field may have. These values SHOULD
+  // conform to other rules. `example` values will not impact validation
+  // but may be used as helpful guidance on how to populate the given field.
+  //
+  // ```proto
+  // message MySInt32 {
+  //   sint32 value = 1 [
+  //     (buf.validate.field).sint32.example = 1,
+  //     (buf.validate.field).sint32.example = -10
+  //   ];
+  // }
+  // ```
+  repeated sint32 example = 8 [(predefined).cel = {
+    id: "sint32.example"
+    expression: "true"
+  }];
+
+  // Extension fields that have the (buf.validate.predefined) option set
+  // will be treated as predefined field rules.
+  // See https://protovalidate.com/schemas/predefined-rules/
+  extensions 1000 to max;
+}
+
+// SInt64Rules describes the rules applied to `sint64` values.
+message SInt64Rules {
+  // `const` requires the field value to exactly match the specified value. If
+  // the field value doesn't match, an error message is generated.
+  //
+  // ```proto
+  // message MySInt64 {
+  //   // value must equal 42
+  //   sint64 value = 1 [(buf.validate.field).sint64.const = 42];
+  // }
+  // ```
+  optional sint64 const = 1 [(predefined).cel = {
+    id: "sint64.const"
+    expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
+  }];
+  oneof less_than {
+    // `lt` requires the field value to be less than the specified value (field
+    // < value). If the field value is equal to or greater than the specified
+    // value, an error message is generated.
+    //
+    // ```proto
+    // message MySInt64 {
+    //   // must be less than 10
+    //   sint64 value = 1 [(buf.validate.field).sint64.lt = 10];
+    // }
+    // ```
+    sint64 lt = 2 [(predefined).cel = {
+      id: "sint64.lt"
+      expression:
+        "!has(rules.gte) && !has(rules.gt) && this >= rules.lt"
+        "? 'must be less than %s'.format([rules.lt]) : ''"
+    }];
+
+    // `lte` requires the field value to be less than or equal to the specified
+    // value (field <= value). If the field value is greater than the specified
+    // value, an error message is generated.
+    //
+    // ```proto
+    // message MySInt64 {
+    //   // must be less than or equal to 10
+    //   sint64 value = 1 [(buf.validate.field).sint64.lte = 10];
+    // }
+    // ```
+    sint64 lte = 3 [(predefined).cel = {
+      id: "sint64.lte"
+      expression:
+        "!has(rules.gte) && !has(rules.gt) && this > rules.lte"
+        "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
+    }];
+  }
+  oneof greater_than {
+    // `gt` requires the field value to be greater than the specified value
+    // (exclusive). If the value of `gt` is larger than a specified `lt` or
+    // `lte`, the range is reversed, and the field value must be outside the
+    // specified range. If the field value doesn't meet the required conditions,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MySInt64 {
+    //   // must be greater than 5 [sint64.gt]
+    //   sint64 value = 1 [(buf.validate.field).sint64.gt = 5];
+    //
+    //   // must be greater than 5 and less than 10 [sint64.gt_lt]
+    //   sint64 other_value = 2 [(buf.validate.field).sint64 = { gt: 5, lt: 10 }];
+    //
+    //   // must be greater than 10 or less than 5 [sint64.gt_lt_exclusive]
+    //   sint64 another_value = 3 [(buf.validate.field).sint64 = { gt: 10, lt: 5 }];
+    // }
+    // ```
+    sint64 gt = 4 [
+      (predefined).cel = {
+        id: "sint64.gt"
+        expression:
+          "!has(rules.lt) && !has(rules.lte) && this <= rules.gt"
+          "? 'must be greater than %s'.format([rules.gt]) : ''"
+      },
+      (predefined).cel = {
+        id: "sint64.gt_lt"
+        expression:
+          "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)"
+          "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "sint64.gt_lt_exclusive"
+        expression:
+          "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)"
+          "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "sint64.gt_lte"
+        expression:
+          "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)"
+          "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
+      },
+      (predefined).cel = {
+        id: "sint64.gt_lte_exclusive"
+        expression:
+          "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)"
+          "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
+      }
+    ];
+
+    // `gte` requires the field value to be greater than or equal to the specified
+    // value (exclusive). If the value of `gte` is larger than a specified `lt`
+    // or `lte`, the range is reversed, and the field value must be outside the
+    // specified range. If the field value doesn't meet the required conditions,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MySInt64 {
+    //   // must be greater than or equal to 5 [sint64.gte]
+    //   sint64 value = 1 [(buf.validate.field).sint64.gte = 5];
+    //
+    //   // must be greater than or equal to 5 and less than 10 [sint64.gte_lt]
+    //   sint64 other_value = 2 [(buf.validate.field).sint64 = { gte: 5, lt: 10 }];
+    //
+    //   // must be greater than or equal to 10 or less than 5 [sint64.gte_lt_exclusive]
+    //   sint64 another_value = 3 [(buf.validate.field).sint64 = { gte: 10, lt: 5 }];
+    // }
+    // ```
+    sint64 gte = 5 [
+      (predefined).cel = {
+        id: "sint64.gte"
+        expression:
+          "!has(rules.lt) && !has(rules.lte) && this < rules.gte"
+          "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
+      },
+      (predefined).cel = {
+        id: "sint64.gte_lt"
+        expression:
+          "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)"
+          "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "sint64.gte_lt_exclusive"
+        expression:
+          "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)"
+          "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "sint64.gte_lte"
+        expression:
+          "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)"
+          "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
+      },
+      (predefined).cel = {
+        id: "sint64.gte_lte_exclusive"
+        expression:
+          "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)"
+          "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
+      }
+    ];
+  }
+
+  // `in` requires the field value to be equal to one of the specified values.
+  // If the field value isn't one of the specified values, an error message
+  // is generated.
+  //
+  // ```proto
+  // message MySInt64 {
+  //   // must be in list [1, 2, 3]
+  //   sint64 value = 1 [(buf.validate.field).sint64 = { in: [1, 2, 3] }];
+  // }
+  // ```
+  repeated sint64 in = 6 [(predefined).cel = {
+    id: "sint64.in"
+    expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
+  }];
+
+  // `not_in` requires the field value to not be equal to any of the specified
+  // values. If the field value is one of the specified values, an error
+  // message is generated.
+  //
+  // ```proto
+  // message MySInt64 {
+  //   // value must not be in list [1, 2, 3]
+  //   sint64 value = 1 [(buf.validate.field).sint64 = { not_in: [1, 2, 3] }];
+  // }
+  // ```
+  repeated sint64 not_in = 7 [(predefined).cel = {
+    id: "sint64.not_in"
+    expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
+  }];
+
+  // `example` specifies values that the field may have. These values SHOULD
+  // conform to other rules. `example` values will not impact validation
+  // but may be used as helpful guidance on how to populate the given field.
+  //
+  // ```proto
+  // message MySInt64 {
+  //   sint64 value = 1 [
+  //     (buf.validate.field).sint64.example = 1,
+  //     (buf.validate.field).sint64.example = -10
+  //   ];
+  // }
+  // ```
+  repeated sint64 example = 8 [(predefined).cel = {
+    id: "sint64.example"
+    expression: "true"
+  }];
+
+  // Extension fields that have the (buf.validate.predefined) option set
+  // will be treated as predefined field rules.
+  // See https://protovalidate.com/schemas/predefined-rules/
+  extensions 1000 to max;
+}
+
+// Fixed32Rules describes the rules applied to `fixed32` values.
+message Fixed32Rules {
+  // `const` requires the field value to exactly match the specified value.
+  // If the field value doesn't match, an error message is generated.
+  //
+  // ```proto
+  // message MyFixed32 {
+  //   // value must equal 42
+  //   fixed32 value = 1 [(buf.validate.field).fixed32.const = 42];
+  // }
+  // ```
+  optional fixed32 const = 1 [(predefined).cel = {
+    id: "fixed32.const"
+    expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
+  }];
+  oneof less_than {
+    // `lt` requires the field value to be less than the specified value (field <
+    // value). If the field value is equal to or greater than the specified value,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MyFixed32 {
+    //   // must be less than 10
+    //   fixed32 value = 1 [(buf.validate.field).fixed32.lt = 10];
+    // }
+    // ```
+    fixed32 lt = 2 [(predefined).cel = {
+      id: "fixed32.lt"
+      expression:
+        "!has(rules.gte) && !has(rules.gt) && this >= rules.lt"
+        "? 'must be less than %s'.format([rules.lt]) : ''"
+    }];
+
+    // `lte` requires the field value to be less than or equal to the specified
+    // value (field <= value). If the field value is greater than the specified
+    // value, an error message is generated.
+    //
+    // ```proto
+    // message MyFixed32 {
+    //   // must be less than or equal to 10
+    //   fixed32 value = 1 [(buf.validate.field).fixed32.lte = 10];
+    // }
+    // ```
+    fixed32 lte = 3 [(predefined).cel = {
+      id: "fixed32.lte"
+      expression:
+        "!has(rules.gte) && !has(rules.gt) && this > rules.lte"
+        "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
+    }];
+  }
+  oneof greater_than {
+    // `gt` requires the field value to be greater than the specified value
+    // (exclusive). If the value of `gt` is larger than a specified `lt` or
+    // `lte`, the range is reversed, and the field value must be outside the
+    // specified range. If the field value doesn't meet the required conditions,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MyFixed32 {
+    //   // must be greater than 5 [fixed32.gt]
+    //   fixed32 value = 1 [(buf.validate.field).fixed32.gt = 5];
+    //
+    //   // must be greater than 5 and less than 10 [fixed32.gt_lt]
+    //   fixed32 other_value = 2 [(buf.validate.field).fixed32 = { gt: 5, lt: 10 }];
+    //
+    //   // must be greater than 10 or less than 5 [fixed32.gt_lt_exclusive]
+    //   fixed32 another_value = 3 [(buf.validate.field).fixed32 = { gt: 10, lt: 5 }];
+    // }
+    // ```
+    fixed32 gt = 4 [
+      (predefined).cel = {
+        id: "fixed32.gt"
+        expression:
+          "!has(rules.lt) && !has(rules.lte) && this <= rules.gt"
+          "? 'must be greater than %s'.format([rules.gt]) : ''"
+      },
+      (predefined).cel = {
+        id: "fixed32.gt_lt"
+        expression:
+          "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)"
+          "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "fixed32.gt_lt_exclusive"
+        expression:
+          "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)"
+          "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "fixed32.gt_lte"
+        expression:
+          "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)"
+          "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
+      },
+      (predefined).cel = {
+        id: "fixed32.gt_lte_exclusive"
+        expression:
+          "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)"
+          "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
+      }
+    ];
+
+    // `gte` requires the field value to be greater than or equal to the specified
+    // value (exclusive). If the value of `gte` is larger than a specified `lt`
+    // or `lte`, the range is reversed, and the field value must be outside the
+    // specified range. If the field value doesn't meet the required conditions,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MyFixed32 {
+    //   // must be greater than or equal to 5 [fixed32.gte]
+    //   fixed32 value = 1 [(buf.validate.field).fixed32.gte = 5];
+    //
+    //   // must be greater than or equal to 5 and less than 10 [fixed32.gte_lt]
+    //   fixed32 other_value = 2 [(buf.validate.field).fixed32 = { gte: 5, lt: 10 }];
+    //
+    //   // must be greater than or equal to 10 or less than 5 [fixed32.gte_lt_exclusive]
+    //   fixed32 another_value = 3 [(buf.validate.field).fixed32 = { gte: 10, lt: 5 }];
+    // }
+    // ```
+    fixed32 gte = 5 [
+      (predefined).cel = {
+        id: "fixed32.gte"
+        expression:
+          "!has(rules.lt) && !has(rules.lte) && this < rules.gte"
+          "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
+      },
+      (predefined).cel = {
+        id: "fixed32.gte_lt"
+        expression:
+          "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)"
+          "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "fixed32.gte_lt_exclusive"
+        expression:
+          "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)"
+          "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "fixed32.gte_lte"
+        expression:
+          "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)"
+          "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
+      },
+      (predefined).cel = {
+        id: "fixed32.gte_lte_exclusive"
+        expression:
+          "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)"
+          "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
+      }
+    ];
+  }
+
+  // `in` requires the field value to be equal to one of the specified values.
+  // If the field value isn't one of the specified values, an error message
+  // is generated.
+  //
+  // ```proto
+  // message MyFixed32 {
+  //   // must be in list [1, 2, 3]
+  //   fixed32 value = 1 [(buf.validate.field).fixed32 = { in: [1, 2, 3] }];
+  // }
+  // ```
+  repeated fixed32 in = 6 [(predefined).cel = {
+    id: "fixed32.in"
+    expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
+  }];
+
+  // `not_in` requires the field value to not be equal to any of the specified
+  // values. If the field value is one of the specified values, an error
+  // message is generated.
+  //
+  // ```proto
+  // message MyFixed32 {
+  //   // value must not be in list [1, 2, 3]
+  //   fixed32 value = 1 [(buf.validate.field).fixed32 = { not_in: [1, 2, 3] }];
+  // }
+  // ```
+  repeated fixed32 not_in = 7 [(predefined).cel = {
+    id: "fixed32.not_in"
+    expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
+  }];
+
+  // `example` specifies values that the field may have. These values SHOULD
+  // conform to other rules. `example` values will not impact validation
+  // but may be used as helpful guidance on how to populate the given field.
+  //
+  // ```proto
+  // message MyFixed32 {
+  //   fixed32 value = 1 [
+  //     (buf.validate.field).fixed32.example = 1,
+  //     (buf.validate.field).fixed32.example = 2
+  //   ];
+  // }
+  // ```
+  repeated fixed32 example = 8 [(predefined).cel = {
+    id: "fixed32.example"
+    expression: "true"
+  }];
+
+  // Extension fields that have the (buf.validate.predefined) option set
+  // will be treated as predefined field rules.
+  // See https://protovalidate.com/schemas/predefined-rules/
+  extensions 1000 to max;
+}
+
+// Fixed64Rules describes the rules applied to `fixed64` values.
+message Fixed64Rules {
+  // `const` requires the field value to exactly match the specified value. If
+  // the field value doesn't match, an error message is generated.
+  //
+  // ```proto
+  // message MyFixed64 {
+  //   // value must equal 42
+  //   fixed64 value = 1 [(buf.validate.field).fixed64.const = 42];
+  // }
+  // ```
+  optional fixed64 const = 1 [(predefined).cel = {
+    id: "fixed64.const"
+    expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
+  }];
+  oneof less_than {
+    // `lt` requires the field value to be less than the specified value (field <
+    // value). If the field value is equal to or greater than the specified value,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MyFixed64 {
+    //   // must be less than 10
+    //   fixed64 value = 1 [(buf.validate.field).fixed64.lt = 10];
+    // }
+    // ```
+    fixed64 lt = 2 [(predefined).cel = {
+      id: "fixed64.lt"
+      expression:
+        "!has(rules.gte) && !has(rules.gt) && this >= rules.lt"
+        "? 'must be less than %s'.format([rules.lt]) : ''"
+    }];
+
+    // `lte` requires the field value to be less than or equal to the specified
+    // value (field <= value). If the field value is greater than the specified
+    // value, an error message is generated.
+    //
+    // ```proto
+    // message MyFixed64 {
+    //   // must be less than or equal to 10
+    //   fixed64 value = 1 [(buf.validate.field).fixed64.lte = 10];
+    // }
+    // ```
+    fixed64 lte = 3 [(predefined).cel = {
+      id: "fixed64.lte"
+      expression:
+        "!has(rules.gte) && !has(rules.gt) && this > rules.lte"
+        "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
+    }];
+  }
+  oneof greater_than {
+    // `gt` requires the field value to be greater than the specified value
+    // (exclusive). If the value of `gt` is larger than a specified `lt` or
+    // `lte`, the range is reversed, and the field value must be outside the
+    // specified range. If the field value doesn't meet the required conditions,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MyFixed64 {
+    //   // must be greater than 5 [fixed64.gt]
+    //   fixed64 value = 1 [(buf.validate.field).fixed64.gt = 5];
+    //
+    //   // must be greater than 5 and less than 10 [fixed64.gt_lt]
+    //   fixed64 other_value = 2 [(buf.validate.field).fixed64 = { gt: 5, lt: 10 }];
+    //
+    //   // must be greater than 10 or less than 5 [fixed64.gt_lt_exclusive]
+    //   fixed64 another_value = 3 [(buf.validate.field).fixed64 = { gt: 10, lt: 5 }];
+    // }
+    // ```
+    fixed64 gt = 4 [
+      (predefined).cel = {
+        id: "fixed64.gt"
+        expression:
+          "!has(rules.lt) && !has(rules.lte) && this <= rules.gt"
+          "? 'must be greater than %s'.format([rules.gt]) : ''"
+      },
+      (predefined).cel = {
+        id: "fixed64.gt_lt"
+        expression:
+          "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)"
+          "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "fixed64.gt_lt_exclusive"
+        expression:
+          "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)"
+          "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "fixed64.gt_lte"
+        expression:
+          "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)"
+          "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
+      },
+      (predefined).cel = {
+        id: "fixed64.gt_lte_exclusive"
+        expression:
+          "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)"
+          "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
+      }
+    ];
+
+    // `gte` requires the field value to be greater than or equal to the specified
+    // value (exclusive). If the value of `gte` is larger than a specified `lt`
+    // or `lte`, the range is reversed, and the field value must be outside the
+    // specified range. If the field value doesn't meet the required conditions,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MyFixed64 {
+    //   // must be greater than or equal to 5 [fixed64.gte]
+    //   fixed64 value = 1 [(buf.validate.field).fixed64.gte = 5];
+    //
+    //   // must be greater than or equal to 5 and less than 10 [fixed64.gte_lt]
+    //   fixed64 other_value = 2 [(buf.validate.field).fixed64 = { gte: 5, lt: 10 }];
+    //
+    //   // must be greater than or equal to 10 or less than 5 [fixed64.gte_lt_exclusive]
+    //   fixed64 another_value = 3 [(buf.validate.field).fixed64 = { gte: 10, lt: 5 }];
+    // }
+    // ```
+    fixed64 gte = 5 [
+      (predefined).cel = {
+        id: "fixed64.gte"
+        expression:
+          "!has(rules.lt) && !has(rules.lte) && this < rules.gte"
+          "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
+      },
+      (predefined).cel = {
+        id: "fixed64.gte_lt"
+        expression:
+          "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)"
+          "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "fixed64.gte_lt_exclusive"
+        expression:
+          "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)"
+          "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "fixed64.gte_lte"
+        expression:
+          "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)"
+          "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
+      },
+      (predefined).cel = {
+        id: "fixed64.gte_lte_exclusive"
+        expression:
+          "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)"
+          "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
+      }
+    ];
+  }
+
+  // `in` requires the field value to be equal to one of the specified values.
+  // If the field value isn't one of the specified values, an error message is
+  // generated.
+  //
+  // ```proto
+  // message MyFixed64 {
+  //   // must be in list [1, 2, 3]
+  //   fixed64 value = 1 [(buf.validate.field).fixed64 = { in: [1, 2, 3] }];
+  // }
+  // ```
+  repeated fixed64 in = 6 [(predefined).cel = {
+    id: "fixed64.in"
+    expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
+  }];
+
+  // `not_in` requires the field value to not be equal to any of the specified
+  // values. If the field value is one of the specified values, an error
+  // message is generated.
+  //
+  // ```proto
+  // message MyFixed64 {
+  //   // value must not be in list [1, 2, 3]
+  //   fixed64 value = 1 [(buf.validate.field).fixed64 = { not_in: [1, 2, 3] }];
+  // }
+  // ```
+  repeated fixed64 not_in = 7 [(predefined).cel = {
+    id: "fixed64.not_in"
+    expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
+  }];
+
+  // `example` specifies values that the field may have. These values SHOULD
+  // conform to other rules. `example` values will not impact validation
+  // but may be used as helpful guidance on how to populate the given field.
+  //
+  // ```proto
+  // message MyFixed64 {
+  //   fixed64 value = 1 [
+  //     (buf.validate.field).fixed64.example = 1,
+  //     (buf.validate.field).fixed64.example = 2
+  //   ];
+  // }
+  // ```
+  repeated fixed64 example = 8 [(predefined).cel = {
+    id: "fixed64.example"
+    expression: "true"
+  }];
+
+  // Extension fields that have the (buf.validate.predefined) option set
+  // will be treated as predefined field rules.
+  // See https://protovalidate.com/schemas/predefined-rules/
+  extensions 1000 to max;
+}
+
+// SFixed32Rules describes the rules applied to `fixed32` values.
+message SFixed32Rules {
+  // `const` requires the field value to exactly match the specified value. If
+  // the field value doesn't match, an error message is generated.
+  //
+  // ```proto
+  // message MySFixed32 {
+  //   // value must equal 42
+  //   sfixed32 value = 1 [(buf.validate.field).sfixed32.const = 42];
+  // }
+  // ```
+  optional sfixed32 const = 1 [(predefined).cel = {
+    id: "sfixed32.const"
+    expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
+  }];
+  oneof less_than {
+    // `lt` requires the field value to be less than the specified value (field <
+    // value). If the field value is equal to or greater than the specified value,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MySFixed32 {
+    //   // must be less than 10
+    //   sfixed32 value = 1 [(buf.validate.field).sfixed32.lt = 10];
+    // }
+    // ```
+    sfixed32 lt = 2 [(predefined).cel = {
+      id: "sfixed32.lt"
+      expression:
+        "!has(rules.gte) && !has(rules.gt) && this >= rules.lt"
+        "? 'must be less than %s'.format([rules.lt]) : ''"
+    }];
+
+    // `lte` requires the field value to be less than or equal to the specified
+    // value (field <= value). If the field value is greater than the specified
+    // value, an error message is generated.
+    //
+    // ```proto
+    // message MySFixed32 {
+    //   // must be less than or equal to 10
+    //   sfixed32 value = 1 [(buf.validate.field).sfixed32.lte = 10];
+    // }
+    // ```
+    sfixed32 lte = 3 [(predefined).cel = {
+      id: "sfixed32.lte"
+      expression:
+        "!has(rules.gte) && !has(rules.gt) && this > rules.lte"
+        "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
+    }];
+  }
+  oneof greater_than {
+    // `gt` requires the field value to be greater than the specified value
+    // (exclusive). If the value of `gt` is larger than a specified `lt` or
+    // `lte`, the range is reversed, and the field value must be outside the
+    // specified range. If the field value doesn't meet the required conditions,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MySFixed32 {
+    //   // must be greater than 5 [sfixed32.gt]
+    //   sfixed32 value = 1 [(buf.validate.field).sfixed32.gt = 5];
+    //
+    //   // must be greater than 5 and less than 10 [sfixed32.gt_lt]
+    //   sfixed32 other_value = 2 [(buf.validate.field).sfixed32 = { gt: 5, lt: 10 }];
+    //
+    //   // must be greater than 10 or less than 5 [sfixed32.gt_lt_exclusive]
+    //   sfixed32 another_value = 3 [(buf.validate.field).sfixed32 = { gt: 10, lt: 5 }];
+    // }
+    // ```
+    sfixed32 gt = 4 [
+      (predefined).cel = {
+        id: "sfixed32.gt"
+        expression:
+          "!has(rules.lt) && !has(rules.lte) && this <= rules.gt"
+          "? 'must be greater than %s'.format([rules.gt]) : ''"
+      },
+      (predefined).cel = {
+        id: "sfixed32.gt_lt"
+        expression:
+          "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)"
+          "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "sfixed32.gt_lt_exclusive"
+        expression:
+          "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)"
+          "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "sfixed32.gt_lte"
+        expression:
+          "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)"
+          "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
+      },
+      (predefined).cel = {
+        id: "sfixed32.gt_lte_exclusive"
+        expression:
+          "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)"
+          "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
+      }
+    ];
+
+    // `gte` requires the field value to be greater than or equal to the specified
+    // value (exclusive). If the value of `gte` is larger than a specified `lt`
+    // or `lte`, the range is reversed, and the field value must be outside the
+    // specified range. If the field value doesn't meet the required conditions,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MySFixed32 {
+    //   // must be greater than or equal to 5 [sfixed32.gte]
+    //   sfixed32 value = 1 [(buf.validate.field).sfixed32.gte = 5];
+    //
+    //   // must be greater than or equal to 5 and less than 10 [sfixed32.gte_lt]
+    //   sfixed32 other_value = 2 [(buf.validate.field).sfixed32 = { gte: 5, lt: 10 }];
+    //
+    //   // must be greater than or equal to 10 or less than 5 [sfixed32.gte_lt_exclusive]
+    //   sfixed32 another_value = 3 [(buf.validate.field).sfixed32 = { gte: 10, lt: 5 }];
+    // }
+    // ```
+    sfixed32 gte = 5 [
+      (predefined).cel = {
+        id: "sfixed32.gte"
+        expression:
+          "!has(rules.lt) && !has(rules.lte) && this < rules.gte"
+          "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
+      },
+      (predefined).cel = {
+        id: "sfixed32.gte_lt"
+        expression:
+          "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)"
+          "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "sfixed32.gte_lt_exclusive"
+        expression:
+          "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)"
+          "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "sfixed32.gte_lte"
+        expression:
+          "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)"
+          "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
+      },
+      (predefined).cel = {
+        id: "sfixed32.gte_lte_exclusive"
+        expression:
+          "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)"
+          "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
+      }
+    ];
+  }
+
+  // `in` requires the field value to be equal to one of the specified values.
+  // If the field value isn't one of the specified values, an error message is
+  // generated.
+  //
+  // ```proto
+  // message MySFixed32 {
+  //   // must be in list [1, 2, 3]
+  //   sfixed32 value = 1 [(buf.validate.field).sfixed32 = { in: [1, 2, 3] }];
+  // }
+  // ```
+  repeated sfixed32 in = 6 [(predefined).cel = {
+    id: "sfixed32.in"
+    expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
+  }];
+
+  // `not_in` requires the field value to not be equal to any of the specified
+  // values. If the field value is one of the specified values, an error
+  // message is generated.
+  //
+  // ```proto
+  // message MySFixed32 {
+  //   // value must not be in list [1, 2, 3]
+  //   sfixed32 value = 1 [(buf.validate.field).sfixed32 = { not_in: [1, 2, 3] }];
+  // }
+  // ```
+  repeated sfixed32 not_in = 7 [(predefined).cel = {
+    id: "sfixed32.not_in"
+    expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
+  }];
+
+  // `example` specifies values that the field may have. These values SHOULD
+  // conform to other rules. `example` values will not impact validation
+  // but may be used as helpful guidance on how to populate the given field.
+  //
+  // ```proto
+  // message MySFixed32 {
+  //   sfixed32 value = 1 [
+  //     (buf.validate.field).sfixed32.example = 1,
+  //     (buf.validate.field).sfixed32.example = 2
+  //   ];
+  // }
+  // ```
+  repeated sfixed32 example = 8 [(predefined).cel = {
+    id: "sfixed32.example"
+    expression: "true"
+  }];
+
+  // Extension fields that have the (buf.validate.predefined) option set
+  // will be treated as predefined field rules.
+  // See https://protovalidate.com/schemas/predefined-rules/
+  extensions 1000 to max;
+}
+
+// SFixed64Rules describes the rules applied to `fixed64` values.
+message SFixed64Rules {
+  // `const` requires the field value to exactly match the specified value. If
+  // the field value doesn't match, an error message is generated.
+  //
+  // ```proto
+  // message MySFixed64 {
+  //   // value must equal 42
+  //   sfixed64 value = 1 [(buf.validate.field).sfixed64.const = 42];
+  // }
+  // ```
+  optional sfixed64 const = 1 [(predefined).cel = {
+    id: "sfixed64.const"
+    expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
+  }];
+  oneof less_than {
+    // `lt` requires the field value to be less than the specified value (field <
+    // value). If the field value is equal to or greater than the specified value,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MySFixed64 {
+    //   // must be less than 10
+    //   sfixed64 value = 1 [(buf.validate.field).sfixed64.lt = 10];
+    // }
+    // ```
+    sfixed64 lt = 2 [(predefined).cel = {
+      id: "sfixed64.lt"
+      expression:
+        "!has(rules.gte) && !has(rules.gt) && this >= rules.lt"
+        "? 'must be less than %s'.format([rules.lt]) : ''"
+    }];
+
+    // `lte` requires the field value to be less than or equal to the specified
+    // value (field <= value). If the field value is greater than the specified
+    // value, an error message is generated.
+    //
+    // ```proto
+    // message MySFixed64 {
+    //   // must be less than or equal to 10
+    //   sfixed64 value = 1 [(buf.validate.field).sfixed64.lte = 10];
+    // }
+    // ```
+    sfixed64 lte = 3 [(predefined).cel = {
+      id: "sfixed64.lte"
+      expression:
+        "!has(rules.gte) && !has(rules.gt) && this > rules.lte"
+        "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
+    }];
+  }
+  oneof greater_than {
+    // `gt` requires the field value to be greater than the specified value
+    // (exclusive). If the value of `gt` is larger than a specified `lt` or
+    // `lte`, the range is reversed, and the field value must be outside the
+    // specified range. If the field value doesn't meet the required conditions,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MySFixed64 {
+    //   // must be greater than 5 [sfixed64.gt]
+    //   sfixed64 value = 1 [(buf.validate.field).sfixed64.gt = 5];
+    //
+    //   // must be greater than 5 and less than 10 [sfixed64.gt_lt]
+    //   sfixed64 other_value = 2 [(buf.validate.field).sfixed64 = { gt: 5, lt: 10 }];
+    //
+    //   // must be greater than 10 or less than 5 [sfixed64.gt_lt_exclusive]
+    //   sfixed64 another_value = 3 [(buf.validate.field).sfixed64 = { gt: 10, lt: 5 }];
+    // }
+    // ```
+    sfixed64 gt = 4 [
+      (predefined).cel = {
+        id: "sfixed64.gt"
+        expression:
+          "!has(rules.lt) && !has(rules.lte) && this <= rules.gt"
+          "? 'must be greater than %s'.format([rules.gt]) : ''"
+      },
+      (predefined).cel = {
+        id: "sfixed64.gt_lt"
+        expression:
+          "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)"
+          "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "sfixed64.gt_lt_exclusive"
+        expression:
+          "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)"
+          "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "sfixed64.gt_lte"
+        expression:
+          "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)"
+          "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
+      },
+      (predefined).cel = {
+        id: "sfixed64.gt_lte_exclusive"
+        expression:
+          "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)"
+          "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
+      }
+    ];
+
+    // `gte` requires the field value to be greater than or equal to the specified
+    // value (exclusive). If the value of `gte` is larger than a specified `lt`
+    // or `lte`, the range is reversed, and the field value must be outside the
+    // specified range. If the field value doesn't meet the required conditions,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MySFixed64 {
+    //   // must be greater than or equal to 5 [sfixed64.gte]
+    //   sfixed64 value = 1 [(buf.validate.field).sfixed64.gte = 5];
+    //
+    //   // must be greater than or equal to 5 and less than 10 [sfixed64.gte_lt]
+    //   sfixed64 other_value = 2 [(buf.validate.field).sfixed64 = { gte: 5, lt: 10 }];
+    //
+    //   // must be greater than or equal to 10 or less than 5 [sfixed64.gte_lt_exclusive]
+    //   sfixed64 another_value = 3 [(buf.validate.field).sfixed64 = { gte: 10, lt: 5 }];
+    // }
+    // ```
+    sfixed64 gte = 5 [
+      (predefined).cel = {
+        id: "sfixed64.gte"
+        expression:
+          "!has(rules.lt) && !has(rules.lte) && this < rules.gte"
+          "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
+      },
+      (predefined).cel = {
+        id: "sfixed64.gte_lt"
+        expression:
+          "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)"
+          "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "sfixed64.gte_lt_exclusive"
+        expression:
+          "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)"
+          "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "sfixed64.gte_lte"
+        expression:
+          "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)"
+          "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
+      },
+      (predefined).cel = {
+        id: "sfixed64.gte_lte_exclusive"
+        expression:
+          "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)"
+          "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
+      }
+    ];
+  }
+
+  // `in` requires the field value to be equal to one of the specified values.
+  // If the field value isn't one of the specified values, an error message is
+  // generated.
+  //
+  // ```proto
+  // message MySFixed64 {
+  //   // must be in list [1, 2, 3]
+  //   sfixed64 value = 1 [(buf.validate.field).sfixed64 = { in: [1, 2, 3] }];
+  // }
+  // ```
+  repeated sfixed64 in = 6 [(predefined).cel = {
+    id: "sfixed64.in"
+    expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
+  }];
+
+  // `not_in` requires the field value to not be equal to any of the specified
+  // values. If the field value is one of the specified values, an error
+  // message is generated.
+  //
+  // ```proto
+  // message MySFixed64 {
+  //   // value must not be in list [1, 2, 3]
+  //   sfixed64 value = 1 [(buf.validate.field).sfixed64 = { not_in: [1, 2, 3] }];
+  // }
+  // ```
+  repeated sfixed64 not_in = 7 [(predefined).cel = {
+    id: "sfixed64.not_in"
+    expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
+  }];
+
+  // `example` specifies values that the field may have. These values SHOULD
+  // conform to other rules. `example` values will not impact validation
+  // but may be used as helpful guidance on how to populate the given field.
+  //
+  // ```proto
+  // message MySFixed64 {
+  //   sfixed64 value = 1 [
+  //     (buf.validate.field).sfixed64.example = 1,
+  //     (buf.validate.field).sfixed64.example = 2
+  //   ];
+  // }
+  // ```
+  repeated sfixed64 example = 8 [(predefined).cel = {
+    id: "sfixed64.example"
+    expression: "true"
+  }];
+
+  // Extension fields that have the (buf.validate.predefined) option set
+  // will be treated as predefined field rules.
+  // See https://protovalidate.com/schemas/predefined-rules/
+  extensions 1000 to max;
+}
+
+// BoolRules describes the rules applied to `bool` values. These rules
+// may also be applied to the `google.protobuf.BoolValue` Well-Known-Type.
+message BoolRules {
+  // `const` requires the field value to exactly match the specified boolean value.
+  // If the field value doesn't match, an error message is generated.
+  //
+  // ```proto
+  // message MyBool {
+  //   // value must equal true
+  //   bool value = 1 [(buf.validate.field).bool.const = true];
+  // }
+  // ```
+  optional bool const = 1 [(predefined).cel = {
+    id: "bool.const"
+    expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
+  }];
+
+  // `example` specifies values that the field may have. These values SHOULD
+  // conform to other rules. `example` values will not impact validation
+  // but may be used as helpful guidance on how to populate the given field.
+  //
+  // ```proto
+  // message MyBool {
+  //   bool value = 1 [
+  //     (buf.validate.field).bool.example = 1,
+  //     (buf.validate.field).bool.example = 2
+  //   ];
+  // }
+  // ```
+  repeated bool example = 2 [(predefined).cel = {
+    id: "bool.example"
+    expression: "true"
+  }];
+
+  // Extension fields that have the (buf.validate.predefined) option set
+  // will be treated as predefined field rules.
+  // See https://protovalidate.com/schemas/predefined-rules/
+  extensions 1000 to max;
+}
+
+// StringRules describes the rules applied to `string` values These
+// rules may also be applied to the `google.protobuf.StringValue` Well-Known-Type.
+message StringRules {
+  // `const` requires the field value to exactly match the specified value. If
+  // the field value doesn't match, an error message is generated.
+  //
+  // ```proto
+  // message MyString {
+  //   // value must equal `hello`
+  //   string value = 1 [(buf.validate.field).string.const = "hello"];
+  // }
+  // ```
+  optional string const = 1 [(predefined).cel = {
+    id: "string.const"
+    expression: "this != getField(rules, 'const') ? 'must equal `%s`'.format([getField(rules, 'const')]) : ''"
+  }];
+
+  // `len` dictates that the field value must have the specified
+  // number of characters (Unicode code points), which may differ from the number
+  // of bytes in the string. If the field value does not meet the specified
+  // length, an error message will be generated.
+  //
+  // ```proto
+  // message MyString {
+  //   // value length must be 5 characters
+  //   string value = 1 [(buf.validate.field).string.len = 5];
+  // }
+  // ```
+  optional uint64 len = 19 [(predefined).cel = {
+    id: "string.len"
+    expression: "uint(this.size()) != rules.len ? 'must be %s characters'.format([rules.len]) : ''"
+  }];
+
+  // `min_len` specifies that the field value must have at least the specified
+  // number of characters (Unicode code points), which may differ from the number
+  // of bytes in the string. If the field value contains fewer characters, an error
+  // message will be generated.
+  //
+  // ```proto
+  // message MyString {
+  //   // value length must be at least 3 characters
+  //   string value = 1 [(buf.validate.field).string.min_len = 3];
+  // }
+  // ```
+  optional uint64 min_len = 2 [(predefined).cel = {
+    id: "string.min_len"
+    expression: "uint(this.size()) < rules.min_len ? 'must be at least %s characters'.format([rules.min_len]) : ''"
+  }];
+
+  // `max_len` specifies that the field value must have no more than the specified
+  // number of characters (Unicode code points), which may differ from the
+  // number of bytes in the string. If the field value contains more characters,
+  // an error message will be generated.
+  //
+  // ```proto
+  // message MyString {
+  //   // value length must be at most 10 characters
+  //   string value = 1 [(buf.validate.field).string.max_len = 10];
+  // }
+  // ```
+  optional uint64 max_len = 3 [(predefined).cel = {
+    id: "string.max_len"
+    expression: "uint(this.size()) > rules.max_len ? 'must be at most %s characters'.format([rules.max_len]) : ''"
+  }];
+
+  // `len_bytes` dictates that the field value must have the specified number of
+  // bytes. If the field value does not match the specified length in bytes,
+  // an error message will be generated.
+  //
+  // ```proto
+  // message MyString {
+  //   // value length must be 6 bytes
+  //   string value = 1 [(buf.validate.field).string.len_bytes = 6];
+  // }
+  // ```
+  optional uint64 len_bytes = 20 [(predefined).cel = {
+    id: "string.len_bytes"
+    expression: "uint(bytes(this).size()) != rules.len_bytes ? 'must be %s bytes'.format([rules.len_bytes]) : ''"
+  }];
+
+  // `min_bytes` specifies that the field value must have at least the specified
+  // number of bytes. If the field value contains fewer bytes, an error message
+  // will be generated.
+  //
+  // ```proto
+  // message MyString {
+  //   // value length must be at least 4 bytes
+  //   string value = 1 [(buf.validate.field).string.min_bytes = 4];
+  // }
+  //
+  // ```
+  optional uint64 min_bytes = 4 [(predefined).cel = {
+    id: "string.min_bytes"
+    expression: "uint(bytes(this).size()) < rules.min_bytes ? 'must be at least %s bytes'.format([rules.min_bytes]) : ''"
+  }];
+
+  // `max_bytes` specifies that the field value must have no more than the
+  // specified number of bytes. If the field value contains more bytes, an
+  // error message will be generated.
+  //
+  // ```proto
+  // message MyString {
+  //   // value length must be at most 8 bytes
+  //   string value = 1 [(buf.validate.field).string.max_bytes = 8];
+  // }
+  // ```
+  optional uint64 max_bytes = 5 [(predefined).cel = {
+    id: "string.max_bytes"
+    expression: "uint(bytes(this).size()) > rules.max_bytes ? 'must be at most %s bytes'.format([rules.max_bytes]) : ''"
+  }];
+
+  // `pattern` specifies that the field value must match the specified
+  // regular expression (RE2 syntax), with the expression provided without any
+  // delimiters. If the field value doesn't match the regular expression, an
+  // error message will be generated.
+  //
+  // ```proto
+  // message MyString {
+  //   // value does not match regex pattern `^[a-zA-Z]//$`
+  //   string value = 1 [(buf.validate.field).string.pattern = "^[a-zA-Z]//$"];
+  // }
+  // ```
+  optional string pattern = 6 [(predefined).cel = {
+    id: "string.pattern"
+    expression: "!this.matches(rules.pattern) ? 'does not match regex pattern `%s`'.format([rules.pattern]) : ''"
+  }];
+
+  // `prefix` specifies that the field value must have the
+  // specified substring at the beginning of the string. If the field value
+  // doesn't start with the specified prefix, an error message will be
+  // generated.
+  //
+  // ```proto
+  // message MyString {
+  //   // value does not have prefix `pre`
+  //   string value = 1 [(buf.validate.field).string.prefix = "pre"];
+  // }
+  // ```
+  optional string prefix = 7 [(predefined).cel = {
+    id: "string.prefix"
+    expression: "!this.startsWith(rules.prefix) ? 'does not have prefix `%s`'.format([rules.prefix]) : ''"
+  }];
+
+  // `suffix` specifies that the field value must have the
+  // specified substring at the end of the string. If the field value doesn't
+  // end with the specified suffix, an error message will be generated.
+  //
+  // ```proto
+  // message MyString {
+  //   // value does not have suffix `post`
+  //   string value = 1 [(buf.validate.field).string.suffix = "post"];
+  // }
+  // ```
+  optional string suffix = 8 [(predefined).cel = {
+    id: "string.suffix"
+    expression: "!this.endsWith(rules.suffix) ? 'does not have suffix `%s`'.format([rules.suffix]) : ''"
+  }];
+
+  // `contains` specifies that the field value must have the
+  // specified substring anywhere in the string. If the field value doesn't
+  // contain the specified substring, an error message will be generated.
+  //
+  // ```proto
+  // message MyString {
+  //   // value does not contain substring `inside`.
+  //   string value = 1 [(buf.validate.field).string.contains = "inside"];
+  // }
+  // ```
+  optional string contains = 9 [(predefined).cel = {
+    id: "string.contains"
+    expression: "!this.contains(rules.contains) ? 'does not contain substring `%s`'.format([rules.contains]) : ''"
+  }];
+
+  // `not_contains` specifies that the field value must not have the
+  // specified substring anywhere in the string. If the field value contains
+  // the specified substring, an error message will be generated.
+  //
+  // ```proto
+  // message MyString {
+  //   // value contains substring `inside`.
+  //   string value = 1 [(buf.validate.field).string.not_contains = "inside"];
+  // }
+  // ```
+  optional string not_contains = 23 [(predefined).cel = {
+    id: "string.not_contains"
+    expression: "this.contains(rules.not_contains) ? 'contains substring `%s`'.format([rules.not_contains]) : ''"
+  }];
+
+  // `in` specifies that the field value must be equal to one of the specified
+  // values. If the field value isn't one of the specified values, an error
+  // message will be generated.
+  //
+  // ```proto
+  // message MyString {
+  //   // must be in list ["apple", "banana"]
+  //   string value = 1 [(buf.validate.field).string.in = "apple", (buf.validate.field).string.in = "banana"];
+  // }
+  // ```
+  repeated string in = 10 [(predefined).cel = {
+    id: "string.in"
+    expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
+  }];
+
+  // `not_in` specifies that the field value cannot be equal to any
+  // of the specified values. If the field value is one of the specified values,
+  // an error message will be generated.
+  // ```proto
+  // message MyString {
+  //   // value must not be in list ["orange", "grape"]
+  //   string value = 1 [(buf.validate.field).string.not_in = "orange", (buf.validate.field).string.not_in = "grape"];
+  // }
+  // ```
+  repeated string not_in = 11 [(predefined).cel = {
+    id: "string.not_in"
+    expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
+  }];
+
+  // `WellKnown` rules provide advanced rules against common string
+  // patterns.
+  oneof well_known {
+    // `email` specifies that the field value must be a valid email address, for
+    // example "foo@example.com".
+    //
+    // Conforms to the definition for a valid email address from the [HTML standard](https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address).
+    // Note that this standard willfully deviates from [RFC 5322](https://datatracker.ietf.org/doc/html/rfc5322),
+    // which allows many unexpected forms of email addresses and will easily match
+    // a typographical error.
+    //
+    // If the field value isn't a valid email address, an error message will be generated.
+    //
+    // ```proto
+    // message MyString {
+    //   // must be a valid email address
+    //   string value = 1 [(buf.validate.field).string.email = true];
+    // }
+    // ```
+    bool email = 12 [
+      (predefined).cel = {
+        id: "string.email"
+        message: "must be a valid email address"
+        expression: "!rules.email || this == '' || this.isEmail()"
+      },
+      (predefined).cel = {
+        id: "string.email_empty"
+        message: "value is empty, which is not a valid email address"
+        expression: "!rules.email || this != ''"
+      }
+    ];
+
+    // `hostname` specifies that the field value must be a valid hostname, for
+    // example "foo.example.com".
+    //
+    // A valid hostname follows the rules below:
+    // - The name consists of one or more labels, separated by a dot (".").
+    // - Each label can be 1 to 63 alphanumeric characters.
+    // - A label can contain hyphens ("-"), but must not start or end with a hyphen.
+    // - The right-most label must not be digits only.
+    // - The name can have a trailing dot—for example, "foo.example.com.".
+    // - The name can be 253 characters at most, excluding the optional trailing dot.
+    //
+    // If the field value isn't a valid hostname, an error message will be generated.
+    //
+    // ```proto
+    // message MyString {
+    //   // must be a valid hostname
+    //   string value = 1 [(buf.validate.field).string.hostname = true];
+    // }
+    // ```
+    bool hostname = 13 [
+      (predefined).cel = {
+        id: "string.hostname"
+        message: "must be a valid hostname"
+        expression: "!rules.hostname || this == '' || this.isHostname()"
+      },
+      (predefined).cel = {
+        id: "string.hostname_empty"
+        message: "value is empty, which is not a valid hostname"
+        expression: "!rules.hostname || this != ''"
+      }
+    ];
+
+    // `ip` specifies that the field value must be a valid IP (v4 or v6) address.
+    //
+    // IPv4 addresses are expected in the dotted decimal format—for example, "192.168.5.21".
+    // IPv6 addresses are expected in their text representation—for example, "::1",
+    // or "2001:0DB8:ABCD:0012::0".
+    //
+    // Both formats are well-defined in the internet standard [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986).
+    // Zone identifiers for IPv6 addresses (for example, "fe80::a%en1") are supported.
+    //
+    // If the field value isn't a valid IP address, an error message will be
+    // generated.
+    //
+    // ```proto
+    // message MyString {
+    //   // must be a valid IP address
+    //   string value = 1 [(buf.validate.field).string.ip = true];
+    // }
+    // ```
+    bool ip = 14 [
+      (predefined).cel = {
+        id: "string.ip"
+        message: "must be a valid IP address"
+        expression: "!rules.ip || this == '' || this.isIp()"
+      },
+      (predefined).cel = {
+        id: "string.ip_empty"
+        message: "value is empty, which is not a valid IP address"
+        expression: "!rules.ip || this != ''"
+      }
+    ];
+
+    // `ipv4` specifies that the field value must be a valid IPv4 address—for
+    // example "192.168.5.21". If the field value isn't a valid IPv4 address, an
+    // error message will be generated.
+    //
+    // ```proto
+    // message MyString {
+    //   // must be a valid IPv4 address
+    //   string value = 1 [(buf.validate.field).string.ipv4 = true];
+    // }
+    // ```
+    bool ipv4 = 15 [
+      (predefined).cel = {
+        id: "string.ipv4"
+        message: "must be a valid IPv4 address"
+        expression: "!rules.ipv4 || this == '' || this.isIp(4)"
+      },
+      (predefined).cel = {
+        id: "string.ipv4_empty"
+        message: "value is empty, which is not a valid IPv4 address"
+        expression: "!rules.ipv4 || this != ''"
+      }
+    ];
+
+    // `ipv6` specifies that the field value must be a valid IPv6 address—for
+    // example "::1", or "d7a:115c:a1e0:ab12:4843:cd96:626b:430b". If the field
+    // value is not a valid IPv6 address, an error message will be generated.
+    //
+    // ```proto
+    // message MyString {
+    //   // must be a valid IPv6 address
+    //   string value = 1 [(buf.validate.field).string.ipv6 = true];
+    // }
+    // ```
+    bool ipv6 = 16 [
+      (predefined).cel = {
+        id: "string.ipv6"
+        message: "must be a valid IPv6 address"
+        expression: "!rules.ipv6 || this == '' || this.isIp(6)"
+      },
+      (predefined).cel = {
+        id: "string.ipv6_empty"
+        message: "value is empty, which is not a valid IPv6 address"
+        expression: "!rules.ipv6 || this != ''"
+      }
+    ];
+
+    // `uri` specifies that the field value must be a valid URI, for example
+    // "https://example.com/foo/bar?baz=quux#frag".
+    //
+    // URI is defined in the internet standard [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986).
+    // Zone Identifiers in IPv6 address literals are supported ([RFC 6874](https://datatracker.ietf.org/doc/html/rfc6874)).
+    //
+    // If the field value isn't a valid URI, an error message will be generated.
+    //
+    // ```proto
+    // message MyString {
+    //   // must be a valid URI
+    //   string value = 1 [(buf.validate.field).string.uri = true];
+    // }
+    // ```
+    bool uri = 17 [
+      (predefined).cel = {
+        id: "string.uri"
+        message: "must be a valid URI"
+        expression: "!rules.uri || this == '' || this.isUri()"
+      },
+      (predefined).cel = {
+        id: "string.uri_empty"
+        message: "value is empty, which is not a valid URI"
+        expression: "!rules.uri || this != ''"
+      }
+    ];
+
+    // `uri_ref` specifies that the field value must be a valid URI Reference—either
+    // a URI such as "https://example.com/foo/bar?baz=quux#frag", or a Relative
+    // Reference such as "./foo/bar?query".
+    //
+    // URI, URI Reference, and Relative Reference are defined in the internet
+    // standard [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986). Zone
+    // Identifiers in IPv6 address literals are supported ([RFC 6874](https://datatracker.ietf.org/doc/html/rfc6874)).
+    //
+    // If the field value isn't a valid URI Reference, an error message will be
+    // generated.
+    //
+    // ```proto
+    // message MyString {
+    //   // must be a valid URI Reference
+    //   string value = 1 [(buf.validate.field).string.uri_ref = true];
+    // }
+    // ```
+    bool uri_ref = 18 [(predefined).cel = {
+      id: "string.uri_ref"
+      message: "must be a valid URI Reference"
+      expression: "!rules.uri_ref || this.isUriRef()"
+    }];
+
+    // `address` specifies that the field value must be either a valid hostname
+    // (for example, "example.com"), or a valid IP (v4 or v6) address (for example,
+    // "192.168.0.1", or "::1"). If the field value isn't a valid hostname or IP,
+    // an error message will be generated.
+    //
+    // ```proto
+    // message MyString {
+    //   // must be a valid hostname, or ip address
+    //   string value = 1 [(buf.validate.field).string.address = true];
+    // }
+    // ```
+    bool address = 21 [
+      (predefined).cel = {
+        id: "string.address"
+        message: "must be a valid hostname, or ip address"
+        expression: "!rules.address || this == '' || this.isHostname() || this.isIp()"
+      },
+      (predefined).cel = {
+        id: "string.address_empty"
+        message: "value is empty, which is not a valid hostname, or ip address"
+        expression: "!rules.address || this != ''"
+      }
+    ];
+
+    // `uuid` specifies that the field value must be a valid UUID as defined by
+    // [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.2). If the
+    // field value isn't a valid UUID, an error message will be generated.
+    //
+    // ```proto
+    // message MyString {
+    //   // must be a valid UUID
+    //   string value = 1 [(buf.validate.field).string.uuid = true];
+    // }
+    // ```
+    bool uuid = 22 [
+      (predefined).cel = {
+        id: "string.uuid"
+        message: "must be a valid UUID"
+        expression: "!rules.uuid || this == '' || this.matches('^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$')"
+      },
+      (predefined).cel = {
+        id: "string.uuid_empty"
+        message: "value is empty, which is not a valid UUID"
+        expression: "!rules.uuid || this != ''"
+      }
+    ];
+
+    // `tuuid` (trimmed UUID) specifies that the field value must be a valid UUID as
+    // defined by [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.2) with all dashes
+    // omitted. If the field value isn't a valid UUID without dashes, an error message
+    // will be generated.
+    //
+    // ```proto
+    // message MyString {
+    //   // must be a valid trimmed UUID
+    //   string value = 1 [(buf.validate.field).string.tuuid = true];
+    // }
+    // ```
+    bool tuuid = 33 [
+      (predefined).cel = {
+        id: "string.tuuid"
+        message: "must be a valid trimmed UUID"
+        expression: "!rules.tuuid || this == '' || this.matches('^[0-9a-fA-F]{32}$')"
+      },
+      (predefined).cel = {
+        id: "string.tuuid_empty"
+        message: "value is empty, which is not a valid trimmed UUID"
+        expression: "!rules.tuuid || this != ''"
+      }
+    ];
+
+    // `ip_with_prefixlen` specifies that the field value must be a valid IP
+    // (v4 or v6) address with prefix length—for example, "192.168.5.21/16" or
+    // "2001:0DB8:ABCD:0012::F1/64". If the field value isn't a valid IP with
+    // prefix length, an error message will be generated.
+    //
+    // ```proto
+    // message MyString {
+    //   // must be a valid IP with prefix length
+    //    string value = 1 [(buf.validate.field).string.ip_with_prefixlen = true];
+    // }
+    // ```
+    bool ip_with_prefixlen = 26 [
+      (predefined).cel = {
+        id: "string.ip_with_prefixlen"
+        message: "must be a valid IP prefix"
+        expression: "!rules.ip_with_prefixlen || this == '' || this.isIpPrefix()"
+      },
+      (predefined).cel = {
+        id: "string.ip_with_prefixlen_empty"
+        message: "value is empty, which is not a valid IP prefix"
+        expression: "!rules.ip_with_prefixlen || this != ''"
+      }
+    ];
+
+    // `ipv4_with_prefixlen` specifies that the field value must be a valid
+    // IPv4 address with prefix length—for example, "192.168.5.21/16". If the
+    // field value isn't a valid IPv4 address with prefix length, an error
+    // message will be generated.
+    //
+    // ```proto
+    // message MyString {
+    //   // must be a valid IPv4 address with prefix length
+    //    string value = 1 [(buf.validate.field).string.ipv4_with_prefixlen = true];
+    // }
+    // ```
+    bool ipv4_with_prefixlen = 27 [
+      (predefined).cel = {
+        id: "string.ipv4_with_prefixlen"
+        message: "must be a valid IPv4 address with prefix length"
+        expression: "!rules.ipv4_with_prefixlen || this == '' || this.isIpPrefix(4)"
+      },
+      (predefined).cel = {
+        id: "string.ipv4_with_prefixlen_empty"
+        message: "value is empty, which is not a valid IPv4 address with prefix length"
+        expression: "!rules.ipv4_with_prefixlen || this != ''"
+      }
+    ];
+
+    // `ipv6_with_prefixlen` specifies that the field value must be a valid
+    // IPv6 address with prefix length—for example, "2001:0DB8:ABCD:0012::F1/64".
+    // If the field value is not a valid IPv6 address with prefix length,
+    // an error message will be generated.
+    //
+    // ```proto
+    // message MyString {
+    //   // must be a valid IPv6 address prefix length
+    //    string value = 1 [(buf.validate.field).string.ipv6_with_prefixlen = true];
+    // }
+    // ```
+    bool ipv6_with_prefixlen = 28 [
+      (predefined).cel = {
+        id: "string.ipv6_with_prefixlen"
+        message: "must be a valid IPv6 address with prefix length"
+        expression: "!rules.ipv6_with_prefixlen || this == '' || this.isIpPrefix(6)"
+      },
+      (predefined).cel = {
+        id: "string.ipv6_with_prefixlen_empty"
+        message: "value is empty, which is not a valid IPv6 address with prefix length"
+        expression: "!rules.ipv6_with_prefixlen || this != ''"
+      }
+    ];
+
+    // `ip_prefix` specifies that the field value must be a valid IP (v4 or v6)
+    // prefix—for example, "192.168.0.0/16" or "2001:0DB8:ABCD:0012::0/64".
+    //
+    // The prefix must have all zeros for the unmasked bits. For example,
+    // "2001:0DB8:ABCD:0012::0/64" designates the left-most 64 bits for the
+    // prefix, and the remaining 64 bits must be zero.
+    //
+    // If the field value isn't a valid IP prefix, an error message will be
+    // generated.
+    //
+    // ```proto
+    // message MyString {
+    //   // must be a valid IP prefix
+    //    string value = 1 [(buf.validate.field).string.ip_prefix = true];
+    // }
+    // ```
+    bool ip_prefix = 29 [
+      (predefined).cel = {
+        id: "string.ip_prefix"
+        message: "must be a valid IP prefix"
+        expression: "!rules.ip_prefix || this == '' || this.isIpPrefix(true)"
+      },
+      (predefined).cel = {
+        id: "string.ip_prefix_empty"
+        message: "value is empty, which is not a valid IP prefix"
+        expression: "!rules.ip_prefix || this != ''"
+      }
+    ];
+
+    // `ipv4_prefix` specifies that the field value must be a valid IPv4
+    // prefix, for example "192.168.0.0/16".
+    //
+    // The prefix must have all zeros for the unmasked bits. For example,
+    // "192.168.0.0/16" designates the left-most 16 bits for the prefix,
+    // and the remaining 16 bits must be zero.
+    //
+    // If the field value isn't a valid IPv4 prefix, an error message
+    // will be generated.
+    //
+    // ```proto
+    // message MyString {
+    //   // must be a valid IPv4 prefix
+    //    string value = 1 [(buf.validate.field).string.ipv4_prefix = true];
+    // }
+    // ```
+    bool ipv4_prefix = 30 [
+      (predefined).cel = {
+        id: "string.ipv4_prefix"
+        message: "must be a valid IPv4 prefix"
+        expression: "!rules.ipv4_prefix || this == '' || this.isIpPrefix(4, true)"
+      },
+      (predefined).cel = {
+        id: "string.ipv4_prefix_empty"
+        message: "value is empty, which is not a valid IPv4 prefix"
+        expression: "!rules.ipv4_prefix || this != ''"
+      }
+    ];
+
+    // `ipv6_prefix` specifies that the field value must be a valid IPv6 prefix—for
+    // example, "2001:0DB8:ABCD:0012::0/64".
+    //
+    // The prefix must have all zeros for the unmasked bits. For example,
+    // "2001:0DB8:ABCD:0012::0/64" designates the left-most 64 bits for the
+    // prefix, and the remaining 64 bits must be zero.
+    //
+    // If the field value is not a valid IPv6 prefix, an error message will be
+    // generated.
+    //
+    // ```proto
+    // message MyString {
+    //   // must be a valid IPv6 prefix
+    //    string value = 1 [(buf.validate.field).string.ipv6_prefix = true];
+    // }
+    // ```
+    bool ipv6_prefix = 31 [
+      (predefined).cel = {
+        id: "string.ipv6_prefix"
+        message: "must be a valid IPv6 prefix"
+        expression: "!rules.ipv6_prefix || this == '' || this.isIpPrefix(6, true)"
+      },
+      (predefined).cel = {
+        id: "string.ipv6_prefix_empty"
+        message: "value is empty, which is not a valid IPv6 prefix"
+        expression: "!rules.ipv6_prefix || this != ''"
+      }
+    ];
+
+    // `host_and_port` specifies that the field value must be a valid host/port
+    // pair—for example, "example.com:8080".
+    //
+    // The host can be one of:
+    // - An IPv4 address in dotted decimal format—for example, "192.168.5.21".
+    // - An IPv6 address enclosed in square brackets—for example, "[2001:0DB8:ABCD:0012::F1]".
+    // - A hostname—for example, "example.com".
+    //
+    // The port is separated by a colon. It must be non-empty, with a decimal number
+    // in the range of 0-65535, inclusive.
+    bool host_and_port = 32 [
+      (predefined).cel = {
+        id: "string.host_and_port"
+        message: "must be a valid host (hostname or IP address) and port pair"
+        expression: "!rules.host_and_port || this == '' || this.isHostAndPort(true)"
+      },
+      (predefined).cel = {
+        id: "string.host_and_port_empty"
+        message: "value is empty, which is not a valid host and port pair"
+        expression: "!rules.host_and_port || this != ''"
+      }
+    ];
+
+    // `ulid` specifies that the field value must be a valid ULID (Universally Unique
+    // Lexicographically Sortable Identifier) as defined by the [ULID specification](https://github.com/ulid/spec).
+    // If the field value isn't a valid ULID, an error message will be generated.
+    //
+    // ```proto
+    // message MyString {
+    //   // must be a valid ULID
+    //   string value = 1 [(buf.validate.field).string.ulid = true];
+    // }
+    // ```
+    bool ulid = 35 [
+      (predefined).cel = {
+        id: "string.ulid"
+        message: "must be a valid ULID"
+        expression: "!rules.ulid || this == '' || this.matches('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$')"
+      },
+      (predefined).cel = {
+        id: "string.ulid_empty"
+        message: "value is empty, which is not a valid ULID"
+        expression: "!rules.ulid || this != ''"
+      }
+    ];
+
+    // `protobuf_fqn` specifies that the field value must be a valid fully-qualified
+    // Protobuf name as defined by the [Protobuf Language Specification](https://protobuf.com/docs/language-spec).
+    //
+    // A fully-qualified Protobuf name is a dot-separated list of Protobuf identifiers,
+    // where each identifier starts with a letter or underscore and is followed by zero or
+    // more letters, underscores, or digits.
+    //
+    // Examples: "buf.validate", "google.protobuf.Timestamp", "my_package.MyMessage".
+    //
+    // Note: historically, fully-qualified Protobuf names were represented with a leading
+    // dot (for example, ".buf.validate.StringRules"). Modern Protobuf does not use the
+    // leading dot, and most fully-qualified names are represented without it. Use
+    // `protobuf_dot_fqn` if a leading dot is required.
+    //
+    // If the field value isn't a valid fully-qualified Protobuf name, an error message
+    // will be generated.
+    //
+    // ```proto
+    // message MyString {
+    //   // value must be a valid fully-qualified Protobuf name
+    //   string value = 1 [(buf.validate.field).string.protobuf_fqn = true];
+    // }
+    // ```
+    bool protobuf_fqn = 37 [
+      (predefined).cel = {
+        id: "string.protobuf_fqn"
+        message: "must be a valid fully-qualified Protobuf name"
+        expression: "!rules.protobuf_fqn || this == '' || this.matches('^[A-Za-z_][A-Za-z_0-9]*(\\\\.[A-Za-z_][A-Za-z_0-9]*)*$')"
+      },
+      (predefined).cel = {
+        id: "string.protobuf_fqn_empty"
+        message: "value is empty, which is not a valid fully-qualified Protobuf name"
+        expression: "!rules.protobuf_fqn || this != ''"
+      }
+    ];
+
+    // `protobuf_dot_fqn` specifies that the field value must be a valid fully-qualified
+    // Protobuf name with a leading dot, as defined by the
+    // [Protobuf Language Specification](https://protobuf.com/docs/language-spec).
+    //
+    // A fully-qualified Protobuf name with a leading dot is a dot followed by a
+    // dot-separated list of Protobuf identifiers, where each identifier starts with a
+    // letter or underscore and is followed by zero or more letters, underscores, or
+    // digits.
+    //
+    // Examples: ".buf.validate", ".google.protobuf.Timestamp", ".my_package.MyMessage".
+    //
+    // Note: this is the historical representation of fully-qualified Protobuf names,
+    // where a leading dot denotes an absolute reference. Modern Protobuf does not use
+    // the leading dot, and most fully-qualified names are represented without it. Most
+    // users will want to use `protobuf_fqn` instead.
+    //
+    // If the field value isn't a valid fully-qualified Protobuf name with a leading dot,
+    // an error message will be generated.
+    //
+    // ```proto
+    // message MyString {
+    //   // value must be a valid fully-qualified Protobuf name with a leading dot
+    //   string value = 1 [(buf.validate.field).string.protobuf_dot_fqn = true];
+    // }
+    // ```
+    bool protobuf_dot_fqn = 38 [
+      (predefined).cel = {
+        id: "string.protobuf_dot_fqn"
+        message: "must be a valid fully-qualified Protobuf name with a leading dot"
+        expression: "!rules.protobuf_dot_fqn || this == '' || this.matches('^\\\\.[A-Za-z_][A-Za-z_0-9]*(\\\\.[A-Za-z_][A-Za-z_0-9]*)*$')"
+      },
+      (predefined).cel = {
+        id: "string.protobuf_dot_fqn_empty"
+        message: "value is empty, which is not a valid fully-qualified Protobuf name with a leading dot"
+        expression: "!rules.protobuf_dot_fqn || this != ''"
+      }
+    ];
+
+    // `well_known_regex` specifies a common well-known pattern
+    // defined as a regex. If the field value doesn't match the well-known
+    // regex, an error message will be generated.
+    //
+    // ```proto
+    // message MyString {
+    //   // must be a valid HTTP header value
+    //   string value = 1 [(buf.validate.field).string.well_known_regex = KNOWN_REGEX_HTTP_HEADER_VALUE];
+    // }
+    // ```
+    //
+    // #### KnownRegex
+    //
+    // `well_known_regex` contains some well-known patterns.
+    //
+    // | Name                          | Number | Description                               |
+    // |-------------------------------|--------|-------------------------------------------|
+    // | KNOWN_REGEX_UNSPECIFIED       | 0      |                                           |
+    // | KNOWN_REGEX_HTTP_HEADER_NAME  | 1      | HTTP header name as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2)  |
+    // | KNOWN_REGEX_HTTP_HEADER_VALUE | 2      | HTTP header value as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4) |
+    KnownRegex well_known_regex = 24 [
+      (predefined).cel = {
+        id: "string.well_known_regex.header_name"
+        message: "must be a valid HTTP header name"
+        expression:
+          "rules.well_known_regex != 1 || this == '' || this.matches(!has(rules.strict) || rules.strict ?"
+          "'^:?[0-9a-zA-Z!#$%&\\'*+-.^_|~\\x60]+$' :"
+          "'^[^\\u0000\\u000A\\u000D]+$')"
+      },
+      (predefined).cel = {
+        id: "string.well_known_regex.header_name_empty"
+        message: "value is empty, which is not a valid HTTP header name"
+        expression: "rules.well_known_regex != 1 || this != ''"
+      },
+      (predefined).cel = {
+        id: "string.well_known_regex.header_value"
+        message: "must be a valid HTTP header value"
+        expression:
+          "rules.well_known_regex != 2 || this.matches(!has(rules.strict) || rules.strict ?"
+          "'^[^\\u0000-\\u0008\\u000A-\\u001F\\u007F]*$' :"
+          "'^[^\\u0000\\u000A\\u000D]*$')"
+      }
+    ];
+  }
+
+  // This applies to regexes `HTTP_HEADER_NAME` and `HTTP_HEADER_VALUE` to
+  // enable strict header validation. By default, this is true, and HTTP header
+  // validations are [RFC-compliant](https://datatracker.ietf.org/doc/html/rfc7230#section-3). Setting to false will enable looser
+  // validations that only disallow `\r\n\0` characters, which can be used to
+  // bypass header matching rules.
+  //
+  // ```proto
+  // message MyString {
+  //   // The field `value` must have be a valid HTTP headers, but not enforced with strict rules.
+  //   string value = 1 [(buf.validate.field).string.strict = false];
+  // }
+  // ```
+  optional bool strict = 25;
+
+  // `example` specifies values that the field may have. These values SHOULD
+  // conform to other rules. `example` values will not impact validation
+  // but may be used as helpful guidance on how to populate the given field.
+  //
+  // ```proto
+  // message MyString {
+  //   string value = 1 [
+  //     (buf.validate.field).string.example = "hello",
+  //     (buf.validate.field).string.example = "world"
+  //   ];
+  // }
+  // ```
+  repeated string example = 34 [(predefined).cel = {
+    id: "string.example"
+    expression: "true"
+  }];
+
+  // Extension fields that have the (buf.validate.predefined) option set
+  // will be treated as predefined field rules.
+  // See https://protovalidate.com/schemas/predefined-rules/
+  extensions 1000 to max;
+}
+
+// KnownRegex contains some well-known patterns.
+enum KnownRegex {
+  KNOWN_REGEX_UNSPECIFIED = 0;
+
+  // HTTP header name as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2).
+  KNOWN_REGEX_HTTP_HEADER_NAME = 1;
+
+  // HTTP header value as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4).
+  KNOWN_REGEX_HTTP_HEADER_VALUE = 2;
+}
+
+// BytesRules describe the rules applied to `bytes` values. These rules
+// may also be applied to the `google.protobuf.BytesValue` Well-Known-Type.
+message BytesRules {
+  // `const` requires the field value to exactly match the specified bytes
+  // value. If the field value doesn't match, an error message is generated.
+  //
+  // ```proto
+  // message MyBytes {
+  //   // must be "\x01\x02\x03\x04"
+  //   bytes value = 1 [(buf.validate.field).bytes.const = "\x01\x02\x03\x04"];
+  // }
+  // ```
+  optional bytes const = 1 [(predefined).cel = {
+    id: "bytes.const"
+    expression: "this != getField(rules, 'const') ? 'must be %x'.format([getField(rules, 'const')]) : ''"
+  }];
+
+  // `len` requires the field value to have the specified length in bytes.
+  // If the field value doesn't match, an error message is generated.
+  //
+  // ```proto
+  // message MyBytes {
+  //   // value length must be 4 bytes.
+  //   optional bytes value = 1 [(buf.validate.field).bytes.len = 4];
+  // }
+  // ```
+  optional uint64 len = 13 [(predefined).cel = {
+    id: "bytes.len"
+    expression: "uint(this.size()) != rules.len ? 'must be %s bytes'.format([rules.len]) : ''"
+  }];
+
+  // `min_len` requires the field value to have at least the specified minimum
+  // length in bytes.
+  // If the field value doesn't meet the requirement, an error message is generated.
+  //
+  // ```proto
+  // message MyBytes {
+  //   // value length must be at least 2 bytes.
+  //   optional bytes value = 1 [(buf.validate.field).bytes.min_len = 2];
+  // }
+  // ```
+  optional uint64 min_len = 2 [(predefined).cel = {
+    id: "bytes.min_len"
+    expression: "uint(this.size()) < rules.min_len ? 'must be at least %s bytes'.format([rules.min_len]) : ''"
+  }];
+
+  // `max_len` requires the field value to have at most the specified maximum
+  // length in bytes.
+  // If the field value exceeds the requirement, an error message is generated.
+  //
+  // ```proto
+  // message MyBytes {
+  //   // must be at most 6 bytes.
+  //   optional bytes value = 1 [(buf.validate.field).bytes.max_len = 6];
+  // }
+  // ```
+  optional uint64 max_len = 3 [(predefined).cel = {
+    id: "bytes.max_len"
+    expression: "uint(this.size()) > rules.max_len ? 'must be at most %s bytes'.format([rules.max_len]) : ''"
+  }];
+
+  // `pattern` requires the field value to match the specified regular
+  // expression ([RE2 syntax](https://github.com/google/re2/wiki/Syntax)).
+  // The value of the field must be valid UTF-8 or validation will fail with a
+  // runtime error.
+  // If the field value doesn't match the pattern, an error message is generated.
+  //
+  // ```proto
+  // message MyBytes {
+  //   // value must match regex pattern "^[a-zA-Z0-9]+$".
+  //   optional bytes value = 1 [(buf.validate.field).bytes.pattern = "^[a-zA-Z0-9]+$"];
+  // }
+  // ```
+  optional string pattern = 4 [(predefined).cel = {
+    id: "bytes.pattern"
+    expression: "!string(this).matches(rules.pattern) ? 'must match regex pattern `%s`'.format([rules.pattern]) : ''"
+  }];
+
+  // `prefix` requires the field value to have the specified bytes at the
+  // beginning of the string.
+  // If the field value doesn't meet the requirement, an error message is generated.
+  //
+  // ```proto
+  // message MyBytes {
+  //   // value does not have prefix \x01\x02
+  //   optional bytes value = 1 [(buf.validate.field).bytes.prefix = "\x01\x02"];
+  // }
+  // ```
+  optional bytes prefix = 5 [(predefined).cel = {
+    id: "bytes.prefix"
+    expression: "!this.startsWith(rules.prefix) ? 'does not have prefix %x'.format([rules.prefix]) : ''"
+  }];
+
+  // `suffix` requires the field value to have the specified bytes at the end
+  // of the string.
+  // If the field value doesn't meet the requirement, an error message is generated.
+  //
+  // ```proto
+  // message MyBytes {
+  //   // value does not have suffix \x03\x04
+  //   optional bytes value = 1 [(buf.validate.field).bytes.suffix = "\x03\x04"];
+  // }
+  // ```
+  optional bytes suffix = 6 [(predefined).cel = {
+    id: "bytes.suffix"
+    expression: "!this.endsWith(rules.suffix) ? 'does not have suffix %x'.format([rules.suffix]) : ''"
+  }];
+
+  // `contains` requires the field value to have the specified bytes anywhere in
+  // the string.
+  // If the field value doesn't meet the requirement, an error message is generated.
+  //
+  // ```proto
+  // message MyBytes {
+  //   // value does not contain \x02\x03
+  //   optional bytes value = 1 [(buf.validate.field).bytes.contains = "\x02\x03"];
+  // }
+  // ```
+  optional bytes contains = 7 [(predefined).cel = {
+    id: "bytes.contains"
+    expression: "!this.contains(rules.contains) ? 'does not contain %x'.format([rules.contains]) : ''"
+  }];
+
+  // `in` requires the field value to be equal to one of the specified
+  // values. If the field value doesn't match any of the specified values, an
+  // error message is generated.
+  //
+  // ```proto
+  // message MyBytes {
+  //   // value must in ["\x01\x02", "\x02\x03", "\x03\x04"]
+  //   optional bytes value = 1 [(buf.validate.field).bytes.in = {"\x01\x02", "\x02\x03", "\x03\x04"}];
+  // }
+  // ```
+  repeated bytes in = 8 [(predefined).cel = {
+    id: "bytes.in"
+    expression: "getField(rules, 'in').size() > 0 && !(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
+  }];
+
+  // `not_in` requires the field value to be not equal to any of the specified
+  // values.
+  // If the field value matches any of the specified values, an error message is
+  // generated.
+  //
+  // ```proto
+  // message MyBytes {
+  //   // value must not in ["\x01\x02", "\x02\x03", "\x03\x04"]
+  //   optional bytes value = 1 [(buf.validate.field).bytes.not_in = {"\x01\x02", "\x02\x03", "\x03\x04"}];
+  // }
+  // ```
+  repeated bytes not_in = 9 [(predefined).cel = {
+    id: "bytes.not_in"
+    expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
+  }];
+
+  // WellKnown rules provide advanced rules against common byte
+  // patterns
+  oneof well_known {
+    // `ip` ensures that the field `value` is a valid IP address (v4 or v6) in byte format.
+    // If the field value doesn't meet this rule, an error message is generated.
+    //
+    // ```proto
+    // message MyBytes {
+    //   // must be a valid IP address
+    //   optional bytes value = 1 [(buf.validate.field).bytes.ip = true];
+    // }
+    // ```
+    bool ip = 10 [
+      (predefined).cel = {
+        id: "bytes.ip"
+        message: "must be a valid IP address"
+        expression: "!rules.ip || this.size() == 0 || this.size() == 4 || this.size() == 16"
+      },
+      (predefined).cel = {
+        id: "bytes.ip_empty"
+        message: "value is empty, which is not a valid IP address"
+        expression: "!rules.ip || this.size() != 0"
+      }
+    ];
+
+    // `ipv4` ensures that the field `value` is a valid IPv4 address in byte format.
+    // If the field value doesn't meet this rule, an error message is generated.
+    //
+    // ```proto
+    // message MyBytes {
+    //   // must be a valid IPv4 address
+    //   optional bytes value = 1 [(buf.validate.field).bytes.ipv4 = true];
+    // }
+    // ```
+    bool ipv4 = 11 [
+      (predefined).cel = {
+        id: "bytes.ipv4"
+        message: "must be a valid IPv4 address"
+        expression: "!rules.ipv4 || this.size() == 0 || this.size() == 4"
+      },
+      (predefined).cel = {
+        id: "bytes.ipv4_empty"
+        message: "value is empty, which is not a valid IPv4 address"
+        expression: "!rules.ipv4 || this.size() != 0"
+      }
+    ];
+
+    // `ipv6` ensures that the field `value` is a valid IPv6 address in byte format.
+    // If the field value doesn't meet this rule, an error message is generated.
+    // ```proto
+    // message MyBytes {
+    //   // must be a valid IPv6 address
+    //   optional bytes value = 1 [(buf.validate.field).bytes.ipv6 = true];
+    // }
+    // ```
+    bool ipv6 = 12 [
+      (predefined).cel = {
+        id: "bytes.ipv6"
+        message: "must be a valid IPv6 address"
+        expression: "!rules.ipv6 || this.size() == 0 || this.size() == 16"
+      },
+      (predefined).cel = {
+        id: "bytes.ipv6_empty"
+        message: "value is empty, which is not a valid IPv6 address"
+        expression: "!rules.ipv6 || this.size() != 0"
+      }
+    ];
+
+    // `uuid` ensures that the field value encodes 128-bit UUID data as defined
+    // by [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.2).
+    // The field must contain exactly 16 bytes representing the UUID. If the
+    // field value isn't a valid UUID, an error message will be generated.
+    //
+    // ```proto
+    // message MyBytes {
+    //   // must be a valid UUID
+    //   optional bytes value = 1 [(buf.validate.field).bytes.uuid = true];
+    // }
+    // ```
+    bool uuid = 15 [
+      (predefined).cel = {
+        id: "bytes.uuid"
+        message: "must be a valid UUID"
+        expression: "!rules.uuid || this.size() == 0 || this.size() == 16"
+      },
+      (predefined).cel = {
+        id: "bytes.uuid_empty"
+        message: "value is empty, which is not a valid UUID"
+        expression: "!rules.uuid || this.size() != 0"
+      }
+    ];
+  }
+
+  // `example` specifies values that the field may have. These values SHOULD
+  // conform to other rules. `example` values will not impact validation
+  // but may be used as helpful guidance on how to populate the given field.
+  //
+  // ```proto
+  // message MyBytes {
+  //   bytes value = 1 [
+  //     (buf.validate.field).bytes.example = "\x01\x02",
+  //     (buf.validate.field).bytes.example = "\x02\x03"
+  //   ];
+  // }
+  // ```
+  repeated bytes example = 14 [(predefined).cel = {
+    id: "bytes.example"
+    expression: "true"
+  }];
+
+  // Extension fields that have the (buf.validate.predefined) option set
+  // will be treated as predefined field rules.
+  // See https://protovalidate.com/schemas/predefined-rules/
+  extensions 1000 to max;
+}
+
+// EnumRules describe the rules applied to `enum` values.
+message EnumRules {
+  // `const` requires the field value to exactly match the specified enum value.
+  // If the field value doesn't match, an error message is generated.
+  //
+  // ```proto
+  // enum MyEnum {
+  //   MY_ENUM_UNSPECIFIED = 0;
+  //   MY_ENUM_VALUE1 = 1;
+  //   MY_ENUM_VALUE2 = 2;
+  // }
+  //
+  // message MyMessage {
+  //   // The field `value` must be exactly MY_ENUM_VALUE1.
+  //   MyEnum value = 1 [(buf.validate.field).enum.const = 1];
+  // }
+  // ```
+  optional int32 const = 1 [(predefined).cel = {
+    id: "enum.const"
+    expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
+  }];
+
+  // `defined_only` requires the field value to be one of the defined values for
+  // this enum, failing on any undefined value.
+  //
+  // ```proto
+  // enum MyEnum {
+  //   MY_ENUM_UNSPECIFIED = 0;
+  //   MY_ENUM_VALUE1 = 1;
+  //   MY_ENUM_VALUE2 = 2;
+  // }
+  //
+  // message MyMessage {
+  //   // The field `value` must be a defined value of MyEnum.
+  //   MyEnum value = 1 [(buf.validate.field).enum.defined_only = true];
+  // }
+  // ```
+  optional bool defined_only = 2;
+
+  // `in` requires the field value to be equal to one of the
+  // specified enum values. If the field value doesn't match any of the
+  // specified values, an error message is generated.
+  //
+  // ```proto
+  // enum MyEnum {
+  //   MY_ENUM_UNSPECIFIED = 0;
+  //   MY_ENUM_VALUE1 = 1;
+  //   MY_ENUM_VALUE2 = 2;
+  // }
+  //
+  // message MyMessage {
+  //   // The field `value` must be equal to one of the specified values.
+  //   MyEnum value = 1 [(buf.validate.field).enum = { in: [1, 2]}];
+  // }
+  // ```
+  repeated int32 in = 3 [(predefined).cel = {
+    id: "enum.in"
+    expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
+  }];
+
+  // `not_in` requires the field value to be not equal to any of the
+  // specified enum values. If the field value matches one of the specified
+  // values, an error message is generated.
+  //
+  // ```proto
+  // enum MyEnum {
+  //   MY_ENUM_UNSPECIFIED = 0;
+  //   MY_ENUM_VALUE1 = 1;
+  //   MY_ENUM_VALUE2 = 2;
+  // }
+  //
+  // message MyMessage {
+  //   // The field `value` must not be equal to any of the specified values.
+  //   MyEnum value = 1 [(buf.validate.field).enum = { not_in: [1, 2]}];
+  // }
+  // ```
+  repeated int32 not_in = 4 [(predefined).cel = {
+    id: "enum.not_in"
+    expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
+  }];
+
+  // `example` specifies values that the field may have. These values SHOULD
+  // conform to other rules. `example` values will not impact validation
+  // but may be used as helpful guidance on how to populate the given field.
+  //
+  // ```proto
+  // enum MyEnum {
+  //   MY_ENUM_UNSPECIFIED = 0;
+  //   MY_ENUM_VALUE1 = 1;
+  //   MY_ENUM_VALUE2 = 2;
+  // }
+  //
+  // message MyMessage {
+  //     (buf.validate.field).enum.example = 1,
+  //     (buf.validate.field).enum.example = 2
+  // }
+  // ```
+  repeated int32 example = 5 [(predefined).cel = {
+    id: "enum.example"
+    expression: "true"
+  }];
+
+  // Extension fields that have the (buf.validate.predefined) option set
+  // will be treated as predefined field rules.
+  // See https://protovalidate.com/schemas/predefined-rules/
+  extensions 1000 to max;
+}
+
+// RepeatedRules describe the rules applied to `repeated` values.
+message RepeatedRules {
+  // `min_items` requires that this field must contain at least the specified
+  // minimum number of items.
+  //
+  // Note that `min_items = 1` is equivalent to setting a field as `required`.
+  //
+  // ```proto
+  // message MyRepeated {
+  //   // value must contain at least  2 items
+  //   repeated string value = 1 [(buf.validate.field).repeated.min_items = 2];
+  // }
+  // ```
+  optional uint64 min_items = 1 [(predefined).cel = {
+    id: "repeated.min_items"
+    expression: "uint(this.size()) < rules.min_items ? 'must contain at least %d item(s)'.format([rules.min_items]) : ''"
+  }];
+
+  // `max_items` denotes that this field must not exceed a
+  // certain number of items as the upper limit. If the field contains more
+  // items than specified, an error message will be generated, requiring the
+  // field to maintain no more than the specified number of items.
+  //
+  // ```proto
+  // message MyRepeated {
+  //   // value must contain no more than 3 item(s)
+  //   repeated string value = 1 [(buf.validate.field).repeated.max_items = 3];
+  // }
+  // ```
+  optional uint64 max_items = 2 [(predefined).cel = {
+    id: "repeated.max_items"
+    expression: "uint(this.size()) > rules.max_items ? 'must contain no more than %s item(s)'.format([rules.max_items]) : ''"
+  }];
+
+  // `unique` indicates that all elements in this field must
+  // be unique. This rule is strictly applicable to scalar and enum
+  // types, with message types not being supported.
+  //
+  // ```proto
+  // message MyRepeated {
+  //   // repeated value must contain unique items
+  //   repeated string value = 1 [(buf.validate.field).repeated.unique = true];
+  // }
+  // ```
+  optional bool unique = 3 [(predefined).cel = {
+    id: "repeated.unique"
+    message: "repeated value must contain unique items"
+    expression: "!rules.unique || this.unique()"
+  }];
+
+  // `items` details the rules to be applied to each item
+  // in the field. Even for repeated message fields, validation is executed
+  // against each item unless `ignore` is specified.
+  //
+  // ```proto
+  // message MyRepeated {
+  //   // The items in the field `value` must follow the specified rules.
+  //   repeated string value = 1 [(buf.validate.field).repeated.items = {
+  //     string: {
+  //       min_len: 3
+  //       max_len: 10
+  //     }
+  //   }];
+  // }
+  // ```
+  //
+  // Note that the `required` rule does not apply. Repeated items
+  // cannot be unset.
+  optional FieldRules items = 4;
+
+  // Extension fields that have the (buf.validate.predefined) option set
+  // will be treated as predefined field rules.
+  // See https://protovalidate.com/schemas/predefined-rules/
+  extensions 1000 to max;
+}
+
+// MapRules describe the rules applied to `map` values.
+message MapRules {
+  // Specifies the minimum number of key-value pairs allowed. If the field has
+  // fewer key-value pairs than specified, an error message is generated.
+  //
+  // ```proto
+  // message MyMap {
+  //   // The field `value` must have at least 2 key-value pairs.
+  //   map<string, string> value = 1 [(buf.validate.field).map.min_pairs = 2];
+  // }
+  // ```
+  optional uint64 min_pairs = 1 [(predefined).cel = {
+    id: "map.min_pairs"
+    expression: "uint(this.size()) < rules.min_pairs ? 'map must be at least %d entries'.format([rules.min_pairs]) : ''"
+  }];
+
+  // Specifies the maximum number of key-value pairs allowed. If the field has
+  // more key-value pairs than specified, an error message is generated.
+  //
+  // ```proto
+  // message MyMap {
+  //   // The field `value` must have at most 3 key-value pairs.
+  //   map<string, string> value = 1 [(buf.validate.field).map.max_pairs = 3];
+  // }
+  // ```
+  optional uint64 max_pairs = 2 [(predefined).cel = {
+    id: "map.max_pairs"
+    expression: "uint(this.size()) > rules.max_pairs ? 'map must be at most %d entries'.format([rules.max_pairs]) : ''"
+  }];
+
+  // Specifies the rules to be applied to each key in the field.
+  //
+  // ```proto
+  // message MyMap {
+  //   // The keys in the field `value` must follow the specified rules.
+  //   map<string, string> value = 1 [(buf.validate.field).map.keys = {
+  //     string: {
+  //       min_len: 3
+  //       max_len: 10
+  //     }
+  //   }];
+  // }
+  // ```
+  //
+  // Note that the `required` rule does not apply. Map keys cannot be unset.
+  optional FieldRules keys = 4;
+
+  // Specifies the rules to be applied to the value of each key in the
+  // field. Message values will still have their validations evaluated unless
+  // `ignore` is specified.
+  //
+  // ```proto
+  // message MyMap {
+  //   // The values in the field `value` must follow the specified rules.
+  //   map<string, string> value = 1 [(buf.validate.field).map.values = {
+  //     string: {
+  //       min_len: 5
+  //       max_len: 20
+  //     }
+  //   }];
+  // }
+  // ```
+  // Note that the `required` rule does not apply. Map values cannot be unset.
+  optional FieldRules values = 5;
+
+  // Extension fields that have the (buf.validate.predefined) option set
+  // will be treated as predefined field rules.
+  // See https://protovalidate.com/schemas/predefined-rules/
+  extensions 1000 to max;
+}
+
+// AnyRules describe rules applied exclusively to the `google.protobuf.Any` well-known type.
+message AnyRules {
+  // `in` requires the field's `type_url` to be equal to one of the
+  // specified values. If it doesn't match any of the specified values, an error
+  // message is generated.
+  //
+  // ```proto
+  // message MyAny {
+  //   //  The `value` field must have a `type_url` equal to one of the specified values.
+  //   google.protobuf.Any value = 1 [(buf.validate.field).any = {
+  //       in: ["type.googleapis.com/MyType1", "type.googleapis.com/MyType2"]
+  //   }];
+  // }
+  // ```
+  repeated string in = 2;
+
+  // `not_in` requires the field's type_url to be not equal to any of the specified values. If it matches any of the specified values, an error message is generated.
+  //
+  // ```proto
+  // message MyAny {
+  //   //  The `value` field must not have a `type_url` equal to any of the specified values.
+  //   google.protobuf.Any value = 1 [(buf.validate.field).any = {
+  //       not_in: ["type.googleapis.com/ForbiddenType1", "type.googleapis.com/ForbiddenType2"]
+  //   }];
+  // }
+  // ```
+  repeated string not_in = 3;
+}
+
+// DurationRules describe the rules applied exclusively to the `google.protobuf.Duration` well-known type.
+message DurationRules {
+  // `const` dictates that the field must match the specified value of the `google.protobuf.Duration` type exactly.
+  // If the field's value deviates from the specified value, an error message
+  // will be generated.
+  //
+  // ```proto
+  // message MyDuration {
+  //   // value must equal 5s
+  //   google.protobuf.Duration value = 1 [(buf.validate.field).duration.const = "5s"];
+  // }
+  // ```
+  optional google.protobuf.Duration const = 2 [(predefined).cel = {
+    id: "duration.const"
+    expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
+  }];
+  oneof less_than {
+    // `lt` stipulates that the field must be less than the specified value of the `google.protobuf.Duration` type,
+    // exclusive. If the field's value is greater than or equal to the specified
+    // value, an error message will be generated.
+    //
+    // ```proto
+    // message MyDuration {
+    //   // must be less than 5s
+    //   google.protobuf.Duration value = 1 [(buf.validate.field).duration.lt = "5s"];
+    // }
+    // ```
+    google.protobuf.Duration lt = 3 [(predefined).cel = {
+      id: "duration.lt"
+      expression:
+        "!has(rules.gte) && !has(rules.gt) && this >= rules.lt"
+        "? 'must be less than %s'.format([rules.lt]) : ''"
+    }];
+
+    // `lte` indicates that the field must be less than or equal to the specified
+    // value of the `google.protobuf.Duration` type, inclusive. If the field's value is greater than the specified value,
+    // an error message will be generated.
+    //
+    // ```proto
+    // message MyDuration {
+    //   // must be less than or equal to 10s
+    //   google.protobuf.Duration value = 1 [(buf.validate.field).duration.lte = "10s"];
+    // }
+    // ```
+    google.protobuf.Duration lte = 4 [(predefined).cel = {
+      id: "duration.lte"
+      expression:
+        "!has(rules.gte) && !has(rules.gt) && this > rules.lte"
+        "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
+    }];
+  }
+  oneof greater_than {
+    // `gt` requires the duration field value to be greater than the specified
+    // value (exclusive). If the value of `gt` is larger than a specified `lt`
+    // or `lte`, the range is reversed, and the field value must be outside the
+    // specified range. If the field value doesn't meet the required conditions,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MyDuration {
+    //   // duration must be greater than 5s [duration.gt]
+    //   google.protobuf.Duration value = 1 [(buf.validate.field).duration.gt = { seconds: 5 }];
+    //
+    //   // duration must be greater than 5s and less than 10s [duration.gt_lt]
+    //   google.protobuf.Duration another_value = 2 [(buf.validate.field).duration = { gt: { seconds: 5 }, lt: { seconds: 10 } }];
+    //
+    //   // duration must be greater than 10s or less than 5s [duration.gt_lt_exclusive]
+    //   google.protobuf.Duration other_value = 3 [(buf.validate.field).duration = { gt: { seconds: 10 }, lt: { seconds: 5 } }];
+    // }
+    // ```
+    google.protobuf.Duration gt = 5 [
+      (predefined).cel = {
+        id: "duration.gt"
+        expression:
+          "!has(rules.lt) && !has(rules.lte) && this <= rules.gt"
+          "? 'must be greater than %s'.format([rules.gt]) : ''"
+      },
+      (predefined).cel = {
+        id: "duration.gt_lt"
+        expression:
+          "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)"
+          "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "duration.gt_lt_exclusive"
+        expression:
+          "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)"
+          "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "duration.gt_lte"
+        expression:
+          "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)"
+          "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
+      },
+      (predefined).cel = {
+        id: "duration.gt_lte_exclusive"
+        expression:
+          "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)"
+          "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
+      }
+    ];
+
+    // `gte` requires the duration field value to be greater than or equal to the
+    // specified value (exclusive). If the value of `gte` is larger than a
+    // specified `lt` or `lte`, the range is reversed, and the field value must
+    // be outside the specified range. If the field value doesn't meet the
+    // required conditions, an error message is generated.
+    //
+    // ```proto
+    // message MyDuration {
+    //  // duration must be greater than or equal to 5s [duration.gte]
+    //  google.protobuf.Duration value = 1 [(buf.validate.field).duration.gte = { seconds: 5 }];
+    //
+    //  // duration must be greater than or equal to 5s and less than 10s [duration.gte_lt]
+    //  google.protobuf.Duration another_value = 2 [(buf.validate.field).duration = { gte: { seconds: 5 }, lt: { seconds: 10 } }];
+    //
+    //  // duration must be greater than or equal to 10s or less than 5s [duration.gte_lt_exclusive]
+    //  google.protobuf.Duration other_value = 3 [(buf.validate.field).duration = { gte: { seconds: 10 }, lt: { seconds: 5 } }];
+    // }
+    // ```
+    google.protobuf.Duration gte = 6 [
+      (predefined).cel = {
+        id: "duration.gte"
+        expression:
+          "!has(rules.lt) && !has(rules.lte) && this < rules.gte"
+          "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
+      },
+      (predefined).cel = {
+        id: "duration.gte_lt"
+        expression:
+          "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)"
+          "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "duration.gte_lt_exclusive"
+        expression:
+          "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)"
+          "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "duration.gte_lte"
+        expression:
+          "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)"
+          "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
+      },
+      (predefined).cel = {
+        id: "duration.gte_lte_exclusive"
+        expression:
+          "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)"
+          "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
+      }
+    ];
+  }
+
+  // `in` asserts that the field must be equal to one of the specified values of the `google.protobuf.Duration` type.
+  // If the field's value doesn't correspond to any of the specified values,
+  // an error message will be generated.
+  //
+  // ```proto
+  // message MyDuration {
+  //   // must be in list [1s, 2s, 3s]
+  //   google.protobuf.Duration value = 1 [(buf.validate.field).duration.in = ["1s", "2s", "3s"]];
+  // }
+  // ```
+  repeated google.protobuf.Duration in = 7 [(predefined).cel = {
+    id: "duration.in"
+    expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''"
+  }];
+
+  // `not_in` denotes that the field must not be equal to
+  // any of the specified values of the `google.protobuf.Duration` type.
+  // If the field's value matches any of these values, an error message will be
+  // generated.
+  //
+  // ```proto
+  // message MyDuration {
+  //   // value must not be in list [1s, 2s, 3s]
+  //   google.protobuf.Duration value = 1 [(buf.validate.field).duration.not_in = ["1s", "2s", "3s"]];
+  // }
+  // ```
+  repeated google.protobuf.Duration not_in = 8 [(predefined).cel = {
+    id: "duration.not_in"
+    expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''"
+  }];
+
+  // `example` specifies values that the field may have. These values SHOULD
+  // conform to other rules. `example` values will not impact validation
+  // but may be used as helpful guidance on how to populate the given field.
+  //
+  // ```proto
+  // message MyDuration {
+  //   google.protobuf.Duration value = 1 [
+  //     (buf.validate.field).duration.example = { seconds: 1 },
+  //     (buf.validate.field).duration.example = { seconds: 2 },
+  //   ];
+  // }
+  // ```
+  repeated google.protobuf.Duration example = 9 [(predefined).cel = {
+    id: "duration.example"
+    expression: "true"
+  }];
+
+  // Extension fields that have the (buf.validate.predefined) option set
+  // will be treated as predefined field rules.
+  // See https://protovalidate.com/schemas/predefined-rules/
+  extensions 1000 to max;
+}
+
+// FieldMaskRules describe rules applied exclusively to the `google.protobuf.FieldMask` well-known type.
+message FieldMaskRules {
+  // `const` dictates that the field must match the specified value of the `google.protobuf.FieldMask` type exactly.
+  // If the field's value deviates from the specified value, an error message
+  // will be generated.
+  //
+  // ```proto
+  // message MyFieldMask {
+  //   // value must equal ["a"]
+  //   google.protobuf.FieldMask value = 1 [(buf.validate.field).field_mask.const = {
+  //       paths: ["a"]
+  //   }];
+  // }
+  // ```
+  optional google.protobuf.FieldMask const = 1 [(predefined).cel = {
+    id: "field_mask.const"
+    expression: "this.paths != getField(rules, 'const').paths ? 'must equal paths %s'.format([getField(rules, 'const').paths]) : ''"
+  }];
+
+  // `in` requires the field value to only contain paths matching specified
+  // values or their subpaths.
+  // If any of the field value's paths doesn't match the rule,
+  // an error message is generated.
+  // See: https://protobuf.dev/reference/protobuf/google.protobuf/#field-mask
+  //
+  // ```proto
+  // message MyFieldMask {
+  //   //  The `value` FieldMask must only contain paths listed in `in`.
+  //   google.protobuf.FieldMask value = 1 [(buf.validate.field).field_mask = {
+  //       in: ["a", "b", "c.a"]
+  //   }];
+  // }
+  // ```
+  repeated string in = 2 [(predefined).cel = {
+    id: "field_mask.in"
+    expression: "!this.paths.all(p, p in getField(rules, 'in') || getField(rules, 'in').exists(f, p.startsWith(f+'.'))) ? 'must only contain paths in %s'.format([getField(rules, 'in')]) : ''"
+  }];
+
+  // `not_in` requires the field value to not contain paths matching specified
+  // values or their subpaths.
+  // If any of the field value's paths matches the rule,
+  // an error message is generated.
+  // See: https://protobuf.dev/reference/protobuf/google.protobuf/#field-mask
+  //
+  // ```proto
+  // message MyFieldMask {
+  //   //  The `value` FieldMask shall not contain paths listed in `not_in`.
+  //   google.protobuf.FieldMask value = 1 [(buf.validate.field).field_mask = {
+  //       not_in: ["forbidden", "immutable", "c.a"]
+  //   }];
+  // }
+  // ```
+  repeated string not_in = 3 [(predefined).cel = {
+    id: "field_mask.not_in"
+    expression: "!this.paths.all(p, !(p in getField(rules, 'not_in') || getField(rules, 'not_in').exists(f, p.startsWith(f+'.')))) ? 'must not contain any paths in %s'.format([getField(rules, 'not_in')]) : ''"
+  }];
+
+  // `example` specifies values that the field may have. These values SHOULD
+  // conform to other rules. `example` values will not impact validation
+  // but may be used as helpful guidance on how to populate the given field.
+  //
+  // ```proto
+  // message MyFieldMask {
+  //   google.protobuf.FieldMask value = 1 [
+  //     (buf.validate.field).field_mask.example = { paths: ["a", "b"] },
+  //     (buf.validate.field).field_mask.example = { paths: ["c.a", "d"] },
+  //   ];
+  // }
+  // ```
+  repeated google.protobuf.FieldMask example = 4 [(predefined).cel = {
+    id: "field_mask.example"
+    expression: "true"
+  }];
+
+  // Extension fields that have the (buf.validate.predefined) option set
+  // will be treated as predefined field rules.
+  // See https://protovalidate.com/schemas/predefined-rules/
+  extensions 1000 to max;
+}
+
+// TimestampRules describe the rules applied exclusively to the `google.protobuf.Timestamp` well-known type.
+message TimestampRules {
+  // `const` dictates that this field, of the `google.protobuf.Timestamp` type, must exactly match the specified value. If the field value doesn't correspond to the specified timestamp, an error message will be generated.
+  //
+  // ```proto
+  // message MyTimestamp {
+  //   // value must equal 2023-05-03T10:00:00Z
+  //   google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.const = {seconds: 1727998800}];
+  // }
+  // ```
+  optional google.protobuf.Timestamp const = 2 [(predefined).cel = {
+    id: "timestamp.const"
+    expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''"
+  }];
+  oneof less_than {
+    // `lt` requires the timestamp field value to be less than the specified value (field < value). If the field value doesn't meet the required conditions, an error message is generated.
+    //
+    // ```proto
+    // message MyTimestamp {
+    //   // timestamp must be less than '2023-01-01T00:00:00Z' [timestamp.lt]
+    //   google.protobuf.Timestamp value = 1 [(buf.validate.field).timestamp.lt = { seconds: 1672444800 }];
+    // }
+    // ```
+    google.protobuf.Timestamp lt = 3 [(predefined).cel = {
+      id: "timestamp.lt"
+      expression:
+        "!has(rules.gte) && !has(rules.gt) && this >= rules.lt"
+        "? 'must be less than %s'.format([rules.lt]) : ''"
+    }];
+
+    // `lte` requires the timestamp field value to be less than or equal to the specified value (field <= value). If the field value doesn't meet the required conditions, an error message is generated.
+    //
+    // ```proto
+    // message MyTimestamp {
+    //   // timestamp must be less than or equal to '2023-05-14T00:00:00Z' [timestamp.lte]
+    //   google.protobuf.Timestamp value = 1 [(buf.validate.field).timestamp.lte = { seconds: 1678867200 }];
+    // }
+    // ```
+    google.protobuf.Timestamp lte = 4 [(predefined).cel = {
+      id: "timestamp.lte"
+      expression:
+        "!has(rules.gte) && !has(rules.gt) && this > rules.lte"
+        "? 'must be less than or equal to %s'.format([rules.lte]) : ''"
+    }];
+
+    // `lt_now` specifies that this field, of the `google.protobuf.Timestamp` type, must be less than the current time. `lt_now` can only be used with the `within` rule.
+    //
+    // ```proto
+    // message MyTimestamp {
+    //  // must be less than now
+    //   google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.lt_now = true];
+    // }
+    // ```
+    bool lt_now = 7 [(predefined).cel = {
+      id: "timestamp.lt_now"
+      expression: "(rules.lt_now && this > now) ? 'must be less than now' : ''"
+    }];
+  }
+  oneof greater_than {
+    // `gt` requires the timestamp field value to be greater than the specified
+    // value (exclusive). If the value of `gt` is larger than a specified `lt`
+    // or `lte`, the range is reversed, and the field value must be outside the
+    // specified range. If the field value doesn't meet the required conditions,
+    // an error message is generated.
+    //
+    // ```proto
+    // message MyTimestamp {
+    //   // timestamp must be greater than '2023-01-01T00:00:00Z' [timestamp.gt]
+    //   google.protobuf.Timestamp value = 1 [(buf.validate.field).timestamp.gt = { seconds: 1672444800 }];
+    //
+    //   // timestamp must be greater than '2023-01-01T00:00:00Z' and less than '2023-01-02T00:00:00Z' [timestamp.gt_lt]
+    //   google.protobuf.Timestamp another_value = 2 [(buf.validate.field).timestamp = { gt: { seconds: 1672444800 }, lt: { seconds: 1672531200 } }];
+    //
+    //   // timestamp must be greater than '2023-01-02T00:00:00Z' or less than '2023-01-01T00:00:00Z' [timestamp.gt_lt_exclusive]
+    //   google.protobuf.Timestamp other_value = 3 [(buf.validate.field).timestamp = { gt: { seconds: 1672531200 }, lt: { seconds: 1672444800 } }];
+    // }
+    // ```
+    google.protobuf.Timestamp gt = 5 [
+      (predefined).cel = {
+        id: "timestamp.gt"
+        expression:
+          "!has(rules.lt) && !has(rules.lte) && this <= rules.gt"
+          "? 'must be greater than %s'.format([rules.gt]) : ''"
+      },
+      (predefined).cel = {
+        id: "timestamp.gt_lt"
+        expression:
+          "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)"
+          "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "timestamp.gt_lt_exclusive"
+        expression:
+          "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)"
+          "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "timestamp.gt_lte"
+        expression:
+          "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)"
+          "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
+      },
+      (predefined).cel = {
+        id: "timestamp.gt_lte_exclusive"
+        expression:
+          "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)"
+          "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''"
+      }
+    ];
+
+    // `gte` requires the timestamp field value to be greater than or equal to the
+    // specified value (exclusive). If the value of `gte` is larger than a
+    // specified `lt` or `lte`, the range is reversed, and the field value
+    // must be outside the specified range. If the field value doesn't meet
+    // the required conditions, an error message is generated.
+    //
+    // ```proto
+    // message MyTimestamp {
+    //   // timestamp must be greater than or equal to '2023-01-01T00:00:00Z' [timestamp.gte]
+    //   google.protobuf.Timestamp value = 1 [(buf.validate.field).timestamp.gte = { seconds: 1672444800 }];
+    //
+    //   // timestamp must be greater than or equal to '2023-01-01T00:00:00Z' and less than '2023-01-02T00:00:00Z' [timestamp.gte_lt]
+    //   google.protobuf.Timestamp another_value = 2 [(buf.validate.field).timestamp = { gte: { seconds: 1672444800 }, lt: { seconds: 1672531200 } }];
+    //
+    //   // timestamp must be greater than or equal to '2023-01-02T00:00:00Z' or less than '2023-01-01T00:00:00Z' [timestamp.gte_lt_exclusive]
+    //   google.protobuf.Timestamp other_value = 3 [(buf.validate.field).timestamp = { gte: { seconds: 1672531200 }, lt: { seconds: 1672444800 } }];
+    // }
+    // ```
+    google.protobuf.Timestamp gte = 6 [
+      (predefined).cel = {
+        id: "timestamp.gte"
+        expression:
+          "!has(rules.lt) && !has(rules.lte) && this < rules.gte"
+          "? 'must be greater than or equal to %s'.format([rules.gte]) : ''"
+      },
+      (predefined).cel = {
+        id: "timestamp.gte_lt"
+        expression:
+          "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)"
+          "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "timestamp.gte_lt_exclusive"
+        expression:
+          "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)"
+          "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''"
+      },
+      (predefined).cel = {
+        id: "timestamp.gte_lte"
+        expression:
+          "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)"
+          "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
+      },
+      (predefined).cel = {
+        id: "timestamp.gte_lte_exclusive"
+        expression:
+          "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)"
+          "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''"
+      }
+    ];
+
+    // `gt_now` specifies that this field, of the `google.protobuf.Timestamp` type, must be greater than the current time. `gt_now` can only be used with the `within` rule.
+    //
+    // ```proto
+    // message MyTimestamp {
+    //   // must be greater than now
+    //   google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.gt_now = true];
+    // }
+    // ```
+    bool gt_now = 8 [(predefined).cel = {
+      id: "timestamp.gt_now"
+      expression: "(rules.gt_now && this < now) ? 'must be greater than now' : ''"
+    }];
+  }
+
+  // `within` specifies that this field, of the `google.protobuf.Timestamp` type, must be within the specified duration of the current time. If the field value isn't within the duration, an error message is generated.
+  //
+  // ```proto
+  // message MyTimestamp {
+  //   // must be within 1 hour of now
+  //   google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.within = {seconds: 3600}];
+  // }
+  // ```
+  optional google.protobuf.Duration within = 9 [(predefined).cel = {
+    id: "timestamp.within"
+    expression: "this < now-rules.within || this > now+rules.within ? 'must be within %s of now'.format([rules.within]) : ''"
+  }];
+
+  // `example` specifies values that the field may have. These values SHOULD
+  // conform to other rules. `example` values will not impact validation
+  // but may be used as helpful guidance on how to populate the given field.
+  //
+  // ```proto
+  // message MyTimestamp {
+  //   google.protobuf.Timestamp value = 1 [
+  //     (buf.validate.field).timestamp.example = { seconds: 1672444800 },
+  //     (buf.validate.field).timestamp.example = { seconds: 1672531200 },
+  //   ];
+  // }
+  // ```
+  repeated google.protobuf.Timestamp example = 10 [(predefined).cel = {
+    id: "timestamp.example"
+    expression: "true"
+  }];
+
+  // Extension fields that have the (buf.validate.predefined) option set
+  // will be treated as predefined field rules.
+  // See https://protovalidate.com/schemas/predefined-rules/
+  extensions 1000 to max;
+}
+
+// `Violations` is a collection of `Violation` messages. This message type is returned by
+// Protovalidate when a proto message fails to meet the requirements set by the `Rule` validation rules.
+// Each individual violation is represented by a `Violation` message.
+message Violations {
+  // `violations` is a repeated field that contains all the `Violation` messages corresponding to the violations detected.
+  repeated Violation violations = 1;
+}
+
+// `Violation` represents a single instance where a validation rule, expressed
+// as a `Rule`, was not met. It provides information about the field that
+// caused the violation, the specific rule that wasn't fulfilled, and a
+// human-readable error message.
+//
+// For example, consider the following message:
+//
+// ```proto
+// message User {
+//     int32 age = 1 [(buf.validate.field).cel = {
+//         id: "user.age",
+//         expression: "this < 18 ? 'User must be at least 18 years old' : ''",
+//     }];
+// }
+// ```
+//
+// It could produce the following violation:
+//
+// ```json
+// {
+//   "ruleId": "user.age",
+//   "message": "User must be at least 18 years old",
+//   "field": {
+//     "elements": [
+//       {
+//         "fieldNumber": 1,
+//         "fieldName": "age",
+//         "fieldType": "TYPE_INT32"
+//       }
+//     ]
+//   },
+//   "rule": {
+//     "elements": [
+//       {
+//         "fieldNumber": 23,
+//         "fieldName": "cel",
+//         "fieldType": "TYPE_MESSAGE",
+//         "index": "0"
+//       }
+//     ]
+//   }
+// }
+// ```
+message Violation {
+  // `field` is a machine-readable path to the field that failed validation.
+  // This could be a nested field, in which case the path will include all the parent fields leading to the actual field that caused the violation.
+  //
+  // For example, consider the following message:
+  //
+  // ```proto
+  // message Message {
+  //   bool a = 1 [(buf.validate.field).required = true];
+  // }
+  // ```
+  //
+  // It could produce the following violation:
+  //
+  // ```textproto
+  // violation {
+  //   field { element { field_number: 1, field_name: "a", field_type: 8 } }
+  //   ...
+  // }
+  // ```
+  optional FieldPath field = 5;
+
+  // `rule` is a machine-readable path that points to the specific rule that failed validation.
+  // This will be a nested field starting from the FieldRules of the field that failed validation.
+  // For custom rules, this will provide the path of the rule, e.g. `cel[0]`.
+  //
+  // For example, consider the following message:
+  //
+  // ```proto
+  // message Message {
+  //   bool a = 1 [(buf.validate.field).required = true];
+  //   bool b = 2 [(buf.validate.field).cel = {
+  //     id: "custom_rule",
+  //     expression: "!this ? 'b must be true': ''"
+  //   }]
+  // }
+  // ```
+  //
+  // It could produce the following violations:
+  //
+  // ```textproto
+  // violation {
+  //   rule { element { field_number: 25, field_name: "required", field_type: 8 } }
+  //   ...
+  // }
+  // violation {
+  //   rule { element { field_number: 23, field_name: "cel", field_type: 11, index: 0 } }
+  //   ...
+  // }
+  // ```
+  optional FieldPath rule = 6;
+
+  // `rule_id` is the unique identifier of the `Rule` that was not fulfilled.
+  // This is the same `id` that was specified in the `Rule` message, allowing easy tracing of which rule was violated.
+  optional string rule_id = 2;
+
+  // `message` is a human-readable error message that describes the nature of the violation.
+  // This can be the default error message from the violated `Rule`, or it can be a custom message that gives more context about the violation.
+  optional string message = 3;
+
+  // `for_key` indicates whether the violation was caused by a map key, rather than a value.
+  optional bool for_key = 4;
+
+  reserved 1;
+  reserved "field_path";
+}
+
+// `FieldPath` provides a path to a nested protobuf field.
+//
+// This message provides enough information to render a dotted field path even without protobuf descriptors.
+// It also provides enough information to resolve a nested field through unknown wire data.
+message FieldPath {
+  // `elements` contains each element of the path, starting from the root and recursing downward.
+  repeated FieldPathElement elements = 1;
+}
+
+// `FieldPathElement` provides enough information to nest through a single protobuf field.
+//
+// If the selected field is a map or repeated field, the `subscript` value selects a specific element from it.
+// A path that refers to a value nested under a map key or repeated field index will have a `subscript` value.
+// The `field_type` field allows unambiguous resolution of a field even if descriptors are not available.
+message FieldPathElement {
+  // `field_number` is the field number this path element refers to.
+  optional int32 field_number = 1;
+
+  // `field_name` contains the field name this path element refers to.
+  // This can be used to display a human-readable path even if the field number is unknown.
+  optional string field_name = 2;
+
+  // `field_type` specifies the type of this field. When using reflection, this value is not needed.
+  //
+  // This value is provided to make it possible to traverse unknown fields through wire data.
+  // When traversing wire data, be mindful of both packed[1] and delimited[2] encoding schemes.
+  //
+  // [1]: https://protobuf.dev/programming-guides/encoding/#packed
+  // [2]: https://protobuf.dev/programming-guides/encoding/#groups
+  //
+  // N.B.: Although groups are deprecated, the corresponding delimited encoding scheme is not, and
+  // can be explicitly used in Protocol Buffers 2023 Edition.
+  optional google.protobuf.FieldDescriptorProto.Type field_type = 3;
+
+  // `key_type` specifies the map key type of this field. This value is useful when traversing
+  // unknown fields through wire data: specifically, it allows handling the differences between
+  // different integer encodings.
+  optional google.protobuf.FieldDescriptorProto.Type key_type = 4;
+
+  // `value_type` specifies map value type of this field. This is useful if you want to display a
+  // value inside unknown fields through wire data.
+  optional google.protobuf.FieldDescriptorProto.Type value_type = 5;
+
+  // `subscript` contains a repeated index or map key, if this path element nests into a repeated or map field.
+  oneof subscript {
+    // `index` specifies a 0-based index into a repeated field.
+    uint64 index = 6;
+
+    // `bool_key` specifies a map key of type bool.
+    bool bool_key = 7;
+
+    // `int_key` specifies a map key of type int32, int64, sint32, sint64, sfixed32 or sfixed64.
+    int64 int_key = 8;
+
+    // `uint_key` specifies a map key of type uint32, uint64, fixed32 or fixed64.
+    uint64 uint_key = 9;
+
+    // `string_key` specifies a map key of type string.
+    string string_key = 10;
+  }
+}

+ 98 - 0
proto/chatto/api/v1/notification_preferences.proto

@@ -0,0 +1,98 @@
+syntax = "proto3";
+
+package chatto.api.v1;
+
+import "buf/validate/validate.proto";
+
+// Notification delivery level for a room.
+enum NotificationLevel {
+  // The level was not specified.
+  NOTIFICATION_LEVEL_UNSPECIFIED = 0;
+  // Use the inherited default for the room.
+  NOTIFICATION_LEVEL_DEFAULT = 1;
+  // Do not notify for this room.
+  NOTIFICATION_LEVEL_MUTED = 2;
+  // Notify according to the normal room rules.
+  NOTIFICATION_LEVEL_NORMAL = 3;
+  // Notify for every message in the room.
+  NOTIFICATION_LEVEL_ALL_MESSAGES = 4;
+}
+
+// Stored and effective notification preference.
+message NotificationPreference {
+  // Explicit level stored for the current user.
+  NotificationLevel level = 1;
+  // Level after applying defaults and inheritance.
+  NotificationLevel effective_level = 2;
+}
+
+// Current notification preference.
+message GetNotificationPreferenceResponse {
+  // Field 1 was `level` and field 2 was `effective_level` before the shared
+  // NotificationPreference shape.
+  reserved 1, 2;
+  reserved "level", "effective_level";
+
+  // Current stored and effective notification preference.
+  NotificationPreference preference = 3;
+}
+
+// Updated notification preference.
+message UpdateNotificationPreferenceResponse {
+  // Field 1 was `level` and field 2 was `effective_level` before the shared
+  // NotificationPreference shape.
+  reserved 1, 2;
+  reserved "level", "effective_level";
+
+  // Stored and effective notification preference after the update.
+  NotificationPreference preference = 3;
+}
+
+// Request for the current user's server-level notification preference.
+message GetServerNotificationPreferenceRequest {}
+
+// Request to update the current user's server-level notification level.
+message UpdateServerNotificationPreferenceRequest {
+  // Required. New explicit notification level. Use NOTIFICATION_LEVEL_DEFAULT
+  // to return the server to default behavior.
+  NotificationLevel level = 1 [(buf.validate.field).enum = {
+    defined_only: true
+    not_in: [0]
+  }];
+}
+
+// Request for the current user's notification preference in one room.
+message GetRoomNotificationPreferenceRequest {
+  // Required. Room whose notification preference should be loaded for the current user.
+  string room_id = 1 [(buf.validate.field).string.min_len = 1];
+}
+
+// Request to update the current user's notification level in one room.
+message UpdateRoomNotificationPreferenceRequest {
+  // Required. Room whose notification level should be changed for the current user.
+  string room_id = 1 [(buf.validate.field).string.min_len = 1];
+  // Required. New explicit notification level. Use NOTIFICATION_LEVEL_DEFAULT
+  // to return the room to inherited/default behavior.
+  NotificationLevel level = 2 [(buf.validate.field).enum = {
+    defined_only: true
+    not_in: [0]
+  }];
+}
+
+// Reads and updates per-room notification preferences for the current user.
+service NotificationPreferencesService {
+  // Returns the current user's explicit and effective server notification level.
+  rpc GetServerNotificationPreference(GetServerNotificationPreferenceRequest) returns (GetNotificationPreferenceResponse);
+  // Updates the current user's explicit server notification level and returns the
+  // resulting stored and effective levels.
+  rpc UpdateServerNotificationPreference(UpdateServerNotificationPreferenceRequest) returns (UpdateNotificationPreferenceResponse);
+  // Returns the current user's explicit and effective notification level for a
+  // room. Use this before rendering room notification controls so the UI can
+  // distinguish inherited defaults from an explicit room override. Returns
+  // NOT_FOUND when the room does not exist and PERMISSION_DENIED when the room
+  // exists but is inaccessible to the caller.
+  rpc GetRoomNotificationPreference(GetRoomNotificationPreferenceRequest) returns (GetNotificationPreferenceResponse);
+  // Updates the current user's explicit notification level for a room and returns
+  // the resulting stored and effective levels.
+  rpc UpdateRoomNotificationPreference(UpdateRoomNotificationPreferenceRequest) returns (UpdateNotificationPreferenceResponse);
+}

+ 33 - 0
proto/chatto/api/v1/permissions.proto

@@ -0,0 +1,33 @@
+syntax = "proto3";
+
+package chatto.api.v1;
+
+// Effective decision for one permission key.
+message PermissionGrant {
+  // Stable permission key, such as "server.manage".
+  string permission = 1;
+  // Whether the permission is currently granted.
+  bool granted = 2;
+}
+
+// Effective decision for one capability key.
+//
+// Built-in keys currently include:
+// - admin.view
+// - dm.start
+// - admin.view-users
+// - user.manage-accounts
+// - role.assign
+// - role.view
+// - role.manage
+// - admin.view-system
+// - admin.view-audit
+// - user.manage-permissions
+//
+// Clients should ignore unknown keys so servers can add capabilities over time.
+message CapabilityGrant {
+  // Stable capability key, such as "admin.view" or "dm.start".
+  string capability = 1;
+  // Whether the capability is currently available.
+  bool granted = 2;
+}

+ 42 - 0
proto/chatto/api/v1/presence.proto

@@ -0,0 +1,42 @@
+syntax = "proto3";
+
+package chatto.api.v1;
+
+import "buf/validate/validate.proto";
+
+// Live presence status returned by public read APIs.
+//
+// Offline is a read-side state only. Clients cannot update their presence to
+// Offline through the account presence RPC; they should stop refreshing and let
+// the server's live presence record expire.
+enum PresenceStatus {
+  // No presence status was specified.
+  PRESENCE_STATUS_UNSPECIFIED = 0;
+  // The user is actively available.
+  PRESENCE_STATUS_ONLINE = 1;
+  // The user is connected but away or idle.
+  PRESENCE_STATUS_AWAY = 2;
+  // The user does not want notifications while this live status is active.
+  PRESENCE_STATUS_DO_NOT_DISTURB = 3;
+  // The user has no active live presence record.
+  PRESENCE_STATUS_OFFLINE = 4;
+}
+
+// Request to update the current user's live presence status.
+message UpdatePresenceRequest {
+  // Live status to store for the authenticated user. Offline is rejected.
+  PresenceStatus status = 1 [(buf.validate.field).enum = {
+    defined_only: true
+    not_in: [0, 4]
+  }];
+  // True when this update comes from a deliberate user selection rather than
+  // automatic idle/refresh updates. Automatic updates do not overwrite an
+  // active manually selected Away or Do Not Disturb status from another client.
+  bool user_selected = 2;
+}
+
+// Result of updating live presence.
+message UpdatePresenceResponse {
+  // Reportable status accepted and stored by the server.
+  PresenceStatus status = 1;
+}

+ 47 - 0
proto/chatto/api/v1/user_status.proto

@@ -0,0 +1,47 @@
+syntax = "proto3";
+
+package chatto.api.v1;
+
+import "buf/validate/validate.proto";
+import "google/protobuf/timestamp.proto";
+
+// Custom status shown on a user profile, separate from presence.
+message CustomUserStatus {
+  // Short emoji marker displayed with the status.
+  string emoji = 1 [(buf.validate.field).string = {
+    min_len: 1
+    max_len: 16
+  }];
+  // User-written status text.
+  string text = 2 [(buf.validate.field).string = {
+    min_len: 1
+    max_len: 100
+  }];
+  // Optional time after which clients should stop showing the status.
+  google.protobuf.Timestamp expires_at = 3;
+}
+
+// Request to update or replace the current user's custom status.
+message UpdateCustomStatusRequest {
+  // Short emoji marker displayed with the status.
+  string emoji = 1;
+  // User-written status text.
+  string text = 2;
+  // Optional future time after which clients should stop showing the status.
+  google.protobuf.Timestamp expires_at = 3;
+}
+
+// Result of updating the current user's custom status.
+message UpdateCustomStatusResponse {
+  // Stored custom status after validation and normalization.
+  CustomUserStatus status = 1;
+}
+
+// Request to delete the current user's custom status.
+message DeleteCustomStatusRequest {}
+
+// Result of deleting the current user's custom status.
+message DeleteCustomStatusResponse {
+  // Current custom status after the operation. Usually absent after a clear.
+  CustomUserStatus status = 1;
+}

+ 24 - 0
proto/chatto/api/v1/users.proto

@@ -0,0 +1,24 @@
+syntax = "proto3";
+
+package chatto.api.v1;
+
+import "chatto/api/v1/presence.proto";
+import "chatto/api/v1/user_status.proto";
+
+// Public user fields.
+message User {
+  // Stable user ID.
+  string id = 1;
+  // Login name.
+  string login = 2;
+  // Display name, when set.
+  string display_name = 3;
+  // True when the user account has been deleted.
+  bool deleted = 4;
+  // Avatar image URL, when available.
+  optional string avatar_url = 5;
+  // Current live presence status.
+  PresenceStatus presence_status = 6;
+  // Custom profile status, when set.
+  CustomUserStatus custom_status = 7;
+}

+ 105 - 0
proto/chatto/api/v1/viewer.proto

@@ -0,0 +1,105 @@
+syntax = "proto3";
+
+package chatto.api.v1;
+
+import "chatto/api/v1/notification_preferences.proto";
+import "chatto/api/v1/permissions.proto";
+import "chatto/api/v1/users.proto";
+import "google/protobuf/timestamp.proto";
+
+// User preference for rendering times in clients.
+enum TimeFormat {
+  // No explicit preference was stored.
+  TIME_FORMAT_UNSPECIFIED = 0;
+  // Let the client choose based on locale and browser settings.
+  TIME_FORMAT_AUTO = 1;
+  // Render times using a 12-hour clock.
+  TIME_FORMAT_12_HOUR = 2;
+  // Render times using a 24-hour clock.
+  TIME_FORMAT_24_HOUR = 3;
+}
+
+// Server-level display settings for the authenticated user.
+message UserSettings {
+  // Optional IANA timezone override. Absent means the client should use the
+  // browser's local timezone.
+  optional string timezone = 1;
+  // Preferred time format.
+  TimeFormat time_format = 2;
+}
+
+// Current authenticated user's public profile plus self-only settings.
+message ViewerUser {
+  reserved 1 to 6;
+  reserved "id", "login", "display_name", "avatar_url", "custom_status", "presence_status";
+
+  // Whether the account has at least one verified email address.
+  bool has_verified_email = 7;
+  // Current user's display settings.
+  UserSettings settings = 8;
+  // Whether the authenticated user may delete this account.
+  bool viewer_can_delete_account = 9;
+  // Last time a login credential changed, when known.
+  google.protobuf.Timestamp last_login_change = 10;
+  // Public user fields for the authenticated user.
+  User profile = 11;
+  // Whether this account currently has a password sign-in credential.
+  bool has_password = 12;
+}
+
+// Permission-derived capabilities for the authenticated user.
+message ViewerCapabilities {
+  // Keyed capability decisions for the authenticated user.
+  repeated CapabilityGrant grants = 1;
+  // Whether the user has unread followed threads.
+  bool has_unread_followed_threads = 2;
+}
+
+// Effective server/channel permission decisions for the authenticated user.
+message ServerViewerPermissions {
+  // One row per permission known to the server.
+  repeated PermissionGrant permissions = 1;
+}
+
+// Non-permission server state for the authenticated user.
+message ServerViewerState {
+  // Whether any joined channel room has unread messages.
+  bool has_unread_rooms = 1;
+}
+
+// Room notification preference for one joined room.
+message RoomNotificationPreference {
+  reserved 2, 3;
+  reserved "level", "effective_level";
+
+  // Room whose preference is represented.
+  string room_id = 1;
+  // Stored and effective notification preference.
+  NotificationPreference preference = 4;
+}
+
+// Request for the authenticated viewer snapshot.
+message GetViewerRequest {}
+
+// Authenticated viewer snapshot needed by application shells.
+message GetViewerResponse {
+  // Current authenticated user.
+  ViewerUser user = 1;
+  // Permission-derived capabilities.
+  ViewerCapabilities capabilities = 2;
+  // Server-wide notification preference.
+  NotificationPreference server_notification_preference = 3;
+  // Notification preferences for rooms the user participates in.
+  repeated RoomNotificationPreference room_notification_preferences = 4;
+  // Effective server/channel permission decisions for the authenticated user.
+  ServerViewerPermissions viewer_permissions = 5;
+  // Non-permission server state for the authenticated user.
+  ServerViewerState viewer_state = 6;
+}
+
+// Provides authenticated user profile, preferences, and capability state.
+service ViewerService {
+  // Returns the current authenticated viewer. This RPC requires a logged-in
+  // user; unauthenticated callers receive an UNAUTHENTICATED error.
+  rpc GetViewer(GetViewerRequest) returns (GetViewerResponse);
+}

+ 584 - 0
proto/chatto/realtime/v1/realtime.proto

@@ -0,0 +1,584 @@
+syntax = "proto3";
+
+package chatto.realtime.v1;
+
+import "chatto/api/v1/notification_preferences.proto";
+import "chatto/api/v1/presence.proto";
+import "chatto/api/v1/viewer.proto";
+import "google/protobuf/timestamp.proto";
+
+// Client-to-server frame for Chatto's protobuf WebSocket realtime protocol.
+//
+// Clients send binary protobuf frames to `/api/realtime`. The first frame must
+// be `hello`; after the server replies with `hello`, clients send
+// `subscribe_events` to start the authenticated live event stream.
+message RealtimeClientFrame {
+  reserved 4;
+  reserved "ack";
+
+  oneof frame {
+    // Opens the protocol session and optionally carries a bearer token.
+    RealtimeClientHello hello = 1;
+    // Starts the caller's authorized live-event stream.
+    RealtimeSubscribeEvents subscribe_events = 2;
+    // Application-level ping. The server replies with `pong`.
+    RealtimePing ping = 3;
+  }
+}
+
+// Server-to-client frame for Chatto's protobuf WebSocket realtime protocol.
+message RealtimeServerFrame {
+  oneof frame {
+    // Confirms protocol version, server version, and capabilities.
+    RealtimeServerHello hello = 1;
+    // Confirms the live-event stream has started.
+    RealtimeSubscribed subscribed = 2;
+    // A live event authorized for the connected user.
+    RealtimeEventEnvelope event = 3;
+    // Application-level heartbeat used for liveness checks.
+    RealtimeHeartbeat heartbeat = 4;
+    // Protocol or authorization error.
+    RealtimeError error = 5;
+    // Server-requested close with reconnect guidance.
+    RealtimeClose close = 6;
+    // Reply to a client ping.
+    RealtimePong pong = 7;
+  }
+}
+
+// Initial client hello.
+message RealtimeClientHello {
+  reserved 3;
+  reserved "resume_cursor";
+
+  // Protocol version requested by the client. The current version is 1.
+  uint32 protocol_version = 1;
+  // Optional bearer token. When present, it takes precedence over cookie auth.
+  optional string bearer_token = 2;
+}
+
+// Initial server hello.
+message RealtimeServerHello {
+  reserved 3;
+  reserved "resume_supported";
+
+  // Protocol version accepted by the server.
+  uint32 protocol_version = 1;
+  // Chatto server software version.
+  string server_version = 2;
+  // Approximate heartbeat interval clients should expect.
+  uint32 heartbeat_interval_seconds = 4;
+  // Stable protocol capability keys supported by this server. Current keys:
+  // `chatto.realtime.events.live.v1`, `chatto.realtime.heartbeat.v1`, and
+  // `chatto.realtime.ping.v1`.
+  repeated string capabilities = 5;
+}
+
+// Request to start the caller's authorized live event stream.
+message RealtimeSubscribeEvents {}
+
+// Confirms event streaming has started.
+message RealtimeSubscribed {
+  reserved 1;
+  reserved "cursor";
+}
+
+// Application-level ping.
+message RealtimePing {
+  // Client-chosen opaque value echoed in the pong.
+  string nonce = 1;
+}
+
+// Application-level pong.
+message RealtimePong {
+  // Echo of the ping nonce.
+  string nonce = 1;
+}
+
+// Application-level heartbeat.
+message RealtimeHeartbeat {
+  // Stable event ID for this heartbeat.
+  string id = 1;
+  // Time the heartbeat was emitted.
+  google.protobuf.Timestamp created_at = 2;
+}
+
+// Protocol error.
+message RealtimeError {
+  // Stable machine-readable error code.
+  string code = 1;
+  // Human-readable diagnostic message.
+  string message = 2;
+  // True when the server will close the socket after sending this error.
+  bool fatal = 3;
+}
+
+// Close instruction sent before the socket is closed when possible.
+message RealtimeClose {
+  // Stable machine-readable close code.
+  string code = 1;
+  // Human-readable diagnostic message.
+  string message = 2;
+  // True when the client should reconnect after a delay.
+  bool reconnect = 3;
+  // Suggested reconnect delay in milliseconds.
+  uint32 retry_after_ms = 4;
+}
+
+// One authorized live event delivered over the realtime WebSocket.
+//
+// Realtime events are invalidation signals first: payloads carry stable IDs and
+// small inline hints, while durable resource state is hydrated through
+// chatto.api.v1 ConnectRPC services. Event-specific messages document the
+// intended hydration path when a referenced resource may need refreshing.
+message RealtimeEventEnvelope {
+  reserved 4;
+  reserved "cursor";
+
+  // Stable event ID.
+  string id = 1;
+  // Time the event was created.
+  google.protobuf.Timestamp created_at = 2;
+  // User or system actor that caused the event, when known.
+  optional string actor_id = 3;
+
+  oneof event {
+    // A message was posted in a room or thread.
+    RealtimeMessagePostedEvent message_posted = 10;
+    // A message body or renderable metadata changed.
+    RealtimeMessageEditedEvent message_edited = 11;
+    // A message was retracted.
+    RealtimeMessageRetractedEvent message_retracted = 12;
+    // A user added a reaction to a message.
+    RealtimeReactionEvent reaction_added = 20;
+    // A user removed a reaction from a message.
+    RealtimeReactionEvent reaction_removed = 21;
+    // A user is typing in a room or thread.
+    RealtimeTypingEvent user_typing = 30;
+    // A user's live presence changed.
+    RealtimePresenceChangedEvent presence_changed = 31;
+    // A room was created.
+    RealtimeRoomEvent room_created = 40;
+    // A room's profile or settings changed.
+    RealtimeRoomEvent room_updated = 41;
+    // A room was deleted.
+    RealtimeRoomEvent room_deleted = 42;
+    // A room was archived.
+    RealtimeRoomEvent room_archived = 43;
+    // A room was restored from the archive.
+    RealtimeRoomEvent room_unarchived = 44;
+    // A user joined a room visible to the current user.
+    RealtimeRoomEvent user_joined_room = 45;
+    // A user left a room visible to the current user.
+    RealtimeRoomEvent user_left_room = 46;
+    // A room's universal visibility flag changed.
+    RealtimeRoomUniversalChangedEvent room_universal_changed = 47;
+    // A notification was created for the current user.
+    RealtimeNotificationCreatedEvent notification_created = 60;
+    // A notification was dismissed for the current user.
+    RealtimeNotificationDismissedEvent notification_dismissed = 61;
+    // The current user's notification level changed.
+    RealtimeNotificationLevelChangedEvent notification_level_changed = 62;
+    // The current user's thread follow state changed.
+    RealtimeThreadFollowChangedEvent thread_follow_changed = 63;
+    // The current user's room read state changed.
+    RealtimeRoomMarkedAsReadEvent room_marked_as_read = 64;
+    // A thread was created in a room visible to the current user.
+    RealtimeThreadCreatedEvent thread_created = 65;
+    // The server profile/config changed.
+    RealtimeServerUpdatedEvent server_updated = 70;
+    // A user profile changed.
+    RealtimeUserProfileUpdatedEvent user_profile_updated = 71;
+    // A user's custom status was set or changed.
+    RealtimeUserCustomStatusSetEvent user_custom_status_set = 72;
+    // A user's custom status was cleared.
+    RealtimeUserCustomStatusClearedEvent user_custom_status_cleared = 73;
+    // The current user's display preferences changed.
+    RealtimeServerUserPreferencesUpdatedEvent server_user_preferences_updated = 74;
+    // Room-group layout changed.
+    RealtimeRoomGroupsUpdatedEvent room_groups_updated = 75;
+    // A server member was deleted.
+    RealtimeServerMemberDeletedEvent server_member_deleted = 76;
+    // Asset processing started for a message attachment.
+    RealtimeAssetProcessingEvent asset_processing_started = 80;
+    // Asset processing completed successfully for a message attachment.
+    RealtimeAssetProcessingEvent asset_processing_succeeded = 81;
+    // Asset processing failed for a message attachment.
+    RealtimeAssetProcessingEvent asset_processing_failed = 82;
+    // An asset attached to a message was deleted.
+    RealtimeAssetDeletedEvent asset_deleted = 83;
+    // A voice call started in a room.
+    RealtimeCallEvent call_started = 84;
+    // A participant joined a voice call.
+    RealtimeCallEvent call_participant_joined = 85;
+    // A participant left a voice call.
+    RealtimeCallEvent call_participant_left = 86;
+    // A voice call ended.
+    RealtimeCallEvent call_ended = 87;
+    // The current user was mentioned in a room.
+    RealtimeMentionNotificationEvent mention_notification = 88;
+    // The current user received a new direct message.
+    RealtimeNewDirectMessageNotificationEvent new_direct_message_notification = 89;
+    // The current user's session was terminated.
+    RealtimeSessionTerminatedEvent session_terminated = 90;
+  }
+}
+
+// Message-posted signal.
+//
+// Hydrate the affected timeline with `RoomService.GetRoomEventsAround`
+// for room messages, or `ThreadService.GetThreadEventsAround` when
+// `thread_root_event_id` is set.
+message RealtimeMessagePostedEvent {
+  // Room containing the message.
+  string room_id = 1;
+  // Event ID of the posted message.
+  string message_event_id = 2;
+  // Root message event ID when the message was posted in a thread.
+  optional string thread_root_event_id = 3;
+}
+
+// Message-edited signal.
+//
+// Refresh the affected timeline window with
+// `RoomService.GetRoomEventsAround` for room messages, or
+// `ThreadService.GetThreadEventsAround` when the local message belongs to
+// a thread.
+message RealtimeMessageEditedEvent {
+  // Room containing the message.
+  string room_id = 1;
+  // Event ID of the edited message.
+  string message_event_id = 2;
+}
+
+// Message-retracted signal.
+//
+// Refresh or patch the affected timeline window with
+// `RoomService.GetRoomEventsAround` for room messages, or
+// `ThreadService.GetThreadEventsAround` when the local message belongs to
+// a thread.
+message RealtimeMessageRetractedEvent {
+  // Room containing the message.
+  string room_id = 1;
+  // Event ID of the retracted message.
+  string message_event_id = 2;
+  // Retraction reason, when one was supplied.
+  optional string reason = 3;
+}
+
+// Reaction signal.
+//
+// Refresh or patch the affected message in its timeline window. Use
+// `RoomService.GetRoomEventsAround` for room messages, or
+// `ThreadService.GetThreadEventsAround` when the local message belongs to
+// a thread. `message_event_id` is canonical: reactions made through a channel
+// echo of a thread reply report the original reply event ID. Clients that show
+// channel echoes should also refresh or patch visible echo rows whose
+// `echo_of_event_id` matches this ID.
+message RealtimeReactionEvent {
+  // Room containing the reacted-to message.
+  string room_id = 1;
+  // Canonical event ID of the reacted-to message.
+  string message_event_id = 2;
+  // Reaction emoji.
+  string emoji = 3;
+}
+
+// Typing signal.
+//
+// This is an ephemeral signal. `room_id` and `thread_root_event_id` identify
+// where to display typing state; clients normally do not hydrate it.
+message RealtimeTypingEvent {
+  // Room where the actor is typing.
+  string room_id = 1;
+  // Thread root event ID when the actor is typing in a thread.
+  optional string thread_root_event_id = 2;
+}
+
+// Presence-changed signal.
+//
+// The latest presence status is inline. Use `UserService.GetUser` when
+// the surrounding user profile or custom status also needs refreshing.
+message RealtimePresenceChangedEvent {
+  // User whose presence changed.
+  string user_id = 1;
+  // Latest presence status.
+  chatto.api.v1.PresenceStatus status = 2;
+}
+
+// Room lifecycle or membership signal.
+//
+// Hydrate visible room state with `RoomDirectoryService.GetRoom` or
+// `RoomDirectoryService.BatchGetRooms`. Unknown/deleted rooms return
+// `NOT_FOUND` from singular reads, hidden rooms return `PERMISSION_DENIED`, and
+// batch reads omit unknown, deleted, hidden, and inaccessible rooms.
+message RealtimeRoomEvent {
+  // Room affected by the event.
+  string room_id = 1;
+}
+
+// Room universal-visibility signal.
+//
+// The latest universal flag is inline. Hydrate the rest of the visible room with
+// `RoomDirectoryService.GetRoom` or `RoomDirectoryService.BatchGetRooms`.
+message RealtimeRoomUniversalChangedEvent {
+  // Room whose universal setting changed.
+  string room_id = 1;
+  // Latest universal setting.
+  bool universal = 2;
+}
+
+// Notification-created signal for the connected user.
+//
+// Hydrate full notification rows with `NotificationService.GetNotification` or
+// `NotificationService.BatchGetNotifications`. Use `RoomService` or
+// `ThreadService` anchor reads when `event_id` or `in_reply_to_id` must be
+// opened in context.
+message RealtimeNotificationCreatedEvent {
+  // Notification ID.
+  string notification_id = 1;
+  // Room associated with the notification, when the notification navigates to a room.
+  optional string room_id = 2;
+  // Event ID associated with the notification, when the notification navigates to an event.
+  optional string event_id = 3;
+  // Parent event ID for reply notifications, when known.
+  optional string in_reply_to_id = 4;
+  // True when the notification should not alert.
+  bool silent = 5;
+}
+
+// Notification-dismissed signal for the connected user.
+//
+// Remove the local notification row by ID. A later singular notification read
+// returns `NOT_FOUND`; batch reads omit dismissed or missing notifications.
+message RealtimeNotificationDismissedEvent {
+  // Notification ID.
+  string notification_id = 1;
+}
+
+// Notification-level signal for the connected user.
+//
+// The updated level is inline. Use
+// `NotificationPreferencesService.GetRoomNotificationPreference` when clients
+// need the complete preference resource.
+message RealtimeNotificationLevelChangedEvent {
+  // Room whose notification level changed.
+  string room_id = 1;
+  // Explicit room notification level.
+  chatto.api.v1.NotificationLevel level = 2;
+  // Effective notification level after defaults are applied.
+  chatto.api.v1.NotificationLevel effective_level = 3;
+}
+
+// Thread-follow signal for the connected user.
+//
+// The updated follow state is inline. Use `ThreadService.GetThreadEvents`
+// or `ThreadService.GetThreadEventsAround` when the thread itself needs
+// refreshing.
+message RealtimeThreadFollowChangedEvent {
+  // Room containing the thread.
+  string room_id = 1;
+  // Root message event ID of the thread.
+  string thread_root_event_id = 2;
+  // True when the user now follows the thread.
+  bool following = 3;
+}
+
+// Thread-created signal.
+//
+// Hydrate the new thread with `ThreadService.GetThreadEventsAround` using
+// `thread_root_event_id` as the anchor.
+message RealtimeThreadCreatedEvent {
+  // Room containing the thread.
+  string room_id = 1;
+  // Root message event ID that identifies the thread.
+  string thread_root_event_id = 2;
+}
+
+// Room-read signal for the connected user.
+//
+// This is a current-user read-state invalidation signal. Clients can patch local
+// unread state for the room; no separate hydration is normally needed.
+message RealtimeRoomMarkedAsReadEvent {
+  // Room marked read.
+  string room_id = 1;
+}
+
+// Server-profile signal.
+//
+// Public server profile fields are inline. Use `ServerDiscoveryService.GetServer`
+// for public metadata and `ServerService.GetMotd` for the authenticated MOTD.
+message RealtimeServerUpdatedEvent {
+  // Server display name.
+  string name = 1;
+  // Server description.
+  string description = 2;
+  // Server logo URL, when configured.
+  optional string logo_url = 3;
+  // Server banner URL, when configured.
+  optional string banner_url = 4;
+}
+
+// User-profile signal.
+//
+// Basic profile fields are inline. Use `UserService.GetUser` or
+// `UserService.BatchGetUsers` for complete user-profile hydration.
+message RealtimeUserProfileUpdatedEvent {
+  // User whose profile changed.
+  string user_id = 1;
+  // Login name.
+  string login = 2;
+  // Display name.
+  string display_name = 3;
+  // Avatar URL, when the user has an avatar.
+  optional string avatar_url = 4;
+}
+
+// User-custom-status set signal.
+//
+// The latest custom status is inline. Use `UserService.GetUser` when
+// clients need to refresh the complete user profile.
+message RealtimeUserCustomStatusSetEvent {
+  // User whose status changed.
+  string user_id = 1;
+  // Emoji part of the status.
+  string emoji = 2;
+  // Text part of the status.
+  string text = 3;
+  // Expiration time, when the status expires automatically.
+  google.protobuf.Timestamp expires_at = 4;
+}
+
+// User-custom-status cleared signal.
+//
+// Clear local custom status for `user_id`. Use `UserService.GetUser`
+// when clients need to refresh the complete user profile.
+message RealtimeUserCustomStatusClearedEvent {
+  // User whose status was cleared.
+  string user_id = 1;
+}
+
+// User display-preferences signal for the connected user.
+//
+// The updated display preferences are inline for the connected user.
+message RealtimeServerUserPreferencesUpdatedEvent {
+  // IANA timezone name, when the user has selected a fixed timezone.
+  optional string timezone = 1;
+  // Preferred time display format.
+  chatto.api.v1.TimeFormat time_format = 2;
+}
+
+// Room-group layout signal.
+//
+// Refetch room-group layout with `RoomDirectoryService.ListRoomGroups`. If a
+// client already knows specific group IDs, it can use
+// `RoomDirectoryService.GetRoomGroup` or
+// `RoomDirectoryService.BatchGetRoomGroups`.
+message RealtimeRoomGroupsUpdatedEvent {
+  // Always true; present for event-bus compatibility.
+  bool changed = 1;
+}
+
+// Server-member deleted signal.
+//
+// Remove or invalidate local member/user rows for `user_id`. Admin clients can
+// hydrate remaining member rows through `AdminUserService.GetMember` or
+// `AdminUserService.BatchGetMembers`.
+message RealtimeServerMemberDeletedEvent {
+  // Deleted user ID.
+  string user_id = 1;
+}
+
+// Asset-processing signal.
+//
+// Message attachments are message-owned subresources. When
+// `message_event_id` is known, refetch message state with
+// `MessageService.GetMessage` or `MessageService.BatchGetMessages`; otherwise
+// refetch the affected attachment list or timeline window.
+message RealtimeAssetProcessingEvent {
+  // Room containing the message that owns the asset, when known.
+  optional string room_id = 1;
+  // Asset ID.
+  string asset_id = 2;
+  // Event ID of the message that owns the asset, when known.
+  optional string message_event_id = 3;
+}
+
+// Asset-deleted signal.
+//
+// Remove local attachment state by `asset_id`. When the owning message is known,
+// clients can refetch that message through `MessageService.GetMessage` or
+// refetch the timeline window.
+message RealtimeAssetDeletedEvent {
+  // Room containing the message that owned the asset, when known.
+  optional string room_id = 1;
+  // Asset ID.
+  string asset_id = 2;
+}
+
+// Voice-call state signal.
+//
+// Hydrate current room-scoped call state with `VoiceCallService.GetActiveCall`
+// or `VoiceCallService.BatchGetActiveCalls`. Compare `call_id` to ignore stale
+// transitions from a previous call in the same room.
+message RealtimeCallEvent {
+  // Room containing the call.
+  string room_id = 1;
+  // Call ID.
+  string call_id = 2;
+  // Source that produced the call transition.
+  RealtimeCallEventSource source = 3;
+}
+
+// Source that produced a realtime voice-call transition.
+enum RealtimeCallEventSource {
+  // No call event source was specified.
+  REALTIME_CALL_EVENT_SOURCE_UNSPECIFIED = 0;
+  // The user explicitly requested the transition through Chatto.
+  REALTIME_CALL_EVENT_SOURCE_USER = 1;
+  // LiveKit reported the transition through a webhook.
+  REALTIME_CALL_EVENT_SOURCE_LIVEKIT = 2;
+  // Chatto reconciled its local state against LiveKit's current room state.
+  REALTIME_CALL_EVENT_SOURCE_RECONCILIATION = 3;
+}
+
+// Mention attention signal for the connected user.
+//
+// Inline names are display hints. Hydrate referenced rooms through
+// `RoomDirectoryService.BatchGetRooms` and users through
+// `UserService.BatchGetUsers` when local caches are missing or stale.
+message RealtimeMentionNotificationEvent {
+  // Room where the mention occurred.
+  string room_id = 1;
+  // Author user ID.
+  string actor_user_id = 2;
+  // Display name of the room where the mention occurred, when hydrated for the caller.
+  optional string room_name = 3;
+  // Display name of the author who mentioned the connected user, when hydrated.
+  optional string actor_display_name = 4;
+}
+
+// New-DM attention signal for the connected user.
+//
+// Inline names and avatar URLs are display hints. Hydrate the DM room through
+// `RoomDirectoryService.GetRoom` or `RoomDirectoryService.BatchGetRooms`, and
+// the sender through `UserService.GetUser` or `UserService.BatchGetUsers` when
+// local caches are missing or stale.
+message RealtimeNewDirectMessageNotificationEvent {
+  // DM room ID.
+  string room_id = 1;
+  // Sender user ID.
+  string sender_id = 2;
+  // Display name of the sender, when hydrated.
+  optional string sender_display_name = 3;
+  // Avatar URL of the sender, when one is available.
+  optional string sender_avatar_url = 4;
+  // Display name for the DM conversation from the connected user's perspective, when hydrated.
+  optional string conversation_name = 5;
+}
+
+// Session-terminated signal for the connected user's current session.
+message RealtimeSessionTerminatedEvent {
+  // Termination reason.
+  string reason = 1;
+}

+ 8 - 0
pyproject.toml

@@ -33,6 +33,7 @@ Homepage = "https://chat.chatto.run"
 [project.optional-dependencies]
 realtime = [
     "websockets>=13.0",
+    "protobuf>=5.28",
 ]
 dev = [
     "pytest>=8.0",
@@ -52,6 +53,7 @@ testpaths = ["tests"]
 [tool.ruff]
 target-version = "py311"
 line-length = 100
+extend-exclude = ["src/chattolib/_pb"]
 
 [tool.ruff.lint]
 select = ["E", "F", "I", "N", "W", "UP"]
@@ -61,3 +63,9 @@ python_version = "3.11"
 strict = true
 warn_return_any = true
 warn_unused_configs = true
+exclude = ["src/chattolib/_pb"]
+
+[[tool.mypy.overrides]]
+module = ["chattolib._pb.*", "websockets.*"]
+follow_imports = "skip"
+ignore_missing_imports = true

+ 71 - 0
scripts/generate_pb.sh

@@ -0,0 +1,71 @@
+#!/usr/bin/env bash
+# Regenerate the vendored Python protobuf bindings under src/chattolib/_pb.
+#
+# Fetches the required .proto sources into proto/ (from chattocorp/chatto's
+# main branch and bufbuild/protovalidate) and runs protoc.
+#
+# Requirements: protoc on PATH, curl on PATH.
+#
+# Run from the repo root:  ./scripts/generate_pb.sh
+
+set -euo pipefail
+
+if ! command -v protoc >/dev/null; then
+    echo "protoc not found on PATH" >&2
+    exit 1
+fi
+
+repo_root=$(cd "$(dirname "$0")/.." && pwd)
+cd "$repo_root"
+
+mkdir -p proto/chatto/realtime/v1 proto/chatto/api/v1 proto/buf/validate
+
+chatto_base="https://raw.githubusercontent.com/chattocorp/chatto/main/proto/chatto"
+
+fetch() {
+    local rel=$1
+    local dest="proto/$rel"
+    curl -sfL "$chatto_base/${rel#chatto/}" -o "$dest"
+    echo "  $rel"
+}
+
+echo "Fetching proto sources ..."
+fetch chatto/realtime/v1/realtime.proto
+fetch chatto/api/v1/viewer.proto
+fetch chatto/api/v1/notification_preferences.proto
+fetch chatto/api/v1/presence.proto
+fetch chatto/api/v1/users.proto
+fetch chatto/api/v1/user_status.proto
+fetch chatto/api/v1/permissions.proto
+curl -sfL "https://raw.githubusercontent.com/bufbuild/protovalidate/main/proto/protovalidate/buf/validate/validate.proto" \
+    -o proto/buf/validate/validate.proto
+echo "  buf/validate/validate.proto"
+
+echo "Regenerating Python bindings ..."
+rm -rf src/chattolib/_pb/chatto src/chattolib/_pb/buf
+mkdir -p src/chattolib/_pb
+
+protoc --proto_path=proto --python_out=src/chattolib/_pb \
+    proto/chatto/realtime/v1/realtime.proto \
+    proto/chatto/api/v1/viewer.proto \
+    proto/chatto/api/v1/notification_preferences.proto \
+    proto/chatto/api/v1/presence.proto \
+    proto/chatto/api/v1/users.proto \
+    proto/chatto/api/v1/user_status.proto \
+    proto/chatto/api/v1/permissions.proto \
+    proto/buf/validate/validate.proto
+
+# Add __init__.py at every level so the generated modules form a package.
+for dir in \
+    src/chattolib/_pb/chatto \
+    src/chattolib/_pb/chatto/api \
+    src/chattolib/_pb/chatto/api/v1 \
+    src/chattolib/_pb/chatto/realtime \
+    src/chattolib/_pb/chatto/realtime/v1 \
+    src/chattolib/_pb/buf \
+    src/chattolib/_pb/buf/validate
+do
+    touch "$dir/__init__.py"
+done
+
+echo "Done."

+ 14 - 0
src/chattolib/__init__.py

@@ -2,6 +2,14 @@
 
 from chattolib.client import ChattoClient
 from chattolib.exceptions import ChattoAuthError, ChattoConnectError, ChattoError
+from chattolib.realtime import (
+    ChattoRealtimeCloseError,
+    ChattoRealtimeError,
+    RealtimeConnection,
+    RealtimeEvent,
+    ServerHello,
+    stream_events,
+)
 from chattolib.types import (
     ActiveCall,
     Asset,
@@ -52,6 +60,12 @@ __all__ = [
     "ChattoError",
     "ChattoConnectError",
     "ChattoAuthError",
+    "ChattoRealtimeCloseError",
+    "ChattoRealtimeError",
+    "RealtimeConnection",
+    "RealtimeEvent",
+    "ServerHello",
+    "stream_events",
     "ActiveCall",
     "Asset",
     "AssetUrl",

+ 21 - 0
src/chattolib/_pb/__init__.py

@@ -0,0 +1,21 @@
+"""Vendored protobuf bindings for the Chatto realtime WebSocket protocol.
+
+Generated modules under this directory import each other via top-level package
+paths (``from chatto.api.v1 import ...``, ``from buf.validate import ...``)
+because that is how ``protoc`` emits Python bindings. To make them importable
+without polluting the top-level ``chatto`` / ``buf`` namespaces of dependent
+projects, this package inserts its own directory into ``sys.path`` on first
+import. Chatto is the only real project shipping under those names, so the
+collision risk is negligible.
+
+Regenerate with ``scripts/generate_pb.sh``.
+"""
+
+from __future__ import annotations
+
+import os
+import sys
+
+_here = os.path.dirname(os.path.abspath(__file__))
+if _here not in sys.path:
+    sys.path.insert(0, _here)

+ 0 - 0
src/chattolib/_pb/buf/__init__.py


+ 0 - 0
src/chattolib/_pb/buf/validate/__init__.py


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 30 - 0
src/chattolib/_pb/buf/validate/validate_pb2.py


+ 0 - 0
src/chattolib/_pb/chatto/__init__.py


+ 0 - 0
src/chattolib/_pb/chatto/api/__init__.py


+ 0 - 0
src/chattolib/_pb/chatto/api/v1/__init__.py


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 27 - 0
src/chattolib/_pb/chatto/api/v1/notification_preferences_pb2.py


+ 38 - 0
src/chattolib/_pb/chatto/api/v1/permissions_pb2.py

@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+# Generated by the protocol buffer compiler.  DO NOT EDIT!
+# NO CHECKED-IN PROTOBUF GENCODE
+# source: chatto/api/v1/permissions.proto
+# Protobuf Python Version: 7.34.1
+"""Generated protocol buffer code."""
+from google.protobuf import descriptor as _descriptor
+from google.protobuf import descriptor_pool as _descriptor_pool
+from google.protobuf import runtime_version as _runtime_version
+from google.protobuf import symbol_database as _symbol_database
+from google.protobuf.internal import builder as _builder
+_runtime_version.ValidateProtobufRuntimeVersion(
+    _runtime_version.Domain.PUBLIC,
+    7,
+    34,
+    1,
+    '',
+    'chatto/api/v1/permissions.proto'
+)
+# @@protoc_insertion_point(imports)
+
+_sym_db = _symbol_database.Default()
+
+
+
+
+DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1f\x63hatto/api/v1/permissions.proto\x12\rchatto.api.v1\"6\n\x0fPermissionGrant\x12\x12\n\npermission\x18\x01 \x01(\t\x12\x0f\n\x07granted\x18\x02 \x01(\x08\"6\n\x0f\x43\x61pabilityGrant\x12\x12\n\ncapability\x18\x01 \x01(\t\x12\x0f\n\x07granted\x18\x02 \x01(\x08\x62\x06proto3')
+
+_globals = globals()
+_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
+_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'chatto.api.v1.permissions_pb2', _globals)
+if not _descriptor._USE_C_DESCRIPTORS:
+  DESCRIPTOR._loaded_options = None
+  _globals['_PERMISSIONGRANT']._serialized_start=50
+  _globals['_PERMISSIONGRANT']._serialized_end=104
+  _globals['_CAPABILITYGRANT']._serialized_start=106
+  _globals['_CAPABILITYGRANT']._serialized_end=160
+# @@protoc_insertion_point(module_scope)

+ 43 - 0
src/chattolib/_pb/chatto/api/v1/presence_pb2.py

@@ -0,0 +1,43 @@
+# -*- coding: utf-8 -*-
+# Generated by the protocol buffer compiler.  DO NOT EDIT!
+# NO CHECKED-IN PROTOBUF GENCODE
+# source: chatto/api/v1/presence.proto
+# Protobuf Python Version: 7.34.1
+"""Generated protocol buffer code."""
+from google.protobuf import descriptor as _descriptor
+from google.protobuf import descriptor_pool as _descriptor_pool
+from google.protobuf import runtime_version as _runtime_version
+from google.protobuf import symbol_database as _symbol_database
+from google.protobuf.internal import builder as _builder
+_runtime_version.ValidateProtobufRuntimeVersion(
+    _runtime_version.Domain.PUBLIC,
+    7,
+    34,
+    1,
+    '',
+    'chatto/api/v1/presence.proto'
+)
+# @@protoc_insertion_point(imports)
+
+_sym_db = _symbol_database.Default()
+
+
+from buf.validate import validate_pb2 as buf_dot_validate_dot_validate__pb2
+
+
+DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1c\x63hatto/api/v1/presence.proto\x12\rchatto.api.v1\x1a\x1b\x62uf/validate/validate.proto\"k\n\x15UpdatePresenceRequest\x12;\n\x06status\x18\x01 \x01(\x0e\x32\x1d.chatto.api.v1.PresenceStatusB\x0c\xbaH\t\x82\x01\x06\x10\x01 \x00 \x04\x12\x15\n\ruser_selected\x18\x02 \x01(\x08\"G\n\x16UpdatePresenceResponse\x12-\n\x06status\x18\x01 \x01(\x0e\x32\x1d.chatto.api.v1.PresenceStatus*\xa8\x01\n\x0ePresenceStatus\x12\x1f\n\x1bPRESENCE_STATUS_UNSPECIFIED\x10\x00\x12\x1a\n\x16PRESENCE_STATUS_ONLINE\x10\x01\x12\x18\n\x14PRESENCE_STATUS_AWAY\x10\x02\x12\"\n\x1ePRESENCE_STATUS_DO_NOT_DISTURB\x10\x03\x12\x1b\n\x17PRESENCE_STATUS_OFFLINE\x10\x04\x62\x06proto3')
+
+_globals = globals()
+_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
+_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'chatto.api.v1.presence_pb2', _globals)
+if not _descriptor._USE_C_DESCRIPTORS:
+  DESCRIPTOR._loaded_options = None
+  _globals['_UPDATEPRESENCEREQUEST'].fields_by_name['status']._loaded_options = None
+  _globals['_UPDATEPRESENCEREQUEST'].fields_by_name['status']._serialized_options = b'\272H\t\202\001\006\020\001 \000 \004'
+  _globals['_PRESENCESTATUS']._serialized_start=259
+  _globals['_PRESENCESTATUS']._serialized_end=427
+  _globals['_UPDATEPRESENCEREQUEST']._serialized_start=76
+  _globals['_UPDATEPRESENCEREQUEST']._serialized_end=183
+  _globals['_UPDATEPRESENCERESPONSE']._serialized_start=185
+  _globals['_UPDATEPRESENCERESPONSE']._serialized_end=256
+# @@protoc_insertion_point(module_scope)

+ 50 - 0
src/chattolib/_pb/chatto/api/v1/user_status_pb2.py

@@ -0,0 +1,50 @@
+# -*- coding: utf-8 -*-
+# Generated by the protocol buffer compiler.  DO NOT EDIT!
+# NO CHECKED-IN PROTOBUF GENCODE
+# source: chatto/api/v1/user_status.proto
+# Protobuf Python Version: 7.34.1
+"""Generated protocol buffer code."""
+from google.protobuf import descriptor as _descriptor
+from google.protobuf import descriptor_pool as _descriptor_pool
+from google.protobuf import runtime_version as _runtime_version
+from google.protobuf import symbol_database as _symbol_database
+from google.protobuf.internal import builder as _builder
+_runtime_version.ValidateProtobufRuntimeVersion(
+    _runtime_version.Domain.PUBLIC,
+    7,
+    34,
+    1,
+    '',
+    'chatto/api/v1/user_status.proto'
+)
+# @@protoc_insertion_point(imports)
+
+_sym_db = _symbol_database.Default()
+
+
+from buf.validate import validate_pb2 as buf_dot_validate_dot_validate__pb2
+from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2
+
+
+DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1f\x63hatto/api/v1/user_status.proto\x12\rchatto.api.v1\x1a\x1b\x62uf/validate/validate.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"u\n\x10\x43ustomUserStatus\x12\x18\n\x05\x65moji\x18\x01 \x01(\tB\t\xbaH\x06r\x04\x10\x01\x18\x10\x12\x17\n\x04text\x18\x02 \x01(\tB\t\xbaH\x06r\x04\x10\x01\x18\x64\x12.\n\nexpires_at\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"h\n\x19UpdateCustomStatusRequest\x12\r\n\x05\x65moji\x18\x01 \x01(\t\x12\x0c\n\x04text\x18\x02 \x01(\t\x12.\n\nexpires_at\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"M\n\x1aUpdateCustomStatusResponse\x12/\n\x06status\x18\x01 \x01(\x0b\x32\x1f.chatto.api.v1.CustomUserStatus\"\x1b\n\x19\x44\x65leteCustomStatusRequest\"M\n\x1a\x44\x65leteCustomStatusResponse\x12/\n\x06status\x18\x01 \x01(\x0b\x32\x1f.chatto.api.v1.CustomUserStatusb\x06proto3')
+
+_globals = globals()
+_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
+_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'chatto.api.v1.user_status_pb2', _globals)
+if not _descriptor._USE_C_DESCRIPTORS:
+  DESCRIPTOR._loaded_options = None
+  _globals['_CUSTOMUSERSTATUS'].fields_by_name['emoji']._loaded_options = None
+  _globals['_CUSTOMUSERSTATUS'].fields_by_name['emoji']._serialized_options = b'\272H\006r\004\020\001\030\020'
+  _globals['_CUSTOMUSERSTATUS'].fields_by_name['text']._loaded_options = None
+  _globals['_CUSTOMUSERSTATUS'].fields_by_name['text']._serialized_options = b'\272H\006r\004\020\001\030d'
+  _globals['_CUSTOMUSERSTATUS']._serialized_start=112
+  _globals['_CUSTOMUSERSTATUS']._serialized_end=229
+  _globals['_UPDATECUSTOMSTATUSREQUEST']._serialized_start=231
+  _globals['_UPDATECUSTOMSTATUSREQUEST']._serialized_end=335
+  _globals['_UPDATECUSTOMSTATUSRESPONSE']._serialized_start=337
+  _globals['_UPDATECUSTOMSTATUSRESPONSE']._serialized_end=414
+  _globals['_DELETECUSTOMSTATUSREQUEST']._serialized_start=416
+  _globals['_DELETECUSTOMSTATUSREQUEST']._serialized_end=443
+  _globals['_DELETECUSTOMSTATUSRESPONSE']._serialized_start=445
+  _globals['_DELETECUSTOMSTATUSRESPONSE']._serialized_end=522
+# @@protoc_insertion_point(module_scope)

+ 38 - 0
src/chattolib/_pb/chatto/api/v1/users_pb2.py

@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+# Generated by the protocol buffer compiler.  DO NOT EDIT!
+# NO CHECKED-IN PROTOBUF GENCODE
+# source: chatto/api/v1/users.proto
+# Protobuf Python Version: 7.34.1
+"""Generated protocol buffer code."""
+from google.protobuf import descriptor as _descriptor
+from google.protobuf import descriptor_pool as _descriptor_pool
+from google.protobuf import runtime_version as _runtime_version
+from google.protobuf import symbol_database as _symbol_database
+from google.protobuf.internal import builder as _builder
+_runtime_version.ValidateProtobufRuntimeVersion(
+    _runtime_version.Domain.PUBLIC,
+    7,
+    34,
+    1,
+    '',
+    'chatto/api/v1/users.proto'
+)
+# @@protoc_insertion_point(imports)
+
+_sym_db = _symbol_database.Default()
+
+
+from chatto.api.v1 import presence_pb2 as chatto_dot_api_dot_v1_dot_presence__pb2
+from chatto.api.v1 import user_status_pb2 as chatto_dot_api_dot_v1_dot_user__status__pb2
+
+
+DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x19\x63hatto/api/v1/users.proto\x12\rchatto.api.v1\x1a\x1c\x63hatto/api/v1/presence.proto\x1a\x1f\x63hatto/api/v1/user_status.proto\"\xe0\x01\n\x04User\x12\n\n\x02id\x18\x01 \x01(\t\x12\r\n\x05login\x18\x02 \x01(\t\x12\x14\n\x0c\x64isplay_name\x18\x03 \x01(\t\x12\x0f\n\x07\x64\x65leted\x18\x04 \x01(\x08\x12\x17\n\navatar_url\x18\x05 \x01(\tH\x00\x88\x01\x01\x12\x36\n\x0fpresence_status\x18\x06 \x01(\x0e\x32\x1d.chatto.api.v1.PresenceStatus\x12\x36\n\rcustom_status\x18\x07 \x01(\x0b\x32\x1f.chatto.api.v1.CustomUserStatusB\r\n\x0b_avatar_urlb\x06proto3')
+
+_globals = globals()
+_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
+_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'chatto.api.v1.users_pb2', _globals)
+if not _descriptor._USE_C_DESCRIPTORS:
+  DESCRIPTOR._loaded_options = None
+  _globals['_USER']._serialized_start=108
+  _globals['_USER']._serialized_end=332
+# @@protoc_insertion_point(module_scope)

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 30 - 0
src/chattolib/_pb/chatto/api/v1/viewer_pb2.py


+ 0 - 0
src/chattolib/_pb/chatto/realtime/__init__.py


+ 0 - 0
src/chattolib/_pb/chatto/realtime/v1/__init__.py


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 30 - 0
src/chattolib/_pb/chatto/realtime/v1/realtime_pb2.py


+ 291 - 34
src/chattolib/realtime.py

@@ -1,49 +1,306 @@
-"""Placeholder for the Chatto realtime WebSocket protocol.
+"""Chatto realtime WebSocket client.
 
-Chatto's realtime protocol (see ``proto/chatto/realtime/v1/realtime.proto``)
-uses binary protobuf frames over WebSocket at ``/api/realtime``. This module
-exports the endpoint metadata and a stub subscribe function. Wiring up actual
-frame encoding/decoding requires protobuf Python bindings and is tracked in a
-separate follow-up bean.
+Chatto exposes a binary-protobuf realtime channel at ``/api/realtime`` (see
+``proto/chatto/realtime/v1/realtime.proto``). This module speaks that
+protocol: it opens the WebSocket, exchanges ``hello`` frames, subscribes to
+the caller's authorized live-event stream, and yields decoded events.
+
+Usage::
+
+    async with await ChattoClient.login(...) as client:
+        async for event in stream_events(client):
+            print(event.kind, event.payload)
+
+Requires the ``chattolib[realtime]`` extra (which pulls in ``websockets`` and
+``protobuf``).
 """
 
 from __future__ import annotations
 
+from collections.abc import AsyncIterator
+from dataclasses import dataclass
+from datetime import datetime
+from typing import TYPE_CHECKING, Any
+
+from chattolib import _pb  # noqa: F401 — installs pb import path
+from chattolib.exceptions import ChattoError
+from chattolib.types import parse_datetime
+
+if TYPE_CHECKING:
+    from chattolib.client import ChattoClient
+
 REALTIME_PATH = "/api/realtime"
 REALTIME_PROTOCOL_VERSION = 1
 
 
+class ChattoRealtimeError(ChattoError):
+    """Server returned a protocol error over the realtime WebSocket."""
+
+    def __init__(self, code: str, message: str, *, fatal: bool = False) -> None:
+        self.code = code
+        self.message = message
+        self.fatal = fatal
+        super().__init__(f"{code}: {message}")
+
+
+class ChattoRealtimeCloseError(ChattoError):
+    """Server sent a close frame."""
+
+    def __init__(
+        self,
+        code: str,
+        message: str,
+        *,
+        reconnect: bool = False,
+        retry_after_ms: int = 0,
+    ) -> None:
+        self.code = code
+        self.message = message
+        self.reconnect = reconnect
+        self.retry_after_ms = retry_after_ms
+        super().__init__(f"{code}: {message}")
+
+
 def realtime_url(base_url: str) -> str:
     """Convert an HTTP(S) base URL to the realtime WebSocket URL."""
     base = base_url.rstrip("/")
     if base.startswith("https://"):
-        scheme = "wss://"
-        rest = base[len("https://") :]
-    elif base.startswith("http://"):
-        scheme = "ws://"
-        rest = base[len("http://") :]
-    else:
-        scheme = "wss://"
-        rest = base
-    return f"{scheme}{rest}{REALTIME_PATH}"
-
-
-class RealtimeNotImplementedError(NotImplementedError):
-    """Raised when realtime is requested but the protobuf bindings are absent."""
-
-
-async def subscribe_events(*_args: object, **_kwargs: object) -> None:
-    """Placeholder for the realtime event stream.
-
-    Chatto's realtime protocol is a binary protobuf WebSocket. Consuming it
-    requires generated protobuf bindings for
-    ``chatto.realtime.v1.RealtimeClientFrame`` / ``RealtimeServerFrame`` and
-    their dependencies. Once bindings are shipped, this function should
-    connect to :data:`REALTIME_PATH`, send a ``RealtimeClientHello`` frame,
-    exchange the server ``hello``, send ``RealtimeSubscribeEvents``, and yield
-    decoded ``RealtimeEventEnvelope`` values.
+        return "wss://" + base[len("https://") :] + REALTIME_PATH
+    if base.startswith("http://"):
+        return "ws://" + base[len("http://") :] + REALTIME_PATH
+    return "wss://" + base + REALTIME_PATH
+
+
+@dataclass
+class ServerHello:
+    """Server's response to the initial hello frame."""
+
+    protocol_version: int
+    server_version: str
+    heartbeat_interval_seconds: int
+    capabilities: list[str]
+
+
+@dataclass
+class RealtimeEvent:
+    """One live event delivered over the realtime WebSocket.
+
+    ``kind`` names the ``oneof event`` case set on the envelope
+    (``message_posted``, ``reaction_added``, ``presence_changed``, …).
+    ``payload`` is the concrete protobuf sub-message; access its fields
+    directly (e.g. ``event.payload.room_id``). Callers that want to hydrate
+    the referenced resource should follow the hydration hints documented on
+    each event message in ``realtime.proto``.
+    """
+
+    id: str
+    created_at: datetime | None
+    actor_id: str | None
+    kind: str
+    payload: Any
+    raw: Any  # the full RealtimeEventEnvelope
+
+
+class RealtimeConnection:
+    """Live realtime WebSocket session.
+
+    Prefer :func:`stream_events` for the common case; use this class directly
+    when you also need to send client pings, close cleanly, or inspect the
+    negotiated :class:`ServerHello`.
     """
-    raise RealtimeNotImplementedError(
-        "chattolib does not yet ship protobuf bindings for the Chatto realtime "
-        "WebSocket protocol. Track the follow-up bean for status."
+
+    def __init__(
+        self,
+        client: ChattoClient,
+        *,
+        protocol_version: int = REALTIME_PROTOCOL_VERSION,
+    ) -> None:
+        self._client = client
+        self._protocol_version = protocol_version
+        self._ws: Any = None
+        self._server_hello: ServerHello | None = None
+
+    @property
+    def server_hello(self) -> ServerHello | None:
+        return self._server_hello
+
+    async def __aenter__(self) -> RealtimeConnection:
+        await self.connect()
+        return self
+
+    async def __aexit__(self, *exc: Any) -> None:
+        await self.close()
+
+    async def connect(self) -> None:
+        try:
+            import websockets
+        except ImportError as exc:  # pragma: no cover
+            raise ChattoError(
+                "The realtime channel requires the 'websockets' package. "
+                "Install with `pip install chattolib[realtime]`."
+            ) from exc
+
+        from chattolib._pb.chatto.realtime.v1 import realtime_pb2
+
+        url = realtime_url(self._client.base_url)
+        headers: dict[str, str] = {}
+        if self._client.session_cookie:
+            headers["Cookie"] = f"chatto_session={self._client.session_cookie}"
+
+        self._ws = await websockets.connect(url, additional_headers=headers)
+
+        client_hello = realtime_pb2.RealtimeClientFrame()
+        client_hello.hello.protocol_version = self._protocol_version
+        if self._client.token:
+            client_hello.hello.bearer_token = self._client.token
+        await self._ws.send(client_hello.SerializeToString())
+
+        first = await self._ws.recv()
+        first_frame = realtime_pb2.RealtimeServerFrame()
+        first_frame.ParseFromString(first)
+        if first_frame.WhichOneof("frame") != "hello":
+            _raise_for_control(first_frame)
+            raise ChattoRealtimeError(
+                "unexpected_frame",
+                f"expected server hello, got {first_frame.WhichOneof('frame')!r}",
+            )
+        hello = first_frame.hello
+        self._server_hello = ServerHello(
+            protocol_version=hello.protocol_version,
+            server_version=hello.server_version,
+            heartbeat_interval_seconds=hello.heartbeat_interval_seconds,
+            capabilities=list(hello.capabilities),
+        )
+
+        subscribe = realtime_pb2.RealtimeClientFrame()
+        subscribe.subscribe_events.SetInParent()
+        await self._ws.send(subscribe.SerializeToString())
+
+    async def close(self) -> None:
+        if self._ws is None:
+            return
+        try:
+            await self._ws.close()
+        finally:
+            self._ws = None
+
+    async def ping(self, nonce: str = "") -> None:
+        """Send a client ping. The server replies with a matching pong."""
+        if self._ws is None:
+            raise ChattoError("realtime connection is closed")
+        from chattolib._pb.chatto.realtime.v1 import realtime_pb2
+
+        frame = realtime_pb2.RealtimeClientFrame()
+        frame.ping.nonce = nonce
+        await self._ws.send(frame.SerializeToString())
+
+    async def events(self) -> AsyncIterator[RealtimeEvent]:
+        """Yield decoded live events until the connection closes."""
+        if self._ws is None:
+            raise ChattoError("realtime connection is not open")
+        from chattolib._pb.chatto.realtime.v1 import realtime_pb2
+
+        async for raw in self._ws:
+            if isinstance(raw, str):
+                # The protocol is binary; a text frame indicates a protocol violation.
+                raise ChattoRealtimeError(
+                    "unexpected_text_frame",
+                    "server sent a text frame; realtime protocol expects binary",
+                )
+            frame = realtime_pb2.RealtimeServerFrame()
+            frame.ParseFromString(raw)
+            case = frame.WhichOneof("frame")
+            if case == "event":
+                yield _wrap_event(frame.event)
+            elif case in ("heartbeat", "pong", "subscribed"):
+                continue
+            elif case == "error":
+                err = frame.error
+                exc = ChattoRealtimeError(err.code, err.message, fatal=err.fatal)
+                if err.fatal:
+                    raise exc
+                # Non-fatal errors are surfaced but the stream continues.
+                # Callers can still receive them if desired; for now we log
+                # by re-raising on fatal only.
+                continue
+            elif case == "close":
+                close = frame.close
+                raise ChattoRealtimeCloseError(
+                    close.code,
+                    close.message,
+                    reconnect=close.reconnect,
+                    retry_after_ms=close.retry_after_ms,
+                )
+            else:
+                raise ChattoRealtimeError(
+                    "unexpected_frame",
+                    f"unknown server frame: {case!r}",
+                )
+
+
+def _raise_for_control(frame: Any) -> None:
+    """If ``frame`` is an error or close frame, translate it and raise."""
+    case = frame.WhichOneof("frame")
+    if case == "error":
+        err = frame.error
+        raise ChattoRealtimeError(err.code, err.message, fatal=err.fatal)
+    if case == "close":
+        close = frame.close
+        raise ChattoRealtimeCloseError(
+            close.code,
+            close.message,
+            reconnect=close.reconnect,
+            retry_after_ms=close.retry_after_ms,
+        )
+
+
+def _wrap_event(envelope: Any) -> RealtimeEvent:
+    kind = envelope.WhichOneof("event") or ""
+    payload = getattr(envelope, kind, None) if kind else None
+    created_at = None
+    if envelope.HasField("created_at"):
+        created_at = parse_datetime(envelope.created_at.ToJsonString())
+    actor_id: str | None = None
+    if envelope.HasField("actor_id"):
+        actor_id = envelope.actor_id
+    return RealtimeEvent(
+        id=envelope.id,
+        created_at=created_at,
+        actor_id=actor_id,
+        kind=kind,
+        payload=payload,
+        raw=envelope,
     )
+
+
+async def stream_events(
+    client: ChattoClient,
+    *,
+    protocol_version: int = REALTIME_PROTOCOL_VERSION,
+) -> AsyncIterator[RealtimeEvent]:
+    """Open a realtime connection and yield events until the server closes.
+
+    Raises :class:`ChattoRealtimeCloseError` when the server sends a close frame,
+    :class:`ChattoRealtimeError` on fatal protocol errors, or
+    :class:`ChattoConnectError` if the initial HTTP handshake fails.
+    """
+    conn = RealtimeConnection(client, protocol_version=protocol_version)
+    try:
+        await conn.connect()
+        async for event in conn.events():
+            yield event
+    finally:
+        await conn.close()
+
+
+__all__ = [
+    "REALTIME_PATH",
+    "REALTIME_PROTOCOL_VERSION",
+    "ChattoRealtimeCloseError",
+    "ChattoRealtimeError",
+    "RealtimeConnection",
+    "RealtimeEvent",
+    "ServerHello",
+    "realtime_url",
+    "stream_events",
+]

+ 126 - 0
tests/test_realtime.py

@@ -0,0 +1,126 @@
+"""Tests for the realtime WebSocket helpers.
+
+Exercises the pure functions and the frame decoding path. The WebSocket
+handshake itself is covered by the live integration test.
+"""
+
+from __future__ import annotations
+
+import pytest
+
+from chattolib.realtime import (
+    ChattoRealtimeCloseError,
+    ChattoRealtimeError,
+    RealtimeEvent,
+    _wrap_event,
+    realtime_url,
+)
+
+
+def test_realtime_url_https_to_wss():
+    assert realtime_url("https://chat.chatto.run") == "wss://chat.chatto.run/api/realtime"
+
+
+def test_realtime_url_http_to_ws():
+    assert realtime_url("http://localhost:9000") == "ws://localhost:9000/api/realtime"
+
+
+def test_realtime_url_strips_trailing_slash():
+    assert (
+        realtime_url("https://chat.chatto.run/") == "wss://chat.chatto.run/api/realtime"
+    )
+
+
+def test_wrap_event_message_posted():
+    from chattolib._pb.chatto.realtime.v1 import realtime_pb2
+
+    envelope = realtime_pb2.RealtimeEventEnvelope()
+    envelope.id = "evt_1"
+    envelope.actor_id = "u1"
+    envelope.message_posted.room_id = "r1"
+    envelope.message_posted.message_event_id = "e1"
+
+    wrapped = _wrap_event(envelope)
+    assert isinstance(wrapped, RealtimeEvent)
+    assert wrapped.id == "evt_1"
+    assert wrapped.kind == "message_posted"
+    assert wrapped.actor_id == "u1"
+    assert wrapped.payload.room_id == "r1"
+    assert wrapped.payload.message_event_id == "e1"
+
+
+def test_wrap_event_presence_changed():
+    from chattolib._pb.chatto.api.v1 import presence_pb2
+    from chattolib._pb.chatto.realtime.v1 import realtime_pb2
+
+    envelope = realtime_pb2.RealtimeEventEnvelope()
+    envelope.id = "evt_2"
+    envelope.presence_changed.user_id = "u1"
+    envelope.presence_changed.status = presence_pb2.PresenceStatus.PRESENCE_STATUS_ONLINE
+
+    wrapped = _wrap_event(envelope)
+    assert wrapped.kind == "presence_changed"
+    assert wrapped.payload.user_id == "u1"
+    assert wrapped.payload.status == presence_pb2.PresenceStatus.PRESENCE_STATUS_ONLINE
+    # No actor_id set on this envelope, so it should be None.
+    assert wrapped.actor_id is None
+
+
+def test_wrap_event_without_variant():
+    """Envelope with no oneof set (server bug or truncation) should still wrap."""
+    from chattolib._pb.chatto.realtime.v1 import realtime_pb2
+
+    envelope = realtime_pb2.RealtimeEventEnvelope()
+    envelope.id = "evt_3"
+
+    wrapped = _wrap_event(envelope)
+    assert wrapped.kind == ""
+    assert wrapped.payload is None
+
+
+def test_close_exception_carries_reconnect_hint():
+    exc = ChattoRealtimeCloseError(
+        "auth_expired", "please reconnect", reconnect=True, retry_after_ms=5000
+    )
+    assert exc.code == "auth_expired"
+    assert exc.reconnect is True
+    assert exc.retry_after_ms == 5000
+    assert "auth_expired" in str(exc)
+
+
+def test_error_exception_marks_fatal():
+    fatal = ChattoRealtimeError("protocol_error", "bad frame", fatal=True)
+    assert fatal.fatal is True
+    recoverable = ChattoRealtimeError("noop", "ignore me")
+    assert recoverable.fatal is False
+
+
+def test_frame_roundtrip_hello():
+    """Client hello serializes and parses back with the fields we set."""
+    from chattolib._pb.chatto.realtime.v1 import realtime_pb2
+
+    frame = realtime_pb2.RealtimeClientFrame()
+    frame.hello.protocol_version = 1
+    frame.hello.bearer_token = "cht_abc"
+    wire = frame.SerializeToString()
+
+    parsed = realtime_pb2.RealtimeClientFrame()
+    parsed.ParseFromString(wire)
+    assert parsed.WhichOneof("frame") == "hello"
+    assert parsed.hello.protocol_version == 1
+    assert parsed.hello.bearer_token == "cht_abc"
+
+
+@pytest.mark.parametrize(
+    "case,attr",
+    [
+        ("subscribe_events", "subscribe_events"),
+        ("ping", "ping"),
+    ],
+)
+def test_client_frame_oneof_cases(case: str, attr: str):
+    from chattolib._pb.chatto.realtime.v1 import realtime_pb2
+
+    frame = realtime_pb2.RealtimeClientFrame()
+    getattr(frame, attr).SetInParent()
+    assert frame.WhichOneof("frame") == case

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott