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§
Source§impl MockRuntime
impl MockRuntime
pub fn into_runtime(self) -> Runtime
pub fn actions(&self) -> Vec<MockAction>
Trait Implementations§
Source§impl Actions for MockRuntime
impl Actions for MockRuntime
Source§fn terminate_session(&self, pid: u32) -> Result<(), String>
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>
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>
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>
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>
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>
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>
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
impl BrainReviewView for MockRuntime
Source§fn all_decisions(&self) -> Vec<DecisionSummary>
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>
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
impl BrainView for MockRuntime
fn gate_mode(&self) -> BrainGateMode
Source§fn recent_decisions(&self, n: usize) -> Vec<DecisionSummary>
fn recent_decisions(&self, n: usize) -> Vec<DecisionSummary>
Most recent
n decisions, newest first.Source§fn decision_count(&self) -> usize
fn decision_count(&self) -> usize
Total count of brain decisions on disk. Drives the “decisions: N”
status line.
Source§impl BusView for MockRuntime
impl BusView for MockRuntime
fn list_agents(&self) -> Vec<AgentDirectoryEntry>
fn list_roles(&self) -> Vec<RoleBinding>
Source§impl CoordView for MockRuntime
impl CoordView for MockRuntime
fn active_leases(&self) -> Vec<LeaseSummary>
fn pending_handoffs(&self) -> Vec<HandoffSummary>
fn pending_interrupts(&self) -> Vec<InterruptSummary>
Source§impl Default for MockRuntime
impl Default for MockRuntime
Source§fn default() -> MockRuntime
fn default() -> MockRuntime
Returns the “default value” for a type. Read more
Source§impl HiveActions for MockRuntime
impl HiveActions for MockRuntime
Semantic keys (
skill:<lowered-name>) of skills already shared into
the local hive store. Used by the Skills overlay to mark “already
shared” rows.Share a discovered skill into the local hive store. Returns the new
unit ID on success.
Source§fn hive_view_snapshot(&self) -> HiveViewSnapshot
fn hive_view_snapshot(&self) -> HiveViewSnapshot
Current view of the local relay identity + known peers for the Hive
tab.
Source§impl Orchestrator for MockRuntime
impl Orchestrator for MockRuntime
Source§fn deliver_mailbox(&self, _sessions: &[SessionSnapshot]) -> Vec<(u32, String)>
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)>
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)
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
impl SessionSource for MockRuntime
Source§fn list(&self) -> Vec<SessionSnapshot>
fn list(&self) -> Vec<SessionSnapshot>
Snapshot of every running Claude Code session. Order is the
implementor’s choice; the TUI sorts again client-side.
Auto Trait Implementations§
impl !Freeze for MockRuntime
impl RefUnwindSafe for MockRuntime
impl Send for MockRuntime
impl Sync for MockRuntime
impl Unpin for MockRuntime
impl UnsafeUnpin for MockRuntime
impl UnwindSafe for MockRuntime
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
Mutably borrows from an owned value. Read more
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>
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 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>
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