pub struct WriteObserverChain(/* private fields */);Expand description
P5-11 (§2 modules 28/29, D-5 “shared write-path interception seam”): an
ORDERED chain of WriteObservers installed as a single
ToolContext::write_observer, so the ONE seam P5-9 built keeps
supporting exactly one call site per tool while now composing multiple
concerns. Order is caller-determined (crate::agent::build_tool_context
builds it checkpoint → formatters → lsp, design’s own required
ordering: checkpoint must capture the PRE-image before anything mutates
the file; formatters must run before lsp so diagnostics reflect the
FINAL, formatted file, not the model’s pre-format draft).
before_write runs every observer in order; after_write runs every
observer in order too and joins any non-empty annotations with a blank
line, so a formatter’s diff-back and an LSP diagnostics block can both
appear in one tool result without one silently discarding the other.
Implementations§
Source§impl WriteObserverChain
impl WriteObserverChain
Sourcepub fn new(observers: Vec<Arc<dyn WriteObserver>>) -> WriteObserverChain
pub fn new(observers: Vec<Arc<dyn WriteObserver>>) -> WriteObserverChain
Build a chain that runs observers in order for both hooks.
Trait Implementations§
Source§impl Debug for WriteObserverChain
impl Debug for WriteObserverChain
Source§impl WriteObserver for WriteObserverChain
impl WriteObserver for WriteObserverChain
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,
WriteObserverChain: 'async_trait,
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,
WriteObserverChain: '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,
WriteObserverChain: '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
'life0: 'async_trait,
'life1: 'async_trait,
WriteObserverChain: '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.