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 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 approved(&self) -> &[Object]
pub fn approved(&self) -> &[Object]
The person’s rejections and approvals, for the changed-object line.