Skip to main content

EventLog

Struct EventLog 

Source
pub struct EventLog { /* private fields */ }
Expand description

Handle to the append-only event log.

Implementations§

Source§

impl EventLog

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self, LogError>

Open (creating if needed) a log at path.

Source

pub fn open_in_memory() -> Result<Self, LogError>

Open an ephemeral in-memory log (used in tests).

Source

pub fn enqueue_pending( &self, cmd: &ProposedCommand, class: Class, reason: &str, ) -> Result<(), LogError>

Add a held command to the approval queue (idempotent on its id).

Source

pub fn pending_status(&self, id: &str) -> Result<Option<String>, LogError>

The current status of a queued command, if it is in the queue.

Source

pub fn set_pending_status(&self, id: &str, status: &str) -> Result<(), LogError>

Set a queued command’s status (approved | denied).

Source

pub fn cas_pending_status( &self, id: &str, from: &str, to: &str, ) -> Result<bool, LogError>

Atomically move a queued command from status from to to. Returns true iff this call performed the transition (the row existed and was from).

This is the exactly-once guard: a held command must resolve/run once even if two kintsugi approve/kintsugi run invocations race — only the winner of the compare-and-swap proceeds; the loser sees false and does nothing.

Source

pub fn pending_command( &self, id: &str, ) -> Result<Option<ProposedCommand>, LogError>

The stored command for a queued id (for resolve/re-run).

Source

pub fn list_pending(&self) -> Result<Vec<PendingItem>, LogError>

List the still-pending queued commands, oldest first.

Source

pub fn record_snapshot(&self, manifest: &Manifest) -> Result<(), LogError>

Record a snapshot taken before a destructive command.

Source

pub fn unreverted_snapshots(&self) -> Result<Vec<Manifest>, LogError>

Load all snapshots not yet reverted, newest first.

Source

pub fn latest_unreverted_snapshot(&self) -> Result<Option<Manifest>, LogError>

The most recent not-yet-reverted snapshot, if any.

Source

pub fn mark_reverted(&self, id: &str) -> Result<(), LogError>

Mark a snapshot as reverted (it has been undone).

Source

pub fn remember( &self, repo: &str, command_hash: &str, action: Decision, ) -> Result<(), LogError>

Remember a per-repo decision for an exact command (always-allow / -deny).

Only Allow and Deny are meaningful; Hold is rejected.

Source

pub fn memory_lookup( &self, repo: &str, command_hash: &str, ) -> Result<Option<Decision>, LogError>

Look up a remembered decision for an exact command in a repo.

Source

pub fn log_event( &self, cmd: &ProposedCommand, verdict: &Verdict, snapshot_id: Option<&str>, ) -> Result<LoggedEvent, LogError>

Append one event built from a proposal and its verdict.

Source

pub fn tail(&self, n: usize) -> Result<Vec<LoggedEvent>, LogError>

Return the most recent n non-redacted events, oldest first.

Source

pub fn query(&self, filter: &Filter) -> Result<Vec<LoggedEvent>, LogError>

Return events matching filter, oldest first (capped by filter.limit, skipping filter.offset of the newest matches first for pagination).

Source

pub fn count_matching(&self, filter: &Filter) -> Result<i64, LogError>

Count events matching filter (ignores limit).

Source

pub fn redact(&self, event_id: &str, reason: &str) -> Result<bool, LogError>

Redact a single event by id (append-only; idempotent). Returns whether a matching, not-already-redacted event existed.

Source

pub fn redact_matching( &self, filter: &Filter, reason: &str, ) -> Result<usize, LogError>

Redact every event matching filter (newest-first, no limit applied). Returns the number newly redacted.

Source

pub fn purge_matching( &self, filter: &Filter, reason: &str, ) -> Result<usize, LogError>

Hard erasure — physically delete events matching filter, rebuild the hash chain over the survivors, and append a marker event recording the purge. Deliberately rewrites history for the purged span; never automatic. Returns the number of events removed.

include_redacted/limit on the filter are ignored: purge always targets every matching row. Catastrophic-or-not is irrelevant — this is the user’s explicit erasure of their own local data.

Source

pub fn count(&self) -> Result<i64, LogError>

Total number of events.

Source

pub fn verify_chain(&self) -> Result<ChainStatus, LogError>

Walk the chain from genesis and confirm every link.

Recomputes each row’s hash from its stored fields and verifies it both matches the stored hash and links to the previous row’s hash.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more