Skip to main content

SRBNOrchestrator

Struct SRBNOrchestrator 

Source
pub struct SRBNOrchestrator {
    pub graph: DiGraph<SRBNNode, Dependency>,
    pub context: AgentContext,
    pub auto_approve: bool,
    pub ledger: MerkleLedger,
    pub last_tool_failure: Option<String>,
    pub planning_policy: PlanningPolicy,
    pub stability_epsilon: f32,
    pub energy_alpha: f32,
    pub energy_beta: f32,
    pub energy_gamma: f32,
    /* private fields */
}
Expand description

The SRBN Orchestrator - manages the agent workflow

Fields§

§graph: DiGraph<SRBNNode, Dependency>

Task DAG managed by petgraph

§context: AgentContext

Agent context

§auto_approve: bool

Auto-approve mode

§ledger: MerkleLedger

Persistence ledger

§last_tool_failure: Option<String>

Last tool failure message (for energy calculation)

§planning_policy: PlanningPolicy

Adaptive planning policy for agent phase selection.

§stability_epsilon: f32

Session-level stability threshold (ε for V(x) < ε convergence)

§energy_alpha: f32

Energy weight α (syntax/build errors)

§energy_beta: f32

Energy weight β (structural concerns)

§energy_gamma: f32

Energy weight γ (test/lint failures)

Implementations§

Source§

impl SRBNOrchestrator

Source

pub fn parse_artifact_bundle_typed( &self, content: &str, node_id: &str, attempt: u32, ) -> (Option<ArtifactBundle>, ParseResultState, Option<CorrectionAttemptRecord>)

PSP-7: Typed parse pipeline returning structured state for every LLM response.

Replaces the Option-based parse_artifact_bundle with a pipeline that classifies every response through Layers A→E and returns a typed result.

  • Layer A: Raw capture — fingerprints the response (hash + length).
  • Layer B: Path normalization via the hardened normalize_artifact_path.
  • Layer C: Strict JSON parse via extract_and_deserialize.
  • Layer D: Tolerant file-marker recovery via extract_file_markers.
  • Layer E: Semantic validation — declared paths, plugin support files, command policy.

Returns (Option<ArtifactBundle>, ParseResultState, Option<CorrectionAttemptRecord>).

Source

pub async fn apply_bundle_transactionally( &mut self, bundle: &ArtifactBundle, node_id: &str, node_class: NodeClass, ) -> Result<()>

PSP-5: Apply an artifact bundle transactionally

All file operations are validated first, then applied. PSP-5 Phase 2: Validates ownership boundaries before applying. If any operation fails, the method returns an error describing which operation failed, and previous successful operations are logged for manual review.

Source§

impl SRBNOrchestrator

Source

pub async fn run_plugin_verification( &mut self, plugin_name: &str, allowed_stages: &[VerifierStage], working_dir: PathBuf, ) -> VerificationResult

PSP-5: Run plugin-driven verification for a node

Uses the active language plugin’s verifier profile to select commands for syntax check, build, test, and lint stages. Delegates execution to TestRunnerTrait implementations from test_runner.

Each stage records a StageOutcome with SensorStatus, enabling callers to detect fallback / unavailable sensors and block false stability claims.

Source§

impl SRBNOrchestrator

Source

pub fn new(working_dir: PathBuf, auto_approve: bool) -> Self

Create a new orchestrator with default models

Source

pub fn new_with_models( working_dir: PathBuf, auto_approve: bool, architect_model: Option<String>, actuator_model: Option<String>, verifier_model: Option<String>, speculator_model: Option<String>, architect_fallback_model: Option<String>, actuator_fallback_model: Option<String>, verifier_fallback_model: Option<String>, speculator_fallback_model: Option<String>, ) -> Self

Create a new orchestrator with custom model configuration

Source

pub fn add_node(&mut self, node: SRBNNode) -> NodeIndex

Add a node to the task DAG

Source

pub fn connect_tui( &mut self, event_sender: EventSender, action_receiver: ActionReceiver, )

Connect TUI channels for interactive control

Source

pub fn abort_flag(&self) -> Arc<AtomicBool>

Get a handle to the abort flag for external signal handlers.

Source

pub fn set_budget( &mut self, max_steps: Option<u32>, max_revisions: Option<u32>, max_cost_usd: Option<f64>, )

Configure the session-level budget envelope.

Call this before run() to set step, cost, or revision caps from CLI flags. Uncapped limits remain None.

Source

pub fn rehydrate_session(&mut self, session_id: &str) -> Result<SessionSnapshot>

Rehydrate the orchestrator from a persisted session, rebuilding the DAG from stored node snapshots and graph edges.

Terminal nodes (Completed, Failed, Aborted) will be skipped during the subsequent run_resumed() execution. Non-terminal nodes are placed back in their persisted state so the executor can continue from the last durable boundary.

Returns Ok(snapshot) with the loaded session snapshot on success, or an error when the session cannot be reconstructed.

Source

pub async fn run_resumed(&mut self) -> Result<()>

Resume execution from a rehydrated session.

Walks the DAG in topological order, skipping terminal nodes and executing any node whose state is not completed/failed/aborted. Emits a differential resume summary so users can see what will be replayed vs. skipped.

Source

pub fn add_dependency( &mut self, from_id: &str, to_id: &str, kind: &str, ) -> Result<()>

Add a dependency edge between nodes

Source

pub async fn run(&mut self, task: String) -> Result<()>

Run the complete SRBN control loop

Source

pub fn session_id(&self) -> &str

Get the current session ID

Source

pub fn node_count(&self) -> usize

Get node count

Source

pub async fn start_lsp_for_plugins( &mut self, plugin_names: &[&str], ) -> Result<()>

Start LSP clients for the given plugin names.

For each name, looks up the plugin’s LspConfig (with fallback) and starts a client keyed by the plugin name.

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: 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
§

impl<T> ToAst for T

§

fn ast(self, begin: usize, end: usize) -> Spanned<Self>

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

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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