Skip to main content

CheckpointStore

Struct CheckpointStore 

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

A directory-backed, content-addressed shadow store rooted at root — see the module doc comment. Never touches anything outside root except (during Self::restore) the project files a manifest names, which are re-validated against project_root independently of how the manifest was produced.

Implementations§

Source§

impl CheckpointStore

Source

pub fn open(root: impl Into<PathBuf>) -> Result<CheckpointStore, Error>

Open (creating if needed) a store at root. Err if root can’t be created (e.g. an unwritable state dir) — callers (see observer_for_config) treat that as “disable checkpoint, warn once”, never a crash.

Source

pub fn create_checkpoint(&self, label: &str) -> Result<String, Error>

Mint a fresh checkpoint (a new turn) with an empty file list. label is display-only.

Source

pub fn record_pre_image( &self, id: &str, rel: &str, content: Option<Vec<u8>>, ) -> Result<(), Error>

Idempotently record rel’s pre-image under checkpoint id — a SECOND call for the same (id, rel) pair is a no-op (the manifest always keeps the EARLIEST pre-image seen this turn, which is the one a revert needs). content: None means the file did not exist yet.

Source

pub fn manifest(&self, id: &str) -> Result<CheckpointManifest, Error>

Read one checkpoint’s full manifest.

Source

pub fn list(&self) -> Result<Vec<CheckpointMeta>, Error>

Every checkpoint in the store, newest first (ids are millis-prefixed so lexical descending order IS chronological descending order). A corrupt individual manifest is skipped (resilience — one bad file never hides every other checkpoint), not a hard error.

Source

pub fn turn_diff(&self, id: &str) -> Result<Vec<String>, Error>

D3 turn-diff: the set of project-relative paths this checkpoint’s turn touched — exactly the manifest’s file list (every entry exists BECAUSE a write-tool call captured a pre-image for it this turn).

Source

pub fn restore( &self, id: &str, project_root: &Path, protected_globs: &[String], ) -> Result<RestoreReport, Error>

D4-adjacent revert: restore project_root’s working files to checkpoint id. For each manifest entry: Some(blob) rewrites the file to that pre-image; None (didn’t exist before the turn) deletes it if present now (undoing a create). SECURITY: every target is independently re-validated (never trusts the manifest was produced honestly) against project_root containment (no symlink escape, no .. traversal) AND protected_globs (plus an unconditional .git/** floor) checked against BOTH the LEXICAL normalized path and the symlink-RESOLVED path — a lexical-only check would miss a manifest entry like foo/config where foo is a pre-existing symlink into .git: lexically it’s clean, but it resolves inside root (so containment alone accepts it too) and lands on the real .git/config. A refused entry is recorded in RestoreReport::refused, never silently applied AND never aborts the rest of the restore (partial-success, fully reported).

Source

pub fn prune(&self, keep: usize) -> Result<usize, Error>

Bounded-disk requirement: keep only the keep newest checkpoints, deleting the rest, then GC any blob no longer referenced by a surviving manifest. Returns the number of checkpoints removed.

Trait Implementations§

Source§

impl Debug for CheckpointStore

Source§

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

Formats the value using the given formatter. Read more

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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