Skip to main content

shep_core/protocol/
mod.rs

1//! The client<->daemon wire protocol (version 2)
2//!
3//! Typed request/response enums + bus events. Framing lives in [`wire`];
4//! every type here is snapshot-pinned — changing any serialized shape is a
5//! protocol version bump recorded in the CHANGELOG.
6//!
7//! **What version 2 added:** the instance slot on [`ProcessInfo`]. A sheep
8//! that is one of several instances of an app reports which slot it is, so
9//! every listing can group an app's instances and roll their numbers up
10//! rather than showing several rows that share a name and explain nothing.
11//! A sheep reports its own slot, counting from 0, so a single-instance app
12//! reports `Some(0)`. `None` means the peer daemon predates the field, and a
13//! reader that finds it should render exactly what it rendered before this
14//! field existed.
15//!
16//! **Two sets of tests carry a version in their name and they assert
17//! opposite things.** The `*_wire_v2` snapshots pin the shape this crate
18//! serializes TODAY, so they follow [`PROTOCOL_VERSION`] and get renamed
19//! whenever it moves. The `v1_*_fixture_still_deserializes` tests pin a
20//! literal payload captured from a version 1 peer and assert it STILL
21//! decodes, so their name records where the bytes came from and never
22//! moves; renaming one would erase the compatibility claim it exists to
23//! make.
24
25pub mod channel;
26pub mod events;
27pub mod frame;
28pub mod request;
29/// Frame encoding shared by daemon and client
30pub mod wire;
31
32pub use channel::{CHANNEL_VERSION, ChildMessage, ShepherdMessage};
33pub use events::{BusEvent, ProcessEventKind};
34pub use frame::ServerFrame;
35pub use request::{
36    ActionOutcome, ActionReply, DogSectionToml, DogSource, Envelope, ExitInfo, Hello, HelloAck,
37    HelloReply, Lamb, LineOutcome, LineReply, ProcessInfo, ProcessInfoBuilder, Reply, Request,
38    Response, RpcError, RpcErrorCode, SelectorSpec, SheepDrift, SignalOutcome, SignalReply, Smit,
39    SmitError, sort_flock,
40};
41pub use wire::{MAX_FRAME_BYTES, WireError, codec, decode_frame, encode_frame};
42
43/// Wire protocol version.
44///
45/// Evolution rule: ADDITIVE optional fields (new serde-defaulted `Option<T>`
46/// fields, new variants behind `#[non_exhaustive]`) keep the version.
47/// Removing, renaming, or retyping anything serialized bumps it, recorded in
48/// the CHANGELOG. Byte fixtures in each protocol module pin the deserialize
49/// direction.
50pub const PROTOCOL_VERSION: u32 = 2;