urna-format 0.5.4

Frozen v1 binary container of the Urna vector database: layout, manifest, sections, encodings, hashes, reader and writer
Documentation
//! Regression for the first coverage-guided fuzz finding (cargo-fuzz,
//! `section-decoders`, 2026-09-05): a 90-byte intpack-repacked spans payload
//! claimed a uri pool of 1.3 billion entries and `Vec::with_capacity` asked
//! the allocator for 31 GB. every count-driven allocation on a decode path
//! is bounded by what the bytes can hold before it happens; these are the
//! exact fuzzer inputs (first byte is the harness's decoder selector, the
//! rest is the payload handed to `decode_payload` for encodings 0..=10).

#![allow(
    clippy::unwrap_used,
    clippy::expect_used,
    reason = "test code: a failing unwrap is a failing test"
)]

use urna_format::encoding::decode_payload;

const ARTIFACTS: [&[u8]; 2] = [
    &[
        0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x4e, 0x45, 0x53, 0x03, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
        0x00, 0x00, 0x00, 0x1c, 0x00, 0xff, 0xff, 0x51, 0x00, 0xd0, 0x2d, 0x00, 0x15, 0x19,
    ],
    &[
        0x01, 0x00, 0x00, 0x00, 0x4e, 0x45, 0x03, 0x00, 0x53, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00,
        0x2e, 0x00, 0x15, 0x19,
    ],
];

#[test]
#[cfg_attr(miri, ignore)] // zstd is c code, miri cannot call it
fn hostile_pool_counts_are_typed_errors_not_allocation_aborts() {
    for (i, payload) in ARTIFACTS.iter().enumerate() {
        for enc in 0..=10u32 {
            // any outcome but a panic/abort is acceptable; the payloads are
            // garbage that used to reach a 31 GB reservation.
            let _ = decode_payload(enc, payload);
        }
        assert!(!payload.is_empty(), "artifact {i} must not be empty");
    }
}