# Archive library contract

Source: https://usecns.dev/hippocampus-topic-archive-library-contract/

[Start here](https://usecns.dev/manual-hippocampus/)
[CLI commands](https://usecns.dev/commands-hippocampus/)
[Configuration & integration](https://usecns.dev/hippocampus-topics/)

`archive::{Manifest, Bundle, Event}` expose the v1 fields described under archive evidence above. `Bundle::decode(bytes)` returns a decoded envelope, **not validated evidence**; bound input before decoding. Call `bundle.validate()` to check versions, identities, raw/events correspondence and record count/digests. It returns `anyhow::Result`, not the content-free wire error enum. Neither step establishes supported adapter/policy, ownership, trusted enrollment, suppression or cumulative prefix correctness. The historical non-Pi normalizer fallback is not an adapter allowlist.

`digest(bytes) -> String` returns lowercase SHA-256. `normalize(episode, adapter, session, workspace, raw, base, max_record) -> Result<Vec<Event>>` preserves full parsed records and absolute offsets, rejects incomplete/oversized/invalid completed lines and metadata conflicts; callers bound total input and authorize adapters separately. `EpisodeSequence::default()` plus ordered `push(&validated_bundle)` checks contiguous ranges from zero and cumulative prefix digest (16 MiB maximum retained raw prefix). `offset()` and `prefix_sha256()` expose the resulting checkpoint. Supply one trusted episode only; discard the sequence after any push error because its working prefix may already have changed.