Expand description
The Commy wire contract: the binary range frame and the error-code vocabulary.
The specification is in spec/, the language-neutral golden vectors are in
vectors/, and every SDK runs the same vectors in its own CI. This crate is
the Rust side of that contract and is tested against those exact files.
Structs§
- Authenticate
- Client to server. Carries the protocol version.
- Confirm
Local - Client to server: the nonce read from
nonce_path, proving the same filesystem view. - Confirm
Local Ack - Server to client: the nonce matched; the server deletes the nonce file. A mismatch is an
ErrorwithPERMISSION_DENIED. - Error
Reply - Server to client: a request failed.
- Flush
Ack - Server to client: the flush identified by
request_idis applied;seqis the new sequence. - GetService
File Path - Client to server: may this service file be mapped locally?
- Loss
- Server to a client: writes of its own were lost, and why.
rangesare in old-file coordinates; empty means the whole file. A receiver treats an unknownkindas a loss of the whole file. - Loss
Range - A byte range inside a file.
- Range
Frame - A run of bytes that changed in one service file. All integers are little-endian.
- Resync
- Client to server: send the whole file again (no replay log in v1).
- Resync
Done - Server to client: the last range frame of the snapshot has been sent.
- Rotate
Request - Client to server: replace a service’s file.
new_sizeis required forRESIZEand forbidden forREVOCATION;revoke_client_idis the reverse. SeeRotateRequest::validate. - Rotation
Accepted - Server to client: the request was accepted. The rotation ends with
RotationCommit. - Rotation
Commit - Server to every SDK on the service: the new file is live.
new_file_iddiffers fromold_file_idand is the handle for the new mapping; fetch it withGetServiceFilePath(local) orResync(remote). After a revocation, each remaining SDK writes its unflushed ranges into the new file; after a resize, old-offset writes are never replayed. - Rotation
Drained - Client to server: everything written so far is flushed;
seqis the last sequence flushed. - Rotation
Pending - Server to every SDK on the service (resize only): the drain barrier is open. Stop issuing write
guards, wait for outstanding ones, flush into the old file, then send
RotationDrainedwithindeadline_ms. An SDK that does not is dropped with aROTATION_STRAGGLERLoss. - Service
File Path - Server to client: the
file_idthat range frames use for this service.pathandnonce_pathare both present (local mapping offered) or both absent (stay on WSS ranges). They are absent unless the service is open to local mapping and the caller holds a write grant on it.
Enums§
- Control
Message - JSON control messages, sent as WebSocket text frames. Adjacently tagged
(
{"type": ..., "data": {...}}); unknown fields and unknown types are refused. - Error
Code - The only spellings an error code may have on the wire, from server and SDKs alike.
- Frame
Error - Why a binary frame was refused.
- Loss
Kind - What a program lost.
- Rotate
Reason - Why a service file is being replaced.
Constants§
- HEADER_
LEN - Bytes before the payload: kind (1) + file_id (4) + seq (8) + offset (8) + len (4).
- KIND_
RANGE - First byte of a binary range frame.
- MAX_
PAYLOAD - Largest payload one frame may carry. A bigger change is split into several frames.