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
impl CheckpointObserver
Sourcepub fn new(
store: CheckpointStore,
project_root: PathBuf,
retain: usize,
protected: Vec<String>,
) -> Self
pub fn new( store: CheckpointStore, project_root: PathBuf, retain: usize, protected: Vec<String>, ) -> Self
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.
Sourcepub fn store(&self) -> &CheckpointStore
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).
Sourcepub fn list(&self) -> Result<Vec<CheckpointMeta>>
pub fn list(&self) -> Result<Vec<CheckpointMeta>>
List every checkpoint, newest first — see CheckpointStore::list.
Sourcepub fn turn_diff(&self, id: &str) -> Result<Vec<String>>
pub fn turn_diff(&self, id: &str) -> Result<Vec<String>>
D3 turn-diff for one checkpoint — see CheckpointStore::turn_diff.
Sourcepub fn restore(&self, id: &str) -> Result<RestoreReport>
pub fn restore(&self, id: &str) -> Result<RestoreReport>
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.
Sourcepub fn is_disabled(&self) -> bool
pub fn is_disabled(&self) -> bool
Whether this observer has disabled itself after an I/O failure.
Sourcepub fn begin_turn(&self, label: &str) -> Option<CheckpointId>
pub fn begin_turn(&self, label: &str) -> Option<CheckpointId>
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).
Sourcepub fn current(&self) -> Option<CheckpointId>
pub fn current(&self) -> Option<CheckpointId>
The checkpoint currently open for the in-flight turn, if any.
Trait Implementations§
Source§impl Debug for CheckpointObserver
impl Debug for CheckpointObserver
Source§impl WriteObserver for CheckpointObserver
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
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn before_write<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: '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
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn after_write<'life0, 'life1, 'async_trait>(
&'life0 self,
_path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: '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.