open-standards/joule-code/joule-code-rs/crates/jwp/src/error.rs
Transaction Science 08c499f8ca joule-code: port CommunicationOS transport (jwp + joule-moq) into the public standard
The MoQT transport that joule-code-collab's network rung needs lived in the
private joulesperbit repo (as inv-moq + jwp), so a public consumer couldn't
depend on it. Port both into the public open-standards joule-code workspace,
self-contained (concrete dep versions, not workspace-inherited) so a bare git
clone builds them:

- crates/jwp: Joule Wire Protocol — energy-aware binary framing (CBOR, zstd/lz4,
  TCP + optional QUIC). Self-contained, external deps only.
- crates/joule-moq: MoQT (Media-over-QUIC) wire protocol + JWP signed-receipt
  extension for CommunicationOS — Publisher/Subscriber/Relay traits, MockFabric
  (in-process) + a production QUIC path (quic feature). Renamed from inv-moq
  to drop the invisible-* namespace and match the joule-code branding; depends
  only on jwp.

Both build (default + quic) and pass their tests (joule-moq 29, jwp 152) in the
new home. The transport-moqt example now path-deps the public joule-moq instead
of reaching into joulesperbit, and its end-to-end BFT-ops-over-MoQT-with-signed-
receipts tests pass. This unblocks public consumers (agent-zed) from git-depping
the transport for cross-machine fleet coordination.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-06-13 21:29:05 -04:00

50 lines
1.3 KiB
Rust

use thiserror::Error;
/// Errors that can occur during JWP frame encoding/decoding.
#[derive(Debug, Error)]
pub enum JwpError {
#[error("unknown frame type: 0x{0:02x}")]
UnknownFrameType(u8),
#[error("payload too large: {0} bytes (max {MAX_PAYLOAD_LEN})")]
PayloadTooLarge(usize),
#[error("incomplete frame: need {needed} bytes, have {available}")]
IncompleteFrame { needed: usize, available: usize },
#[error("invalid protocol version: {0}")]
InvalidVersion(u8),
#[error("CBOR decode error: {0}")]
CborDecode(String),
#[error("CBOR encode error: {0}")]
CborEncode(String),
#[error("invalid state transition: {from} -> {event}")]
InvalidTransition { from: String, event: String },
#[error("compression error: {0}")]
CompressionError(String),
#[error("negotiation failed: {0}")]
NegotiationFailed(String),
#[error("unsupported encoding: 0x{0:02x}")]
UnsupportedEncoding(u8),
#[error("invalid header format: 0x{0:02x}")]
InvalidHeaderFormat(u8),
#[error("batch decode error: {0}")]
BatchDecodeError(String),
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("authentication error: {0}")]
AuthError(String),
}
/// Maximum payload size: 16 MiB.
pub const MAX_PAYLOAD_LEN: usize = 16 * 1024 * 1024;