pub struct MockRuntime {Show 14 fields
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 tasks: Vec<TaskSummary>,
pub agents: Vec<AgentDirectoryEntry>,
pub roles: Vec<RoleBinding>,
pub peers: Vec<(String, Option<String>)>,
pub discovered: Vec<DiscoveredMachine>,
pub discovery_unavailable: bool,
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>§tasks: Vec<TaskSummary>§agents: Vec<AgentDirectoryEntry>§roles: Vec<RoleBinding>§peers: Vec<(String, Option<String>)>Paired peers hive_view_snapshot reports, so a test can exercise the
peer picker without a relay on the machine running the suite.
discovered: Vec<DiscoveredMachine>Machines start_discovery reports, so a test can drive the Hive tab’s
nearby listing without a network.
When set, start_discovery answers None, the way a build without
the relay feature does, so the tab’s “cannot listen” path has a test.
actions_log: Mutex<Vec<MockAction>>Implementations§
Source§impl MockRuntime
impl MockRuntime
pub fn into_runtime(self) -> Runtime
Like into_runtime, but hands back the Arc as well so a test can
read actions() after the TUI has driven the runtime. into_runtime
alone moves the mock out of reach.
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>
Source§fn inject_text(&self, session_id: &str, text: &str) -> Result<(), String>
fn inject_text(&self, session_id: &str, text: &str) -> Result<(), String>
Source§fn set_gate_mode(&self, mode: BrainGateMode) -> Result<(), String>
fn set_gate_mode(&self, mode: BrainGateMode) -> Result<(), String>
BrainView::gate_mode on the next call.Source§fn log_observation(&self, observation: ObservationInput) -> Result<(), String>
fn log_observation(&self, observation: ObservationInput) -> Result<(), String>
Source§fn log_decision(&self, input: LogDecisionInput) -> Result<(), String>
fn log_decision(&self, input: LogDecisionInput) -> Result<(), String>
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>
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>
(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§fn cancel_task(&self, task_id: &str) -> Result<(), String>
fn cancel_task(&self, task_id: &str) -> Result<(), String>
Err when the coord feature is compiled
out, the task is already terminal, or the store write fails.Source§fn set_supervisor_drain(&self, draining: bool) -> Result<(), String>
fn set_supervisor_drain(&self, draining: bool) -> Result<(), String>
Err when the coord feature is compiled out.Source§fn retry_task(&self, task_id: &str) -> Result<(), String>
fn retry_task(&self, task_id: &str) -> Result<(), String>
Err for a DONE task (nothing to retry), a
still-active task, or when the coord feature is compiled out.Source§fn approve_task(&self, task_id: &str) -> Result<(), String>
fn approve_task(&self, task_id: &str) -> Result<(), String>
Err when the task isn’t in
NEEDS_HUMAN, or the coord feature is compiled out.Source§fn send_session_to_peer(
&self,
session_id: &str,
transcript: Option<&Path>,
cwd: &str,
peer: &str,
) -> Result<String, String>
fn send_session_to_peer( &self, session_id: &str, transcript: Option<&Path>, cwd: &str, peer: &str, ) -> Result<String, String>
transcript is the
path session discovery already resolved, which is more reliable than
re-deriving it from cwd and the id. Read moreSource§impl BrainReviewView for MockRuntime
impl BrainReviewView for MockRuntime
Source§fn all_decisions(&self) -> Vec<DecisionSummary>
fn all_decisions(&self) -> Vec<DecisionSummary>
Source§fn review_queue(&self) -> Vec<ReviewItemSummary>
fn review_queue(&self) -> Vec<ReviewItemSummary>
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>
n decisions, newest first.Source§fn decision_count(&self) -> usize
fn decision_count(&self) -> usize
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§fn tasks(&self) -> Vec<TaskSummary>
fn tasks(&self) -> Vec<TaskSummary>
coord feature
is off so the TUI can render a “no supervisor” state without cfg.Source§impl Default for MockRuntime
impl Default for MockRuntime
Source§impl HiveActions for MockRuntime
impl HiveActions for MockRuntime
skill:<lowered-name>) of skills already shared into
the local hive store. Used by the Skills overlay to mark “already
shared” rows.Source§fn hive_view_snapshot(&self) -> HiveViewSnapshot
fn hive_view_snapshot(&self) -> HiveViewSnapshot
Source§fn start_discovery(&self) -> Option<Box<dyn DiscoveryListener>>
fn start_discovery(&self) -> Option<Box<dyn DiscoveryListener>>
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)>
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)>
(interrupt_id, status_message) tuples.Source§fn expire_stale(&self, _live_session_ids: &[String])
fn expire_stale(&self, _live_session_ids: &[String])
Source§impl SessionSource for MockRuntime
impl SessionSource for MockRuntime
Source§fn list(&self) -> Vec<SessionSnapshot>
fn list(&self) -> Vec<SessionSnapshot>
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
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