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 tasks: Vec<TaskSummary>,
pub agents: Vec<AgentDirectoryEntry>,
pub roles: Vec<RoleBinding>,
pub peers: Vec<(String, Option<String>)>,
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.
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>
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§fn cancel_task(&self, task_id: &str) -> Result<(), String>
fn cancel_task(&self, task_id: &str) -> Result<(), String>
Cancel a supervisor task (move it to CANCELLED). Used by the Supervisor
panel’s one-key cancel (#368).
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>
Set or clear the supervisor drain marker. When draining, the reconciler
stops issuing new task assignments while letting running tasks finish.
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>
Re-queue a failed/cancelled task (move it back to PENDING so the
reconciler re-assigns it).
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>
Approve a NEEDS_HUMAN task — accept the work as-is and move it to DONE,
overriding the verifier that escalated it.
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>
Move a conversation to a paired peer, so it can be resumed there
(#510). The TUI calls this from the send hotkey;
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>
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§fn tasks(&self) -> Vec<TaskSummary>
fn tasks(&self) -> Vec<TaskSummary>
Supervisor task lifecycles, newest first. Empty when the
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
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, _live_session_ids: &[String])
fn expire_stale(&self, _live_session_ids: &[String])
Expire stale leases and interrupts that have passed their deadline.
Bookkeeping side-effect; best-effort, no return. Implementations
log failures rather than propagating them. Read more
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