Skip to main content

Factory

Struct Factory 

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

A running factory.

Implementations§

Source§

impl Factory

Source

pub fn new(config: Config, root: impl Into<PathBuf>) -> Result<Self>

Opens a factory rooted at root, which is where .layover/ lives.

§Errors

Returns an error when the state directory cannot be created.

Source

pub fn serving_mcp(self, endpoint: impl Into<String>) -> Self

Tells runs where Layover’s MCP endpoint is, so they can call back into it.

Without this a run is a one-shot: it reads its instructions, does the work and ends, and no chain can be longer than the flight that started it. With it, layover_send reaches a real queue and the route map means something at runtime rather than only at load.

Source

pub fn tokens(&self) -> Arc<Tokens>

The token registry, which the MCP endpoint resolves callers against.

Source

pub const fn graph(&self) -> &RouteGraph

The route map this factory is enforcing.

Source

pub const fn config(&self) -> &Config

The factory definition this is running.

Source

pub fn ground_stop_engaged(&self) -> bool

Whether a Ground Stop is engaged.

Read from disk on every check rather than cached: a kill switch whose state is a snapshot taken at startup is a kill switch that does not work while the thing is running.

Source

pub fn run_flight( &self, itinerary: &mut Itinerary, sender: Option<&AgentName>, flight: &Flight, ) -> Dispatched

Runs one flight to completion, recording what happened.

sender is None for a human trigger.

§Errors

Never returns Err; a failure is reported as Dispatched::Failed so that one bad flight cannot stop a factory draining the rest of its queue.

Source

pub fn history_dir(&self) -> PathBuf

Where history is written.

Source

pub fn drain( &self, pending: Vec<Queued>, unqueue: impl FnMut(&Flight), report: impl FnMut(&Flight, &Dispatched), ) -> Drained

Runs every flight waiting in pending, and every flight those runs send, until nothing is left.

Each is taken off the queue before it runs. A flight that crashes the factory mid-run must not come back on restart and run again: an agent that opened a pull request and was interrupted before its outcome was recorded would open a second one.

§Why this loops rather than iterating once

A run can send flights while it is running. Draining the list it started with would leave those sitting until something else picked them up, which turns every chain into one hop per invocation. refill is asked for whatever is queued now, after each pass.

The loop is bounded by the rails rather than by a count: each flight spends a Hop from a shared itinerary and each run spends Fuel and a slot against the run cap, so a chain that will not settle is cut by the same mechanism that bounds every other chain.

It also stops as soon as a whole pass starts nothing. Only a run can send a flight, so a pass in which every flight was refused cannot have produced new work, and asking for more would spin against a queue the rails have already closed.

Source

pub fn drain_with( &self, pending: Vec<Queued>, unqueue: &mut impl FnMut(&Flight), report: &mut impl FnMut(&Flight, &Dispatched), refill: impl FnMut(&[Flight]) -> Vec<Queued>, ) -> Drained

Drains, asking refill for newly queued work after each pass.

Source

pub fn root(&self) -> &Path

Where the factory’s root is.

Source

pub fn env_for(&self, agent: &AgentName) -> BTreeMap<String, String>

Variables the factory would pass to agent, for reporting rather than for spawning.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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