pub struct Policy { /* private fields */ }Expand description
The classifier for one project.
Implementations§
Source§impl Policy
impl Policy
Sourcepub fn new(checks: &[Vec<String>], exact: &[Vec<String>]) -> Self
pub fn new(checks: &[Vec<String>], exact: &[Vec<String>]) -> Self
A policy allowing the command prefixes of checks (program and
subcommands, up to the first option) and exactly the argvs of
exact ([commands] allow).
Sourcepub fn with_prefixes(self, prefixes: Vec<Vec<String>>) -> Self
pub fn with_prefixes(self, prefixes: Vec<Vec<String>>) -> Self
[commands] allow_prefix: prefixes of two elements or more (a
shorter one is dropped; the configuration refuses it).
Sourcepub fn check_prefixes(&self) -> &[Vec<String>]
pub fn check_prefixes(&self) -> &[Vec<String>]
The check-derived prefixes, for a coverage view.
Paths git ignored when an in-place run started: the file tools refuse them, except the protected files (the intent stays readable).
Sourcepub fn in_place(self) -> Self
pub fn in_place(self) -> Self
An in-place attempt (run --in-place): the checkout is the
person’s, so git commands that move it are denied.
Sourcepub const fn autopilot(self) -> Self
pub const fn autopilot(self) -> Self
An autopilot run: nothing asks (Policy::settle).
Sourcepub const fn is_autopilot(&self) -> bool
pub const fn is_autopilot(&self) -> bool
Whether it is an autopilot run’s.
Sourcepub fn settle(&self, decision: Decision) -> Decision
pub fn settle(&self, decision: Decision) -> Decision
What a decision comes to once every grant had its say: on
autopilot a call that would still ask a person is refused for the
run (AUTOPILOT_DENIED); every other decision stands — a denial,
a rejection or a protected path is never lifted.
The planning profile: the format’s artifacts and scripts are the work; its machinery, verification inputs and secrets stay denied; anything else — source code included — needs approval.
Sourcepub fn planning(self, dir: &str) -> Self
pub fn planning(self, dir: &str) -> Self
A planning task’s profile: writes inside the unit’s directory
dir (worktree-relative) are its work, except the format’s judged
files (crate::format::Rules::judged), a credential and the
person’s review; everything else is as the policy says.
Sourcepub fn is_planning_write(&self, rel: &str) -> bool
pub fn is_planning_write(&self, rel: &str) -> bool
Whether rel (resolved, worktree-relative) is a planning task’s
to write: a design document inside its unit’s directory
(Protected::is_design_doc), not judged by the format.
Sourcepub fn rules(self, rules: &'static Rules) -> Self
pub fn rules(self, rules: &'static Rules) -> Self
The project’s format’s rules (intent, planning artifacts); the reference format’s by default.
Sourcepub fn with_network(self, exact: Vec<Vec<String>>) -> Self
pub fn with_network(self, exact: Vec<Vec<String>>) -> Self
[sandbox] network_allow: exact argvs that get the network.
Sourcepub fn with_network_prefixes(self, prefixes: Vec<Vec<String>>) -> Self
pub fn with_network_prefixes(self, prefixes: Vec<Vec<String>>) -> Self
[sandbox] network_allow_prefix: prefixes (two elements or more)
that get the network.
Sourcepub fn network_allowed(&self, argv: &[String]) -> bool
pub fn network_allowed(&self, argv: &[String]) -> bool
Whether argv gets the network without asking: an exact entry, or a
prefix entry it extends.
Sourcepub fn with_mcp(self, tools: impl IntoIterator<Item = (String, String)>) -> Self
pub fn with_mcp(self, tools: impl IntoIterator<Item = (String, String)>) -> Self
The project’s MCP tools and their configured decisions.
Sourcepub fn with_decisions(
self,
approved: Vec<Object>,
rejected: Vec<Rejection>,
) -> Self
pub fn with_decisions( self, approved: Vec<Object>, rejected: Vec<Rejection>, ) -> Self
A person’s decisions for this task: an approval turns a call that needs approval into an allowed one (never a denied one); a rejection turns it into a denial with the person’s reason.
Sourcepub fn with_frozen(self, frozen: impl IntoIterator<Item = String>) -> Self
pub fn with_frozen(self, frozen: impl IntoIterator<Item = String>) -> Self
Freezes these test files: writing them needs approval.
Sourcepub fn write_protected(&self, rel: &str) -> Option<Class>
pub fn write_protected(&self, rel: &str) -> Option<Class>
Whether this (resolved, workspace-relative) path is protected for writing under this policy: the authoring profile writes the format’s artifacts, nothing else of the protected set.
Sourcepub fn classify(
&self,
tool: &str,
args: &Value,
object: Option<&Object>,
) -> Decision
pub fn classify( &self, tool: &str, args: &Value, object: Option<&Object>, ) -> Decision
Classifies tool called with args. A person’s decision applies
only to the call’s resolved object (none: the request alone was
seen, and nobody’s decision covers it): a rejection of that very
object denies it, an approval of it allows it, never a denial.
Sourcepub fn rejection(&self, object: &Object) -> Option<&Rejection>
pub fn rejection(&self, object: &Object) -> Option<&Rejection>
A person’s rejection of exactly object, if one holds.
Sourcepub fn approved(&self) -> &[Object]
pub fn approved(&self) -> &[Object]
The person’s rejections and approvals, for the changed-object line.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Policy
impl RefUnwindSafe for Policy
impl Send for Policy
impl Sync for Policy
impl Unpin for Policy
impl UnsafeUnpin for Policy
impl UnwindSafe for Policy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more