Skip to main content

Engine

Struct Engine 

Source
pub struct Engine<P, R> {
Show 32 fields pub config: EngineConfig, pub ext: Option<Box<dyn EnginePlatformExt<P, R>>>, pub deepseek_client: Option<Arc<dyn LlmClient>>, pub deepseek_client_error: Option<String>, pub api_key_env_only_recovery: Option<String>, pub session: Session, pub shell: Box<dyn ShellHost>, pub rx_op: Receiver<Op>, pub tx_approval: Sender<ApprovalDecision<P>>, pub rx_approval: Receiver<ApprovalDecision<P>>, pub rx_user_input: Receiver<UserInputDecision<R>>, pub rx_steer: Receiver<String>, pub tx_event: Sender<Event>, pub cancel_token: CancellationToken, pub shared_cancel_token: Arc<Mutex<CancellationToken>>, pub tool_exec_lock: Arc<RwLock<()>>, pub capacity_controller: CapacityController, pub seam: Option<Box<dyn SeamHost>>, pub coherence_state: CoherenceState, pub turn_counter: u64, pub lsp: Arc<dyn LspHost>, pub workshop: Option<Box<dyn WorkshopHost>>, pub sandbox: Box<dyn SandboxHost>, pub pending_lsp_blocks: Vec<DiagnosticBlock>, pub scratchpad_step: ScratchpadStepState, pub scratchpad_run_id: Option<String>, pub scratchpad_summary_injected_this_turn: bool, pub scratchpad_audit_continue_injected_this_turn: bool, pub long_horizon_continue_injected_this_turn: bool, pub long_horizon_auto_continue_rounds: u32, pub topic_memory: Box<dyn TopicMemoryHost>, pub overflow_source_budget_cap: Option<u32>,
}
Expand description

The core engine that processes operations and emits events.

Fields§

§config: EngineConfig§ext: Option<Box<dyn EnginePlatformExt<P, R>>>

Tui-only extension config + concrete subsystem handles (type-erased). Wrapped in Option so the op loop can Option::take it during dispatch without aliasing &mut self.

§deepseek_client: Option<Arc<dyn LlmClient>>§deepseek_client_error: Option<String>§api_key_env_only_recovery: Option<String>§session: Session§shell: Box<dyn ShellHost>§rx_op: Receiver<Op>§tx_approval: Sender<ApprovalDecision<P>>§rx_approval: Receiver<ApprovalDecision<P>>§rx_user_input: Receiver<UserInputDecision<R>>§rx_steer: Receiver<String>§tx_event: Sender<Event>§cancel_token: CancellationToken§shared_cancel_token: Arc<Mutex<CancellationToken>>§tool_exec_lock: Arc<RwLock<()>>§capacity_controller: CapacityController§seam: Option<Box<dyn SeamHost>>§coherence_state: CoherenceState§turn_counter: u64§lsp: Arc<dyn LspHost>§workshop: Option<Box<dyn WorkshopHost>>§sandbox: Box<dyn SandboxHost>§pending_lsp_blocks: Vec<DiagnosticBlock>§scratchpad_step: ScratchpadStepState§scratchpad_run_id: Option<String>§scratchpad_summary_injected_this_turn: bool§scratchpad_audit_continue_injected_this_turn: bool

One-shot guard: inject incomplete-audit continue nudge before prose-only turn break.

§long_horizon_continue_injected_this_turn: bool

One-shot guard: inject LHT continue nudge before prose-only turn break.

§long_horizon_auto_continue_rounds: u32

“一推到底” (C2): auto-continue rounds consumed this turn — bounds the give-up override (long_horizon.max_auto_continue_rounds). Reset per user message alongside the other per-turn LHT guards.

§topic_memory: Box<dyn TopicMemoryHost>§overflow_source_budget_cap: Option<u32>

P2-D overflow recovery: source-only token budget cap set by try_budget_recompile when the compiler budget solver successfully evicts Volatile / shrinks SemiStatic sources to fit within the context window. On the next compiler_request_context call the compiler runs compile_with_budget_override(cap) instead of compile(), applying the eviction. Consumed (set back to None) immediately after use so it only applies for one request retry. Reset to None at turn start.

Implementations§

Source§

impl<P, R> Engine<P, R>
where P: Send + Sync + 'static, R: Send + Sync + 'static,

Source

pub async fn run(self)

Run the engine op loop until Op::Shutdown or channel close.

Source§

impl<P, R> Engine<P, R>
where P: Send + Sync + 'static, R: Send + Sync + 'static,

Source

pub fn with_hosts( config: EngineConfig, session: Session, hosts: EngineHostBundle<P, R>, ) -> (Self, EngineHandle<P, R>)

Construct an engine from lean config + tui-wired host bundle.

Creates the seven mpsc channel pairs core-side (spike R11) and returns (engine, handle) for the tui builder to spawn the loop.

Auto Trait Implementations§

§

impl<P, R> !RefUnwindSafe for Engine<P, R>

§

impl<P, R> !UnwindSafe for Engine<P, R>

§

impl<P, R> Freeze for Engine<P, R>

§

impl<P, R> Send for Engine<P, R>
where P: Send, R: Send,

§

impl<P, R> Sync for Engine<P, R>
where P: Send, R: Send,

§

impl<P, R> Unpin for Engine<P, R>

§

impl<P, R> UnsafeUnpin for Engine<P, R>

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.

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

Source§

type Output = T

Should always be 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.
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