Skip to main content

CheckpointObserver

Struct CheckpointObserver 

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

WriteObserver implementation backing [capabilities.checkpoint]. One instance per crate::Agent (installed on its crate::tools::ToolContext AND held directly so crate::Agent::run_loop can call Self::begin_turn once per user turn — see that method’s call site’s doc comment).

Implementations§

Source§

impl CheckpointObserver

Source

pub fn new( store: CheckpointStore, project_root: PathBuf, retain: usize, protected: Vec<String>, ) -> CheckpointObserver

protected layers extra glob patterns (typically Config::permissions_protected_paths, when module 13 is active) on top of the unconditional .git/** floor — consulted by Self::restore.

Source

pub fn store(&self) -> &CheckpointStore

Read-only access to the underlying store (e.g. so a caller can list/turn_diff/restore without re-deriving the root path).

Source

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

List every checkpoint, newest first — see CheckpointStore::list.

Source

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

D3 turn-diff for one checkpoint — see CheckpointStore::turn_diff.

Source

pub fn restore(&self, id: &str) -> Result<RestoreReport, Error>

D4-adjacent revert: restore this project’s working files to checkpoint id, honoring THIS observer’s own project_root and protected globs (the fields set at construction) — see CheckpointStore::restore for the full security contract.

Source

pub fn is_disabled(&self) -> bool

Whether this observer has disabled itself after an I/O failure.

Source

pub fn begin_turn(&self, label: &str) -> Option<String>

Open a fresh checkpoint for a new turn — called once at the top of crate::Agent::run_loop (i.e. once per Agent::send/ send_with_files/send_with_images call, cc’s “per-prompt file-history-snapshot”). label is a short excerpt of the turn’s prompt, display-only. Also prunes past the retention bound here (once per turn, not once per write) — see CheckpointStore::prune. Returns None when disabled (config-off is never routed here at all — see observer_for_config — so None here specifically means an I/O failure already tripped the breaker).

Source

pub fn current(&self) -> Option<String>

The checkpoint currently open for the in-flight turn, if any.

Trait Implementations§

Source§

impl Debug for CheckpointObserver

Source§

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

Formats the value using the given formatter. Read more
Source§

impl WriteObserver for CheckpointObserver

Source§

fn before_write<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 Path, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, CheckpointObserver: 'async_trait,

path (already resolved + sandbox-checked) is about to be created/overwritten/deleted. Implementations must be fast and must never propagate a failure as a tool error — a capture failure should degrade the OBSERVER (e.g. disable itself with a one-time warning), never block or fail the user’s actual edit.
Source§

fn after_write<'life0, 'life1, 'async_trait>( &'life0 self, _path: &'life1 Path, ) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, CheckpointObserver: 'async_trait,

path was just written/deleted successfully. Not called when the tool call itself failed (e.g. the write errored before completing). Returns an optional annotation for the calling tool’s result text — see the trait doc comment above.

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