Skip to main content

Journal

Struct Journal 

Source
pub struct Journal { /* private fields */ }

Implementations§

Source§

impl Journal

Source

pub fn open(path: &Path) -> Result<Self, JournalError>

Source

pub fn begin_session( &self, id: &str, harness: &str, cwd: &str, ) -> Result<(), JournalError>

Source

pub fn start_action( &self, new: &NewAction<'_>, ) -> Result<ActionId, JournalError>

Record a new action as pending. Any older still-pending action in the same session is closed as abandoned — its post event will never come (captured contract: failures emit no PostToolUse).

Source

pub fn complete_by_tool_use( &self, session_id: &str, tool_use_id: &str, duration_ms: i64, ) -> Result<ActionId, JournalError>

Close a pending action via its pre/post correlation key. Also accepts an abandoned action: with interleaved or background tool calls a post can arrive after the next action’s start already abandoned its pre — the late post is ground truth and wins over our guess.

Source

pub fn end_session(&self, id: &str) -> Result<(), JournalError>

Source

pub fn attach_manifest( &self, action: ActionId, manifest: &Manifest, role: ManifestRole, ) -> Result<(), JournalError>

Source

pub fn manifests(&self, action: ActionId) -> Result<Vec<Manifest>, JournalError>

All manifests of an action, regardless of role.

Source

pub fn manifests_by_role( &self, action: ActionId, role: ManifestRole, ) -> Result<Vec<Manifest>, JournalError>

Manifests of an action filtered by role (pre = undo side, post = redo side / conflict oracle).

Source

pub fn latest_undoable(&self) -> Result<Option<ActionRecord>, JournalError>

Newest command-kind action that is plausibly undoable: completed or abandoned, with at least one pre-manifest. Searches across sessions.

Source

pub fn recent_actions( &self, limit: i64, ) -> Result<Vec<ActionRecord>, JournalError>

Most recent actions across all sessions, newest first (for log).

Source

pub fn latest_redoable(&self) -> Result<Option<ActionRecord>, JournalError>

Newest live undo action (redo target): kind undo, still completed.

Source

pub fn record_undo( &self, session_id: &str, target: ActionId, ) -> Result<ActionId, JournalError>

Record an undo of target as a new journaled action. The target flips to undone, remembering its prior status on the undo row; undoing an undo restores that recorded status to the original — redo without fabricating history. The status check runs INSIDE the transaction, so racing double-undos admit exactly one winner, and an already-undone target is refused (redo targets the undo action, not the original).

Chains are bounded by design: undoable targets are command actions and first-level undos (redo). Undoing a redo is refused with a pointer to the original — the same capability with a trivially-consistent state machine instead of recursive status cascades (audit round 4). The exhaustive small-model test in T4 checks every sequence to depth 4 against a reference implementation of these rules.

Source

pub fn add_note(&self, action: ActionId, note: &str) -> Result<(), JournalError>

Append a note line to an action (used for loud protection-gap records: truncated snapshots, per-path failures).

Source

pub fn set_pinned( &self, action: ActionId, pinned: bool, ) -> Result<(), JournalError>

Source

pub fn live_hashes( &self, retain_after_ms: i64, ) -> Result<BTreeSet<String>, JournalError>

Store hashes that GC must keep: referenced by a pinned action, by any action started at/after retain_after_ms, or by an action that a live (pinned/recent) undo targets — a kept chain row must keep its objects, or redo would fail on a journal entry that still exists.

Source

pub fn action(&self, id: ActionId) -> Result<ActionRecord, JournalError>

Source

pub fn session_actions( &self, session_id: &str, ) -> Result<Vec<ActionRecord>, JournalError>

Source

pub fn max_started_at(&self) -> Result<Option<i64>, JournalError>

Newest action timestamp in the journal — the reference point for retention cutoffs. NEVER use the wall clock for that (CLAUDE.md: a backward NTP jump would make recent snapshots look collectable).

Source

pub fn prune_before( &self, cutoff_ms: i64, dry_run: bool, ) -> Result<(u64, u64), JournalError>

Prune journal rows older than cutoff_ms. Never touches pinned rows, pending rows, or rows referenced as an undo target by a surviving row (chain integrity; the referencing row’s own pruning frees them for the NEXT pass — eventual cleanup). Old raw_command strings may embed secrets, which is why pruning rows (not just store objects) matters. Returns (actions_pruned, sessions_pruned); dry_run only counts.

Source

pub fn oldest_evictable_batch_end( &self, batch: u32, before_ms: i64, ) -> Result<Option<i64>, JournalError>

The started_at_ms of the last row in the next oldest-first batch of evictable actions strictly before before_ms (size-cap eviction, D2). Evictable = the same condition prune_before deletes by: unpinned, non-pending, not referenced by an undo. None = nothing left to evict below the ceiling — the caller must stop and report, never force.

Source

pub fn set_started_at_for_test( &self, action: ActionId, at_ms: i64, ) -> Result<(), JournalError>

Test support: rewrite an action’s timestamp so retention tests can construct explicit timelines. Not part of the product surface.

Source

pub fn set_session_started_at_for_test( &self, session_id: &str, at_ms: i64, ) -> Result<(), JournalError>

Test support: backdate a session’s start so retention tests can build explicit timelines. Not part of the product surface.

Source

pub fn stats(&self) -> Result<(u64, Vec<(String, u64)>), JournalError>

(sessions, per-status action counts) for status/doctor.

Source

pub fn integrity_check(&self) -> Result<bool, JournalError>

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

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