Skip to main content

MockRuntime

Struct MockRuntime 

Source
pub struct MockRuntime {
    pub sessions: Vec<SessionSnapshot>,
    pub gate_mode: Mutex<Option<BrainGateMode>>,
    pub decisions: Vec<DecisionSummary>,
    pub review_queue: Vec<ReviewItemSummary>,
    pub leases: Vec<LeaseSummary>,
    pub handoffs: Vec<HandoffSummary>,
    pub interrupts: Vec<InterruptSummary>,
    pub agents: Vec<AgentDirectoryEntry>,
    pub roles: Vec<RoleBinding>,
    pub actions_log: Mutex<Vec<MockAction>>,
}
Expand description

In-memory runtime backed by Vecs and interior-mutable counters. Used by tests in this crate to verify the trait shapes compile and roundtrip cleanly, and by the future claudectl-tui crate’s tests to render the TUI against fixtures without dragging in brain / coord / bus.

Actions impls record their calls in actions_log so tests can assert “the TUI invoked the right side-effect” without spying on real I/O.

Fields§

§sessions: Vec<SessionSnapshot>§gate_mode: Mutex<Option<BrainGateMode>>§decisions: Vec<DecisionSummary>§review_queue: Vec<ReviewItemSummary>§leases: Vec<LeaseSummary>§handoffs: Vec<HandoffSummary>§interrupts: Vec<InterruptSummary>§agents: Vec<AgentDirectoryEntry>§roles: Vec<RoleBinding>§actions_log: Mutex<Vec<MockAction>>

Implementations§

Trait Implementations§

Source§

impl Actions for MockRuntime

Source§

fn terminate_session(&self, pid: u32) -> Result<(), String>

Terminate the OS process with the given PID. The TUI uses this for “kill session” hotkeys.
Source§

fn inject_text(&self, session_id: &str, text: &str) -> Result<(), String>

Inject text into the session’s terminal. Implementations pick the right backend (tmux, Kitty, etc.) from the session metadata. Read more
Source§

fn set_gate_mode(&self, mode: BrainGateMode) -> Result<(), String>

Update the persisted brain gate mode. Reflected back through BrainView::gate_mode on the next call.
Source§

fn log_observation(&self, observation: ObservationInput) -> Result<(), String>

Record an observation about a user action — non-LLM “the user did X.” Drives the brain’s outcome telemetry and preference distillation.
Source§

fn log_decision(&self, input: LogDecisionInput) -> Result<(), String>

Record a user’s accept/reject decision on a brain suggestion. The distinction from log_observation is that log_decision carries the actual suggestion that was on screen — the brain pairs it with the user’s response for outcome telemetry, counterfactual analysis, and few-shot retrieval.
Source§

fn mark_canonical( &self, decision_id: &str, note: Option<String>, ) -> Result<(), String>

Mark a past brain decision as canonical for teaching. Optional note is the operator’s annotation. Used by the Brain Review surface.
Source§

fn bind_bus_role(&self, name: &str, cwd: &str, pid: u32) -> Result<(), String>

Bind an agent-bus role to a (cwd, pid) pair. The TUI calls this from the new role-bind key (Ctrl+R) so the operator can attach a role to a specific running Claude session without dropping to another terminal. Returns Err when the bus feature is compiled out or the DB write fails. See issue #307.
Source§

impl BrainReviewView for MockRuntime

Source§

fn all_decisions(&self) -> Vec<DecisionSummary>

Every decision on disk, newest first. Used by the Brain Review screen to render the full history list.
Source§

fn review_queue(&self) -> Vec<ReviewItemSummary>

Priority-ordered review queue. Built from all_decisions() plus the brain’s queue-building heuristics (counterfactual hits, Critical-tier safety cases, high-confidence misses).
Source§

impl BrainView for MockRuntime

Source§

fn gate_mode(&self) -> BrainGateMode

Source§

fn recent_decisions(&self, n: usize) -> Vec<DecisionSummary>

Most recent n decisions, newest first.
Source§

fn decision_count(&self) -> usize

Total count of brain decisions on disk. Drives the “decisions: N” status line.
Source§

impl BusView for MockRuntime

Source§

impl CoordView for MockRuntime

Source§

impl Default for MockRuntime

Source§

fn default() -> MockRuntime

Returns the “default value” for a type. Read more
Source§

impl HiveActions for MockRuntime

Source§

fn shared_skill_keys(&self) -> HashSet<String>

Semantic keys (skill:<lowered-name>) of skills already shared into the local hive store. Used by the Skills overlay to mark “already shared” rows.
Source§

fn share_skill(&self, _skill: &DiscoveredSkill) -> Result<String, String>

Share a discovered skill into the local hive store. Returns the new unit ID on success.
Source§

fn hive_view_snapshot(&self) -> HiveViewSnapshot

Current view of the local relay identity + known peers for the Hive tab.
Source§

impl Orchestrator for MockRuntime

Source§

fn deliver_mailbox(&self, _sessions: &[SessionSnapshot]) -> Vec<(u32, String)>

Drain pending mailbox messages addressed to running sessions and deliver them to the live terminals. Used by App::tick to surface "Brain → sess_X: 'go ahead'" style messages.
Source§

fn deliver_interrupts( &self, _sessions: &[SessionSnapshot], ) -> Vec<(String, String)>

Deliver pending coordination interrupts (cross-agent signals) to running sessions. Returns (interrupt_id, status_message) tuples.
Source§

fn expire_stale(&self)

Expire stale leases and interrupts that have passed their deadline. Bookkeeping side-effect; best-effort, no return. Implementations log failures rather than propagating them.
Source§

impl SessionSource for MockRuntime

Source§

fn list(&self) -> Vec<SessionSnapshot>

Snapshot of every running Claude Code session. Order is the implementor’s choice; the TUI sorts again client-side.
Source§

fn detail(&self, session_id: &str) -> Option<SessionSnapshot>

Fetch a specific session by its ID. None when the session has exited or never existed.

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.

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