open-standards/joule-code/joule-code-rs/crates/jwp/src/lib.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

57 lines
2.2 KiB
Rust

//! # Joule Wire Protocol (JWP)
//!
//! A custom binary framing protocol where every frame header carries
//! cumulative energy cost. Transport-agnostic — works over TCP, QUIC
//! streams, or Unix sockets.
//!
//! ## Frame format (21-byte header + CBOR payload)
//!
//! ```text
//! Offset Size Field
//! 0 1 version (0x01)
//! 1 1 frame_type
//! 2 4 payload_length (u32 big-endian, max 16 MiB)
//! 6 8 energy_uwh (u64 big-endian, cumulative µWh)
//! 14 4 sequence (u32 big-endian, monotonic)
//! 18 3 flags (24-bit bitfield)
//! 21 N payload (CBOR-encoded, canonical RFC 8949)
//! ```
pub mod adaptive_codec;
pub mod codec;
pub mod compression;
pub mod encoding;
pub mod error;
pub mod frame;
pub mod negotiation;
pub mod profile;
pub mod state_machine;
pub mod transport;
#[cfg(feature = "quic")]
pub mod transport_quic;
pub mod transport_tcp;
pub use adaptive_codec::AdaptiveCodec;
pub use codec::JwpCodec;
pub use compression::{
CompressionId, CompressionStrategy, Lz4Compression, NoCompression, ZstdCompression,
};
pub use encoding::{CborPayloadCodec, EncodingId, PayloadCodec};
pub use error::JwpError;
pub use frame::{
BalanceQueryPayload, BalanceResponsePayload, BatchPayload, COMPACT_HEADER_LEN, CommandPayload,
CommandResponsePayload, DonePayload, EnergyBreakdown, EnergyGradientPayload, ErrorPayload,
FrameFlags, FrameHeader, FrameType, HEADER_LEN, HandshakePayload, HandshakeV2Payload,
HeaderFormat, JwpFrame, MetaPayload, NegotiatePayload, PROTOCOL_VERSION, PROTOCOL_VERSION_V2,
PROTOCOL_VERSION_V2_COMPACT, PROTOCOL_VERSION_V2_EXTENDED, ProfileUpdatePayload, QueryPayload,
RateLimitPayload, ReceiptPayload, ResultPayload, StreamChunkPayload, TopupBeginPayload,
TopupResponsePayload, UsageEntryPayload, UsageQueryPayload, UsageResponsePayload, cbor_decode,
cbor_encode,
};
pub use negotiation::NegotiatedCapabilities;
pub use profile::{ConnectionProfile, EnergyReporting, RateLimitInfo};
pub use state_machine::{ProtocolState, ProtocolStateMachine};
pub use transport::{Transport, TransportStats};
#[cfg(feature = "quic")]
pub use transport_quic::QuicTransport;
pub use transport_tcp::TcpTransport;