Skip to main content

MemoryProvenanceStore

Trait MemoryProvenanceStore 

Source
pub trait MemoryProvenanceStore: Send + Sync {
    // Required methods
    fn append(
        &self,
        input: MemoryProvenanceAppend,
    ) -> Result<MemoryProvenanceEntry, MemoryProvenanceError>;
    fn get_entry(
        &self,
        entry_id: &str,
    ) -> Result<Option<MemoryProvenanceEntry>, MemoryProvenanceError>;
    fn latest_for_key(
        &self,
        store: &str,
        key: &str,
    ) -> Result<Option<MemoryProvenanceEntry>, MemoryProvenanceError>;
    fn verify_entry(
        &self,
        entry_id: &str,
    ) -> Result<ProvenanceVerification, MemoryProvenanceError>;
    fn chain_digest(&self) -> Result<String, MemoryProvenanceError>;
}
Expand description

Contract for the append-only, hash-chained memory provenance log.

Implementations MUST:

  1. Compute prev_hash by reading the tail entry inside the same transactional scope as the append, so concurrent appenders cannot both read the same tail and produce a forked chain.
  2. Populate hash with recompute_entry_hash (or equivalent) so every consumer can independently verify the entry.
  3. Keep the chain insertion order total: append followed by latest_for_key / chain_digest must observe the freshly written entry.

Required Methods§

Source

fn append( &self, input: MemoryProvenanceAppend, ) -> Result<MemoryProvenanceEntry, MemoryProvenanceError>

Append a new entry, computing the chain linkage atomically.

Source

fn get_entry( &self, entry_id: &str, ) -> Result<Option<MemoryProvenanceEntry>, MemoryProvenanceError>

Fetch an entry by its unique id. Returns Ok(None) when the id is absent; consumers should treat that as UnverifiedReason::NoProvenance when it happens during a read.

Source

fn latest_for_key( &self, store: &str, key: &str, ) -> Result<Option<MemoryProvenanceEntry>, MemoryProvenanceError>

Fetch the most-recent entry for a (store, key) pair, or Ok(None) when no entry has ever been appended for that key.

Source

fn verify_entry( &self, entry_id: &str, ) -> Result<ProvenanceVerification, MemoryProvenanceError>

Verify a specific entry: recompute its hash, confirm its prev_hash matches the entry that sits immediately before it (or the genesis marker for entry #1), and return ProvenanceVerification::Verified when everything checks out.

Source

fn chain_digest(&self) -> Result<String, MemoryProvenanceError>

Aggregate digest of the chain – the hash of the tail entry, or MEMORY_PROVENANCE_GENESIS_PREV_HASH when the chain is empty. Useful for embedding into receipts as a snapshot marker.

Implementors§