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§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: boolOne-shot guard: inject incomplete-audit continue nudge before prose-only turn break.
long_horizon_continue_injected_this_turn: boolOne-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>
impl<P, R> Engine<P, R>
Sourcepub async fn run(self)
pub async fn run(self)
Run the engine op loop until Op::Shutdown or channel close.
Source§impl<P, R> Engine<P, R>
impl<P, R> Engine<P, R>
Sourcepub fn with_hosts(
config: EngineConfig,
session: Session,
hosts: EngineHostBundle<P, R>,
) -> (Self, EngineHandle<P, R>)
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.