pub struct BrainEngine {
pub pending: HashMap<u32, BrainSuggestion>,
/* private fields */
}Expand description
The brain inference engine. Manages async inference threads and collects results.
Fields§
§pending: HashMap<u32, BrainSuggestion>Pending suggestions waiting for user confirmation (advisory mode).
Implementations§
Source§impl BrainEngine
impl BrainEngine
pub fn new(config: BrainConfig) -> Self
Sourcepub fn tick(
&mut self,
sessions: &[ClaudeSession],
deny_rules: &[AutoRule],
) -> Vec<(u32, String)>
pub fn tick( &mut self, sessions: &[ClaudeSession], deny_rules: &[AutoRule], ) -> Vec<(u32, String)>
Run one tick of the brain engine. Call this from app.tick() after refresh().
- Collect results from completed inference threads
- Spawn new inference threads for eligible sessions
Returns a list of (pid, status_message) for actions taken this tick.
Sourcepub fn accept(&mut self, pid: u32, session: &ClaudeSession) -> Option<String>
pub fn accept(&mut self, pid: u32, session: &ClaudeSession) -> Option<String>
Accept a pending brain suggestion (user pressed ‘b’).
Sourcepub fn reject(&mut self, pid: u32) -> Option<BrainSuggestion>
pub fn reject(&mut self, pid: u32) -> Option<BrainSuggestion>
Reject a pending brain suggestion (user pressed ‘B’).
Sourcepub fn maybe_restart_saturated(
&mut self,
sessions: &[ClaudeSession],
lifecycle: &LifecycleConfig,
is_idle: bool,
) -> Vec<(u32, String)>
pub fn maybe_restart_saturated( &mut self, sessions: &[ClaudeSession], lifecycle: &LifecycleConfig, is_idle: bool, ) -> Vec<(u32, String)>
Check for sessions with saturated context and auto-restart them. Saves a checkpoint and spawns a fresh session with the summary as prompt.
Sourcepub fn cleanup(&mut self, sessions: &[ClaudeSession])
pub fn cleanup(&mut self, sessions: &[ClaudeSession])
Clear pending suggestions for PIDs that are no longer in NeedsInput/WaitingInput.
Sourcepub fn maybe_orchestrate(
&mut self,
sessions: &[ClaudeSession],
) -> Vec<(u32, String)>
pub fn maybe_orchestrate( &mut self, sessions: &[ClaudeSession], ) -> Vec<(u32, String)>
Run orchestration evaluation: ask the brain if any cross-session actions should be taken (spawn, route, terminate). Runs less frequently than per-session advisory (every orchestrate_interval_secs).
Sourcepub fn handle_orchestration_result(
&mut self,
suggestion: &BrainSuggestion,
sessions: &[ClaudeSession],
) -> Vec<(u32, String)>
pub fn handle_orchestration_result( &mut self, suggestion: &BrainSuggestion, sessions: &[ClaudeSession], ) -> Vec<(u32, String)>
Check if a result is an orchestration response (pid == 0).
Auto Trait Implementations§
impl Freeze for BrainEngine
impl RefUnwindSafe for BrainEngine
impl Send for BrainEngine
impl !Sync for BrainEngine
impl Unpin for BrainEngine
impl UnsafeUnpin for BrainEngine
impl UnwindSafe for BrainEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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