CLAUDE.md@mirrord/protocol · git:20260323.2d81e57 · 2026-03-23 · sha256 fcc54c6886bd1501

CLAUDE.md@mirrord/protocol git:20260323.2d81e57A

Immutable. This exact content is served forever at /api/v1/blob/fcc54c6886bd1501.

## Quick Reference

```bash
cargo check -p mirrord-protocol --keep-going
cargo test -p mirrord-protocol
```

## Backward Compatibility

The protocol define the messages that layer, intproxy, agent, and operator send to each other. These components ship independently, so we must make sure that they are able to talk to each other even when running mismatched versions. The wire format is generated by the Rust types layouts through `bincode`, so the declarations in this crate _are_ the wire format.

**Safe changes** (won't break older components):
1. Renaming types, fields, or variants (bincode doesn't use names).
2. Changing a field type only if the bincode representation stays the same.
3. Adding a new enum variant **at the end**, gated by a negotiated protocol version.
4. Code changes that don't affect the wire representation.

**Breaking changes** (will break older components):
1. Adding a field to a struct.
2. Changing `T` to/from `Option<T>`.
3. Reordering enum variants.

Version checks are defined as `LazyLock<VersionReq>` constants near the types they protect. Consumers use `SwitchProtocolVersion` to negotiate.

## CI and Versioning Rules

- This crate is versioned **independently** from the rest of the workspace.
- CI requires that any change under `mirrord/protocol/**` includes a `mirrord/protocol/Cargo.toml` version bump.
- Version bump policy: new protocol capability → bump minor; internal change → bump patch.
- Future cleanup points are marked with `#[protocol_break(<major>)]`.

## Adding a New Protocol Capability

This involves changes across multiple crates:

1. Add new message/types in this crate, following the enum ordering rules above.
2. Add a minimum supported `VersionReq` constant near the new type.
3. Add conversion/fallback behavior where older peers need alternate messages.
4. Update all consumers to handle the new variant.
5. Bump `mirrord/protocol/Cargo.toml` version (usually minor).
6. Run checks across affected crates:
   - `cargo check -p mirrord-protocol --keep-going`
   - `cargo check -p mirrord-intproxy --keep-going`
   - `cargo check -p mirrord-layer --keep-going`
   - `cargo check -p mirrord-agent --target x86_64-unknown-linux-gnu --keep-going`