Skip to main content

Policy

Struct Policy 

Source
pub struct Policy { /* private fields */ }
Expand description

The classifier for one project.

Implementations§

Source§

impl Policy

Source

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).

Source

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).

Source

pub fn check_prefixes(&self) -> &[Vec<String>]

The check-derived prefixes, for a coverage view.

Source

pub fn with_hidden(self, hidden: impl IntoIterator<Item = String>) -> Self

Paths git ignored when an in-place run started: the file tools refuse them, except the protected files (the intent stays readable).

Source

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.

Source

pub const fn autopilot(self) -> Self

An autopilot run: nothing asks (Policy::settle).

Source

pub const fn is_autopilot(&self) -> bool

Whether it is an autopilot run’s.

Source

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.

Source

pub fn authoring(self) -> Self

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.

Source

pub fn rules(self, rules: &'static Rules) -> Self

The project’s format’s rules (intent, planning artifacts); the reference format’s by default.

Source

pub fn with_network(self, exact: Vec<Vec<String>>) -> Self

[sandbox] network_allow: exact argvs that get the network.

Source

pub fn with_network_prefixes(self, prefixes: Vec<Vec<String>>) -> Self

[sandbox] network_allow_prefix: prefixes (two elements or more) that get the network.

Source

pub fn network_allowed(&self, argv: &[String]) -> bool

Whether argv gets the network without asking: an exact entry, or a prefix entry it extends.

Source

pub fn with_mcp(self, tools: impl IntoIterator<Item = (String, String)>) -> Self

The project’s MCP tools and their configured decisions.

Source

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.

Source

pub fn with_frozen(self, frozen: impl IntoIterator<Item = String>) -> Self

Freezes these test files: writing them needs approval.

Source

pub fn protected(&self) -> &Protected

The protected set this policy uses.

Source

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.

Source

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.

Source

pub fn approved(&self) -> &[Object]

The person’s rejections and approvals, for the changed-object line.

Source

pub fn rule(&self, tool: &str, args: &Value, object: Option<&Object>) -> String

The rule that decides tool with args when no person does: what a call’s record names, so a rule’s decision is never read as a person’s.

Source

pub fn base(&self, tool: &str, args: &Value) -> Decision

The decision by rule alone, before any person’s: what decides whether a call’s object is resolved and a person asked.

Trait Implementations§

Source§

impl Clone for Policy

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Policy

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Policy

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more