Skip to main content

FilePolicy

Trait FilePolicy 

Source
pub trait FilePolicy: Send + Sync {
Show 14 methods // Required methods fn is_secret(&self, path: &Path) -> bool; fn is_secret_ignoring_name_shape(&self, path: &Path) -> bool; fn is_sensitive(&self, path: &Path) -> bool; // Provided methods fn declare_path(&self, path: &str) -> String { ... } fn attaches_images(&self) -> bool { ... } fn shell_tool_name(&self) -> &str { ... } fn delivery_hint(&self) -> Option<&str> { ... } fn keeps_backups(&self) -> bool { ... } fn backup_before_overwrite<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _backend: &'life1 Arc<dyn ExecutionBackend>, _path: &'life2 BackendPath, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn post_write_diagnostics<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _backend: &'life1 dyn ExecutionBackend, _path: &'life2 Path, ) -> Pin<Box<dyn Future<Output = String> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn write_effects( &self, _backend: &dyn ExecutionBackend, _arguments: &str, ) -> CallEffects { ... } fn plants_configuration(&self, _path: &str) -> bool { ... } fn refusal_hint(&self, _path: &Path) -> Option<String> { ... } fn is_persistence(&self, path: &Path) -> bool { ... }
}
Expand description

What an application decides about the file tools.

Required Methods§

Source

fn is_secret(&self, path: &Path) -> bool

Files read_file refuses because they hold secrets.

Source

fn is_secret_ignoring_name_shape(&self, path: &Path) -> bool

FilePolicy::is_secret without name-shape rules, for .env.example style templates, which are judged by where they live.

Source

fn is_sensitive(&self, path: &Path) -> bool

Paths the file tools must not change. ProtectedPathGuard enforces these three; add it to the agent.

Provided Methods§

Source

fn declare_path(&self, path: &str) -> String

The path a kernel access manifest declares for a path argument.

Source

fn attaches_images(&self) -> bool

Whether images are returned as attachments the caller can deliver.

Source

fn shell_tool_name(&self) -> &str

The tool named in hints that suggest running a command.

Source

fn delivery_hint(&self) -> Option<&str>

A sentence added after an append, on delivering the finished file.

Source

fn keeps_backups(&self) -> bool

Source

fn backup_before_overwrite<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _backend: &'life1 Arc<dyn ExecutionBackend>, _path: &'life2 BackendPath, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Keep a copy of path before it is replaced. Best effort: a failed backup never blocks the change.

Source

fn post_write_diagnostics<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _backend: &'life1 dyn ExecutionBackend, _path: &'life2 Path, ) -> Pin<Box<dyn Future<Output = String> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Text appended to a successful write, such as a syntax check.

Source

fn write_effects( &self, _backend: &dyn ExecutionBackend, _arguments: &str, ) -> CallEffects

The effects of a write call.

Source

fn plants_configuration(&self, _path: &str) -> bool

Whether writing path changes configuration that later commands run (git configuration, for example).

Source

fn refusal_hint(&self, _path: &Path) -> Option<String>

Where to go instead when the file tools refuse path: an app’s own files can have a tool of their own (its config tool, for example).

Source

fn is_persistence(&self, path: &Path) -> bool

Whether writing path plants something that runs or is obeyed later without anyone asking (a shell start-up file, a launch agent, a git hook, the app’s own instruction files): such a write always asks the owner.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§