Skip to content

Commit 2b4c3ec

Browse files
committed
Split proto into separate files
Signed-off-by: Mikhail Agapov <mikhail.agapov@decentraland.org>
1 parent 448f34c commit 2b4c3ec

5 files changed

Lines changed: 4719 additions & 4626 deletions

File tree

.claude/skills/modify-protocol/SKILL.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The protocol is the single source of truth for the wire format. It lives in a **
1515
| Thing | Path | Notes |
1616
|---|---|---|
1717
| Proto sources | `../protocol/proto/decentraland/` | **Sibling repo** — edit these |
18-
| Pulse-specific protos | `../protocol/proto/decentraland/pulse/pulse_comms.proto` | `ClientMessage` / `ServerMessage` envelopes + all game messages |
18+
| Pulse-specific protos | `../protocol/proto/decentraland/pulse/` | Three files: `pulse_client.proto` (C→S messages + `ClientMessage` envelope), `pulse_server.proto` (S→C messages + `ServerMessage` envelope), `pulse_shared.proto` (types referenced by both directions: `PlayerState`, `GlideState`, `PlayerAnimationFlags`) |
1919
| Shared primitives | `../protocol/proto/decentraland/common/` | `vectors.proto`, `options.proto` (custom `quantized` / `bit_packed`), etc. |
2020
| Bitwise plugin | `../protocol/protoc-gen-bitwise/plugin.py` | Python protoc plugin — emits C# `Encode`/`Decode` partials |
2121
| Plugin runtime | `../protocol/protoc-gen-bitwise/runtime/cs/{BitReader,BitWriter,Quantize}.cs` | `Quantize.cs` is copied into `Generated/` at build time |
@@ -34,8 +34,11 @@ Override with `/p:_ProtocolRepo=...` or a local `Directory.Build.props` if your
3434
## Change workflow
3535

3636
1. **Edit the `.proto` file(s)** in `../protocol/proto/decentraland/...`
37-
- For new top-level game messages, add to the `ClientMessage` / `ServerMessage` `oneof` in `pulse_comms.proto`.
38-
- For shared primitives, edit the appropriate file in `common/`.
37+
- **Pick the right pulse file by direction:**
38+
- Client→server message → add it to `pulse_client.proto`, then add the variant to the `ClientMessage` `oneof` at the bottom of that file.
39+
- Server→client message → add it to `pulse_server.proto`, then add the variant to the `ServerMessage` `oneof` at the bottom of that file.
40+
- Type referenced from **both** directions (e.g. another shared state struct like `PlayerState`) → put it in `pulse_shared.proto`. Both `pulse_client.proto` and `pulse_server.proto` import it. Don't cross-import client↔server.
41+
- For shared primitives across protocols (vectors, etc.), edit the appropriate file in `common/`.
3942
- Filenames are `snake_case.proto`; message types are `PascalCase`; fields are `snake_case`.
4043
- **Keep comments minimal** — at most one short line above a message or field. No multi-paragraph docblocks, bullet-list "contracts", or lifecycle prose. The proto is a schema vendored into every client repo; invariants belong in the server handler that enforces them or in the PR description, not here.
4144

@@ -49,7 +52,7 @@ Override with `/p:_ProtocolRepo=...` or a local `Directory.Build.props` if your
4952
// Integer packed into fewer than 32 bits:
5053
uint32 entity_id = 4 [(decentraland.common.bit_packed) = { bits: 20 }];
5154
```
52-
Rules of thumb: match existing tiering in `pulse_comms.proto`; `optional` on a quantized field means it participates in the plugin-generated field_mask (absent fields don't hit the wire).
55+
Rules of thumb: match existing tiering in `pulse_server.proto` (`PlayerStateDeltaTier0`); `optional` on a quantized field means it participates in the plugin-generated field_mask (absent fields don't hit the wire).
5356

5457
3. **Rebuild** — proto regen runs automatically:
5558
```bash
@@ -95,7 +98,7 @@ After regeneration:
9598

9699
1. Build: `DOTNET_ROOT="$HOME/.dotnet" PATH="$HOME/.dotnet:$PATH" dotnet build src/DCLPulse/DCLPulse.sln`
97100
2. Run tests: `DOTNET_ROOT="$HOME/.dotnet" PATH="$HOME/.dotnet:$PATH" dotnet test src/DCLPulse/DCLPulse.sln -p:GenerateProto=false`
98-
3. Verify the new/changed C# types show up in `src/Protocol/Generated/PulseComms.cs` (data class) and `PulseComms.Bitwise.cs` (if the message has `quantized` / `bit_packed` fields).
101+
3. Verify the new/changed C# types show up in the generated file matching the source proto: `src/Protocol/Generated/PulseClient.cs`, `PulseServer.cs`, or `PulseShared.cs` (data classes), plus `PulseServer.Bitwise.cs` etc. (if the message has `quantized` / `bit_packed` fields). All three live in the same `Decentraland.Pulse` namespace, so callers don't need to know which file a type came from.
99102
4. If you changed `ClientMessage` / `ServerMessage` oneofs, confirm the new `MessageOneofCase` enum value appears and your handler is registered.
100103

101104
## Troubleshooting

0 commit comments

Comments
 (0)