Skip to content

Commit 51aeda8

Browse files
authored
Update .coderabbit.yaml
Signed-off-by: MontyPokemon <59332150+MonaaEid@users.noreply.github.com>
1 parent 0276732 commit 51aeda8

File tree

1 file changed

+112
-110
lines changed

1 file changed

+112
-110
lines changed

.coderabbit.yaml

Lines changed: 112 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ language: "en-US" # USA English
44
# It should not state additional information like: related issues, PRs, suggest reviewers
55
# It should not continue a casual conversation with users that reply to it
66

7+
knowledge_base: # Enable knowledge base access for up-to-date information
8+
web_search: # Enable web search for up-to-date information
9+
enabled: true
710
# Only documents non-default options:
811
reviews:
912
profile: "assertive" # Assertive profile yields more feedback, that may be considered nitpicky.
@@ -18,9 +21,7 @@ reviews:
1821
in_progress_fortune: false # Do not stall time with a message (spammy)
1922
poem: false # Do not write a literal poem (spammy)
2023
enable_prompt_for_ai_agents: false # Disable prompts for AI agents (spammy)
21-
knowledge_base: # Enable knowledge base access for up-to-date information
22-
web_search: # Enable web search for up-to-date information
23-
enabled: true
24+
2425

2526
# TOKEN REVIEW INSTRUCTIONS
2627
token_review_instructions: &token_review_instructions |
@@ -568,6 +569,114 @@ reviews:
568569
- Do NOT suggest fixes inline.
569570
- Instead, aggregate all out-of-scope issues into a single comment with a list of recommendations for one or more follow-up issues that can be created.
570571
path_instructions:
572+
# PROTOBUF INSTRUCTIONS
573+
- path: "src/hiero_sdk_python/**/*.py"
574+
instructions: |
575+
## Protobuf Schema Alignment Review
576+
577+
### Step 1 — Detect protobuf imports
578+
579+
Scan the file for all imports matching this pattern:
580+
`from hiero_sdk_python.hapi.<path> import <module>_pb2`
581+
582+
For each import found, skip `_grpc` stubs (those end in `_pb2_grpc`) — only
583+
process `_pb2` message modules.
584+
585+
### Step 2 — Construct the canonical schema URL
586+
587+
For each `_pb2` import:
588+
1. Extract the path segment after `hapi`
589+
(e.g. `services` from `hiero_sdk_python.hapi.services`)
590+
2. Extract the module name before `_pb2`
591+
(e.g. `transaction_record` from `transaction_record_pb2`)
592+
3. Build the canonical URL:
593+
`https://github.com/hashgraph/hedera-protobufs/blob/main/<path>/<module>.proto`
594+
595+
**Example:**
596+
```
597+
Import: from hiero_sdk_python.hapi.services import transaction_record_pb2
598+
Schema: https://github.com/hashgraph/hedera-protobufs/blob/main/services/transaction_record.proto
599+
```
600+
601+
### Step 3 — Compare the SDK class against the proto schema
602+
603+
For each SDK class that calls `_from_proto` or `_to_proto` using messages from
604+
the detected proto module, verify the following:
605+
606+
#### 3a. Field coverage
607+
- Every non-deprecated proto field SHOULD have a corresponding SDK attribute.
608+
- Flag any proto field that is present in the schema but missing from the SDK
609+
class (either as a dataclass field or handled in `_from_proto`).
610+
- Flag any SDK attribute that references a proto field name that does not exist
611+
in the schema.
612+
613+
#### 3b. Field name mapping
614+
- Proto field names use `snake_case` (e.g. `ethereum_hash`) or `camelCase`
615+
(e.g. `transactionHash`, `consensusTimestamp`). Verify that `_from_proto`
616+
accesses the correct proto field name, not a renamed/misspelled version.
617+
- Verify `_to_proto` sets the correct proto field name.
618+
619+
#### 3c. Field type alignment
620+
Check that each SDK field type correctly represents the proto type:
621+
622+
| Proto type | Expected SDK type |
623+
|------------------------|----------------------------------------------|
624+
| `string` | `str \| None` or `str` |
625+
| `bytes` | `bytes \| None` or `bytes` |
626+
| `bool` | `bool` |
627+
| `int32`, `uint32` | `int` |
628+
| `int64`, `uint64`, `sint64` | `int` |
629+
| `MessageType` | corresponding SDK wrapper class or `None` |
630+
| `repeated MessageType` | `list[SdkType]` |
631+
| `repeated scalar` | `list[scalar]` |
632+
633+
#### 3d. `oneof` field handling
634+
- Identify all `oneof` blocks in the proto schema for the message.
635+
- Verify that `_to_proto` does NOT set more than one field from the same
636+
`oneof` block simultaneously. If it does, a `ValueError` guard MUST be
637+
present before setting those fields.
638+
- Verify that `_from_proto` uses `proto.HasField(...)` (not attribute access)
639+
to detect which branch of a `oneof` is populated.
640+
- Common `oneof` groups to watch for in `TransactionRecord`:
641+
- `oneof body { contractCallResult, contractCreateResult }` (fields 7, 8)
642+
- `oneof entropy { prng_bytes, prng_number }` (fields 19, 20)
643+
644+
#### 3e. Bytes field normalization
645+
- Proto `bytes` fields default to `b""` (empty bytes) when unset, not `None`.
646+
- If the SDK models the field as `bytes | None`, verify that `_from_proto`
647+
uses `proto.<field> or None` to normalize empty bytes to `None`.
648+
- Conversely, if `_to_proto` sets a bytes field, verify it guards against
649+
setting `None` (which would cause a protobuf type error).
650+
651+
#### 3f. `_from_proto` / `_to_proto` symmetry
652+
- Every field parsed in `_from_proto` SHOULD also be serialized in `_to_proto`,
653+
and vice versa, unless the field is intentionally read-only (e.g. server-set
654+
fields that clients never send).
655+
- Flag any asymmetry that is not accompanied by a code comment explaining why.
656+
657+
#### 3g. Repeated field default values
658+
- SDK attributes representing proto `repeated` fields MUST default to an empty
659+
list (`field(default_factory=list)`), never `None`.
660+
- Flag any `repeated` field that defaults to `None`.
661+
662+
#### 3h. Type annotation consistency
663+
- The codebase uses `X | None` union syntax (Python 3.10+). Flag any use of
664+
`Optional[X]` from `typing` in newly added or modified code, as it is
665+
inconsistent with the established style.
666+
667+
### Step 4 — Report format
668+
669+
For each issue found, report:
670+
- **File and line**: where the issue occurs
671+
- **Proto field**: the canonical proto field name and number from the schema
672+
- **Issue type**: one of — Missing field | Wrong field name | Wrong type |
673+
oneof violation | Bytes not normalized | Asymmetric round-trip |
674+
Wrong default | Style inconsistency
675+
- **Description**: concise explanation of the discrepancy
676+
- **Suggested fix**: the corrected code snippet
677+
678+
If no issues are found for a file, state:
679+
✅ All mapped proto fields align with the schema at `<URL>`.
571680
# --- CODEOWNERS REVIEW INSTRUCTIONS ---
572681
- path: ".github/CODEOWNERS"
573682
instructions: |
@@ -1081,113 +1190,6 @@ reviews:
10811190
- path: "src/hiero_sdk_python/contract/**"
10821191
instructions: *contract_review_instructions
10831192

