Skip to main content

Mechanism

Enum Mechanism 

Source
pub enum Mechanism {
    Env(&'static str),
    EnvFile(&'static str),
    FlagDir(ConflictOption),
    FlagFile(ConflictOption),
}
Expand description

How an adapter points its agent at the profile: the cross product of {variable, flag} x {directory, file}. This is the complete, closed set — it is the same vocabulary the probe harness speaks (sandbox/probes/common.sh, env: / envfile: / flagdir: / flagfile:), so a fifth variant here would be a mechanism no probe can exercise.

§Three renderings, one per consumer — do not collapse them

  1. std::fmt::Display — the path-free sentence, for error messages. An error message cannot name a path, because check_conflicts refuses an argument before any plan exists and therefore before any path has been chosen. It prints the placeholder <dir> / <file> instead.
  2. Mechanism::sentence_for — the concrete sentence that becomes PlannedLaunch::mechanism, for the launch report. A report line should name the exact path it is about to create, so here the placeholder is the real path.
  3. Mechanism::probe_token — the machine identifier the evidence pipeline consumes. The human text above may be reworded freely; this token may not.

That (1) and (2) differ in form for flag mechanisms is deliberate, not drift: they answer different questions at different times. For environment mechanisms they coincide, because there is no path in the sentence to differ over.

All three are generated from this one value, and so is the launch itself: Mechanism::plan (crate internal, so not linked here — a public doc comment cannot link a private item) dispatches on the variant and takes the variable name or flag spelling out of the variant’s own payload. An adapter passes no name and no flag, so there is no second string for the first to drift from.

Variants§

§

Env(&'static str)

A variable set to the profile directory.

§

EnvFile(&'static str)

A variable set to a file inside the profile directory.

§

FlagDir(ConflictOption)

An option passed the profile directory.

§

FlagFile(ConflictOption)

An option passed a file inside the profile directory.

Implementations§

Source§

impl Mechanism

Source

pub fn conflict_option(&self) -> Option<&ConflictOption>

The option this mechanism itself occupies, if it is a flag. check_conflicts scans it alongside the adapter’s declared extra conflicts, so an adapter cannot accept a flag it uses itself.

Source

pub fn sentence_for(&self, target: &Path) -> String

The report sentence naming target, the path this mechanism points at. Environment mechanisms name the variable and ignore target.

Source

pub fn probe_token(&self) -> String

The evidence pipeline’s identifier, e.g. env:CODEX_HOME or flagfile:--config.

Source§

impl Mechanism

Source

pub(crate) fn plan( &self, adapter: &dyn Adapter, ctx: &PlanContext<'_>, ) -> Result<PlannedLaunch>

Plans a launch that points the agent at its profile through this mechanism.

The variable name and the flag spelling are read out of the mechanism’s own payload, and the report sentence comes from Mechanism::sentence_for on the very same value. There is no parameter through which an adapter could pass a second name, so declaring Env("A") and launching with "B" is not expressible — the two used to be separate arguments and agreed only because every adapter happened to pass the same constant twice.

It lives here rather than in metadata because planning needs this module’s private machinery — executable discovery, the case-twin check and path materialization state.

Adapter-specific extras stay in the adapter: plan() returns no notes, and an adapter that has one (Codex’s logged-out note, Aider’s layering note) pushes it onto the result.

Trait Implementations§

Source§

impl Clone for Mechanism

Source§

fn clone(&self) -> Mechanism

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 Copy for Mechanism

Source§

impl Debug for Mechanism

Source§

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

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

impl Display for Mechanism

Source§

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

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

impl Eq for Mechanism

Source§

impl PartialEq for Mechanism

Source§

fn eq(&self, other: &Mechanism) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Mechanism

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

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.