//! Snapshots: committed states with provenance inside the hash.
use jac_core::{Author, Provenance, SnapshotId, Timestamp, TreeId};
use smallvec::SmallVec;
/// A committed state of the repository.
///
/// Everything in this struct is hashed into the snapshot's id — including
/// [`provenance`](Self::provenance). Relabelling an agent's snapshot as
/// human-authored therefore mints a *different* snapshot with a different id,
/// visible to anything holding the old one. The honest scope of that claim:
/// provenance is unforgeable *after the fact*, not verified *at creation* —
/// nothing here checks that the label was true when the author supplied it.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Snapshot {
/// Root tree of the committed state.
pub tree: TreeId,
/// Parent snapshots; two only at a merge. Inline because almost every
/// snapshot has zero or one.
pub parents: SmallVec<[SnapshotId; 2]>,
/// Who committed it.
pub author: Author,
/// Whose hands made it. Part of the hashed identity.
pub provenance: Provenance,
/// Commit message.
pub message: String,
/// When it was committed, from an injected clock.
pub at: Timestamp,
}