Skip to main content

Log

Struct Log 

Source
pub struct Log;
Expand description

The store’s chronological log: a thin handle for the append-only timeline. All methods take the Store so they resolve the active log.md and the log/ archives under the store root.

Implementations§

Source§

impl Log

Source

pub fn append(store: &Store, entry: &LogEntry) -> Result<()>

Atomically append entry to the active log.md, creating it (with type: log frontmatter) if absent. If the active log holds entries from a prior month, roll those older months into log/<YYYY-MM>.md first (atomic move), keeping the active file to the current month.

Source

pub fn tail(store: &Store, n: usize) -> Result<Vec<LogEntry>>

The n most-recent entries by timestamp, returned oldest→newest.

Out-of-order safety (mirrors Log::since). The log is append-only but not guaranteed to be in non-decreasing timestamp order on disk: a corrective entry is appended below the entry it corrects, a backdated/clock-skewed write lands physically after newer entries, and a merge=union clone merge interleaves both sides until a later agent reorders. Out-of-order is only a LOG_OUT_OF_ORDER warning, never rejected. So the last n physical entries are not the n newest by time — taking them would omit a genuinely-recent entry that sits physically before an older one, and the documented curator warm-up (dbmd log tail 20) would report a stale picture of what was done lately. We therefore feed every entry of each file we touch through a bounded newest-by-timestamp window and let it select the true top n.

Bounded cost: the active log.md is kept to the current month by rotation, so a full read of it is cheap and is not a whole-store walk. Across archives we can prune: each log/<YYYY-MM>.md holds only entries from that month (rotation buckets by the entry’s own year-month), so once the window is full, an archive whose month is strictly before the window-minimum’s month cannot contain any entry newer than the current nth-newest. We cross archives newest-month-first and stop at the first such archive.

Source

pub fn since( store: &Store, time: DateTime<FixedOffset>, ) -> Result<Vec<LogEntry>>

Entries strictly newer than time, reverse-scanning active → archives.

No within-file early stop. The log is append-only but not guaranteed to be in non-decreasing timestamp order on disk: a corrective entry is appended below the entry it corrects (SPEC: “if a finding is wrong, append a corrective entry below it”), a backdated/clock-skewed write lands physically after newer entries, and a merge=union clone merge interleaves both sides until a later agent reorders. Out-of-order is only a LOG_OUT_OF_ORDER warning, never rejected. So a newer entry can sit physically before an older one; stopping at the first older-than-time entry would silently drop those — the documented curator warm-up (dbmd log since <ts>) would miss real recent work. We therefore read every entry of each file we touch.

Bounded cost: the active log.md is kept to the current month by rotation, so a full read of it is cheap (the same read tail does for a large n) and is not a whole-store walk. Across archives we can stop: each log/<YYYY-MM>.md holds only entries from that month (rotation buckets by the entry’s own year-month), so an archive whose month is strictly before time’s month cannot contain any entry newer than time. We cross archives newest-month-first and stop at the first whose month is entirely at or before time’s.

Source

pub fn last_validate_at(store: &Store) -> Result<Option<DateTime<FixedOffset>>>

The timestamp of the most recent validate entry — the default since window for working-set validation (crate::validate::validate_working_set).

Source

pub fn parse_header( line: &str, ) -> Option<(DateTime<FixedOffset>, LogKind, Option<String>)>

Parse a single entry header (## [YYYY-MM-DD HH:MM] <kind> | <object>) into its timestamp, kind, and object. Returns None if the line isn’t a well-formed entry header.

Trait Implementations§

Source§

impl Clone for Log

Source§

fn clone(&self) -> Log

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Log

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Log

§

impl RefUnwindSafe for Log

§

impl Send for Log

§

impl Sync for Log

§

impl Unpin for Log

§

impl UnsafeUnpin for Log

§

impl UnwindSafe for Log

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,