5 releases (1 stable)

new 2026.2.0 Feb 5, 2026
0.0.65 Jan 14, 2026
0.0.64 Dec 20, 2025
0.0.63 Dec 12, 2025
0.0.1 Dec 12, 2025

#755 in Magic Beans

27 downloads per month
Used in 10 crates

MIT/Apache

33KB
267 lines

commonware-conformance

Crates.io Docs.rs

Automatically assert the stability of encoding and mechanisms over time.

Status

Stability varies by primitive. See README for details.


lib.rs:

Automatically assert the stability of encoding and mechanisms over time.

This crate provides a unified infrastructure for verifying that implementations maintain backward compatibility by comparing output against known-good hash values stored in TOML files.

The Conformance Trait

The core abstraction is the Conformance trait, which represents types that can produce deterministic bytes from a seed.

This enables conformance testing across different domains, for example:

  • Codec: Verify wire format stability
  • Storage: Verify on-disk format stability
  • Network: Verify message ordering consistency

Storage Format

Test vectors are stored in a TOML file with a single hash per type:

["Vec<u8>"]
n_cases = 100
hash = "abc123..."

["Vec<u16>"]
n_cases = 100
hash = "def456..."

The hash is computed by generating n_cases commitments (using seeds 0..n_cases), and hashing all the bytes together.

Regeneration Mode

When cfg(generate_conformance_tests) is set, tests regenerate their expected hashes in the TOML file. Use this to intentionally update the format:

RUSTFLAGS="--cfg generate_conformance_tests" cargo test

Dependencies

~3.5–5MB
~115K SLoC