1084-
- path: "src/hiero_sdk_python/**/*.py"
1085-
instructions: |
1086-
## Protobuf Schema Alignment Review
1087-
1088-
### Step 1 — Detect protobuf imports
1089-
1090-
Scan the file for all imports matching this pattern:
1091-
`from hiero_sdk_python.hapi.<path> import <module>_pb2`
1092-
1093-
For each import found, skip `_grpc` stubs (those end in `_pb2_grpc`) — only
1094-
process `_pb2` message modules.
1095-
1096-
### Step 2 — Construct the canonical schema URL
1097-
1098-
For each `_pb2` import:
1099-
1. Extract the path segment after `hapi`
1100-
(e.g. `services` from `hiero_sdk_python.hapi.services`)
1101-
2. Extract the module name before `_pb2`
1102-
(e.g. `transaction_record` from `transaction_record_pb2`)
1103-
3. Build the canonical URL:
1104-
`https://github.com/hashgraph/hedera-protobufs/blob/main/<path>/<module>.proto`
1105-
1106-
**Example:**
1107-
```
1108-
Import: from hiero_sdk_python.hapi.services import transaction_record_pb2
1109-
Schema: https://github.com/hashgraph/hedera-protobufs/blob/main/services/transaction_record.proto
1110-
```
1111-
1112-
### Step 3 — Compare the SDK class against the proto schema
1113-
1114-
For each SDK class that calls `_from_proto` or `_to_proto` using messages from
1115-
the detected proto module, verify the following:
1116-
1117-
#### 3a. Field coverage
1118-
- Every non-deprecated proto field SHOULD have a corresponding SDK attribute.
1119-
- Flag any proto field that is present in the schema but missing from the SDK
1120-
class (either as a dataclass field or handled in `_from_proto`).
1121-
- Flag any SDK attribute that references a proto field name that does not exist
1122-
in the schema.
1123-
1124-
#### 3b. Field name mapping
1125-
- Proto field names use `snake_case` (e.g. `ethereum_hash`) or `camelCase`
1126-
(e.g. `transactionHash`, `consensusTimestamp`). Verify that `_from_proto`
1127-
accesses the correct proto field name, not a renamed/misspelled version.
1128-
- Verify `_to_proto` sets the correct proto field name.
1129-
1130-
#### 3c. Field type alignment
1131-
Check that each SDK field type correctly represents the proto type:
1132-
1133-
| Proto type | Expected SDK type |
1134-
|------------------------|----------------------------------------------|
1135-
| `string` | `str \| None` or `str` |
1136-
| `bytes` | `bytes \| None` or `bytes` |
1137-
| `bool` | `bool` |
1138-
| `int32`, `uint32` | `int` |
1139-
| `int64`, `uint64`, `sint64` | `int` |
1140-
| `MessageType` | corresponding SDK wrapper class or `None` |
1141-
| `repeated MessageType` | `list[SdkType]` |
1142-
| `repeated scalar` | `list[scalar]` |
1143-
1144-
#### 3d. `oneof` field handling
1145-
- Identify all `oneof` blocks in the proto schema for the message.
1146-
- Verify that `_to_proto` does NOT set more than one field from the same
1147-
`oneof` block simultaneously. If it does, a `ValueError` guard MUST be
1148-
present before setting those fields.
1149-
- Verify that `_from_proto` uses `proto.HasField(...)` (not attribute access)
1150-
to detect which branch of a `oneof` is populated.
1151-
- Common `oneof` groups to watch for in `TransactionRecord`:
1152-
- `oneof body { contractCallResult, contractCreateResult }` (fields 7, 8)
1153-
- `oneof entropy { prng_bytes, prng_number }` (fields 19, 20)
1154-
1155-
#### 3e. Bytes field normalization
1156-
- Proto `bytes` fields default to `b""` (empty bytes) when unset, not `None`.
1157-
- If the SDK models the field as `bytes | None`, verify that `_from_proto`
1158-
uses `proto.<field> or None` to normalize empty bytes to `None`.
1159-
- Conversely, if `_to_proto` sets a bytes field, verify it guards against
1160-
setting `None` (which would cause a protobuf type error).
1161-
1162-
#### 3f. `_from_proto` / `_to_proto` symmetry
1163-
- Every field parsed in `_from_proto` SHOULD also be serialized in `_to_proto`,
1164-
and vice versa, unless the field is intentionally read-only (e.g. server-set
1165-
fields that clients never send).
1166-
- Flag any asymmetry that is not accompanied by a code comment explaining why.
1167-
1168-
#### 3g. Repeated field default values
1169-
- SDK attributes representing proto `repeated` fields MUST default to an empty
1170-
list (`field(default_factory=list)`), never `None`.
1171-
- Flag any `repeated` field that defaults to `None`.
1172-
1173-
#### 3h. Type annotation consistency
1174-
- The codebase uses `X | None` union syntax (Python 3.10+). Flag any use of
1175-
`Optional[X]` from `typing` in newly added or modified code, as it is
1176-
inconsistent with the established style.
1177-
1178-
### Step 4 — Report format
1179-
1180-
For each issue found, report:
1181-
- **File and line**: where the issue occurs
1182-
- **Proto field**: the canonical proto field name and number from the schema
1183-
- **Issue type**: one of — Missing field | Wrong field name | Wrong type |
1184-
oneof violation | Bytes not normalized | Asymmetric round-trip |
1185-
Wrong default | Style inconsistency
1186-
- **Description**: concise explanation of the discrepancy
1187-
- **Suggested fix**: the corrected code snippet
1188-
1189-
If no issues are found for a file, state:
1190-
✅ All mapped proto fields align with the schema at `<URL>`.
11911193

11921194
- path: "src/hiero_sdk_python/consensus/**/*.py"
11931195
instructions: |

0 commit comments

Comments
 (0)