# `mirrord-protocol`

## Backwards 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**:

- Renaming types, fields, or variants (bincode doesn't use names).
- Changing a field type only if the bincode representation stays the same.
- Adding a new enum variant **at the end**, gated by a negotiated protocol version.
- Code changes that don't affect the wire representation.

**Breaking changes**:

- Adding a field to a struct.
- Changing `T` to/from `Option<T>`.
- Reordering fields in a struct.
- 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.
