[package]
name = "peat-protocol"
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
repository.workspace = true
description = "Peat Coordination Protocol — hierarchical capability composition over CRDTs for heterogeneous mesh networks"
homepage = "https://github.com/defenseunicorns/peat"
documentation = "https://docs.rs/peat-protocol"

[package.metadata.docs.rs]
# Build docs.rs with every feature enabled so the `relay-n0-hosted` opt-in
# (and other gated items) render. `--cfg docsrs` enables the
# `#[cfg_attr(docsrs, feature(doc_auto_cfg))]` attribute in `lib.rs`,
# which makes rustdoc emit "Available on crate feature `X` only" badges
# next to feature-gated items.
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
keywords = ["peat", "protocol", "mesh", "crdt", "coordination"]
categories = ["network-programming"]

[dependencies]
# Peat facade: peat-protocol re-exports peat-schema and peat-mesh so
# downstream consumers can depend on peat-protocol alone.
peat-schema = { path = "../peat-schema", version = "=0.9.0-rc.15" }
peat-mesh = { workspace = true }

tokio = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
uuid = { workspace = true }
thiserror = { workspace = true }
anyhow = { workspace = true }
async-trait = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
dotenvy = { workspace = true }
chrono = { workspace = true }
# geohash vendored in src/geohash.rs (supply chain audit 2026-03-26)
tempfile = "3.13"
base64 = "0.22"
prost = "0.13"
# postcard: codec-internal binary serialization between Translator
# (Rust) and OutboundSink (Kotlin/Swift via FFI). Per ADR-059 Slice 1.b
# (peat-mesh ADR-0011); chosen over ciborium for active maintenance,
# embedded-Rust ecosystem fit (embassy/esp-hal, peat-lite), and
# documented frozen v1 wire format. See ADR-059 §"Per-transport
# channel sizing" and Slice 1.b project-health audit notes.
postcard = { version = "1", default-features = false, features = ["alloc"] }

# Security/Crypto dependencies (ADR-006)
ed25519-dalek = { version = "2", features = ["rand_core"] }
bitflags = "2"  # Permission flags for membership certificates (ADR-048)
sha2 = "0.10"
rand_core = { version = "0.6", features = ["getrandom"] }
argon2 = "0.5"  # Password hashing (Phase 3: User Auth)
hmac = "0.12"   # TOTP implementation (Phase 3: User Auth)
# Encryption (Phase 4: Encryption & Audit). Symmetric AEAD + DH primitives
# live in peat-mesh per ADR-060 §5 (FIPS posture: AES-256-GCM + ECDH-P256).
# peat-protocol re-exports them via `pub use peat_mesh::security::{...}`.
# The previous direct `chacha20poly1305` + `x25519-dalek` entries here were
# dead manifest declarations (grep `src/` returned zero uses) AND contradicted
# the FIPS rule — removed 2026-05-18 alongside the rc.12 bump.
hkdf = "0.12"              # HKDF key derivation
subtle = "2.6"             # Constant-time comparison (formation key auth)

# CRDT Backends (E8 Evaluation - ADR-007)
automerge = { version = "0.7.1", optional = true }  # Automerge CRDT library for evaluation

# AutomergeIrohBackend dependencies (ADR-011)
#
# ADR-062 Phase 2 (peat#926, this PR) — `iroh`, `iroh-blobs`, and
# `iroh-mdns-address-lookup` are no longer direct deps of peat-protocol.
# All three reach peat-protocol transitively via peat-mesh, which is now
# the canonical owner of the iroh `Endpoint` wrapper, the
# `MeshTransport` trait impl, and the iroh-backed types peat-protocol's
# surviving consumers reference (`EndpointId`, `Connection`,
# `DiscoveryEvent` — all re-exported from `peat_mesh::network` as of
# peat-mesh 0.9.0-rc.22). Dropping them here satisfies the ADR-062
# acceptance gate #2: "peat-protocol/Cargo.toml direct-deps section no
# longer lists iroh or iroh-blobs". The iroh feature configuration
# (`default-features = false`, `tls-aws-lc-rs`, `metrics`,
# `fast-apple-datapath`, `portmapper`) lives in `peat-mesh/Cargo.toml`
# — peat-mesh is the canonical iroh consumer per ADR-060 §5 (FIPS
# posture: aws-lc-rs, not ring).
redb = { version = "2.4", optional = true }  # Pure Rust embedded database (pinned to 2.x - 3.x has memory regression, Issue #446)
lru = { version = "0.16.3", optional = true }  # LRU cache for hot documents
toml = { version = "0.8", optional = true }  # Static peer configuration
hex = "0.4"  # Hex encoding for PublicKeys and encryption keys
# mdns-sd removed under peat#898: the transport-coupled MdnsDiscovery in
# `src/discovery/peer.rs` was retired in favor of the canonical
# `peat_mesh::discovery::MdnsDiscovery`. Per `peat/SKILL.md`'s
# transport-agnosticism rule, IP-stack-specific discovery code lives in
# the peat-mesh sibling crate, not here.
rand = { version = "0.9", optional = true }  # Random number generation for retry jitter
futures-lite = { version = "2", optional = true }  # Minimal stream utilities (Issue #233)
negentropy = { version = "0.5", optional = true }  # Set reconciliation protocol (ADR-040, Issue #435)

# TAK/CoT Integration (ADR-020, ADR-028)
quick-xml = { version = "0.37", features = ["serialize"] }  # CoT XML encoding/decoding

# Peat-Lite transport (ADR-035)
log = { version = "0.4", optional = true }  # Logging for lite transport

# Bluetooth LE transport (ADR-032, ADR-039)
peat-btle = { workspace = true, optional = true }

[features]
default = ["automerge-backend"]
# Automerge/Iroh backend - pure Rust, works on Android
automerge-backend = ["automerge", "redb", "lru", "toml", "rand", "futures-lite", "negentropy", "peat-mesh/automerge-backend"]
# Peat-Lite transport - UDP-based communication with embedded devices (ADR-035)
lite-transport = ["log", "peat-mesh/lite-bridge"]
# Bluetooth LE transport - BLE mesh networking (ADR-032, ADR-039)
bluetooth = ["peat-btle", "peat-mesh/bluetooth"]
# Opt-in to n0's hosted relay pool and DNS pkarr discovery (issue #833).
# Off by default: tactical/edge builds must not phone home through n0
# infrastructure. Turn on only for environments that explicitly want
# n0-hosted NAT traversal and global discovery.
relay-n0-hosted = []

[dev-dependencies]
proptest = { workspace = true }
criterion = { workspace = true }
tokio = { workspace = true, features = ["test-util"] }
tempfile = "3.13"
serial_test = "3.1"  # Serialize tests sharing global state (iroh endpoints)
# ADR-062 Phase 2 (peat#926): iroh is no longer a `[dependencies]` entry
# (peat-protocol/src/ reaches iroh types via `peat_mesh::network`
# re-exports). A handful of integration tests under `tests/` still
# use direct iroh APIs (`Endpoint::builder`, `TransportAddr`,
# `EndpointAddr`) to construct minimal endpoint scaffolding for
# transport-level sync e2e checks. Keeping iroh as a dev-only dep so
# those tests keep compiling without putting iroh back into the
# runtime dep tree. Same feature set as peat-mesh's iroh activation
# (default-features off + `tls-aws-lc-rs`) for FIPS posture parity.
iroh = { version = "=1.0.0-rc.0", default-features = false, features = ["tls-aws-lc-rs"] }

[[bench]]
name = "cap_benchmarks"
harness = false
