mind-body: public surface snapshot for self_run and the shared parser; clippy fixes

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-22 17:46:13 +02:00
commit d9afb7439b
3 changed files with 34 additions and 7 deletions

View file

@ -229,12 +229,11 @@ pub fn carry(mind: &dyn MindPort, clock: &dyn Clock, spawner: &dyn Spawner, out:
};
match child.next_line(wait) {
Read::Line(line) => match read_usage(&line) {
Usage::Request { id, prefix: newest } => {
if seen.insert(id) {
requests += 1;
prefix = newest;
writeln!(out, "request {requests} prefix {prefix}")?;
}
// A message id seen before is the same request again (F24).
Usage::Request { id, prefix: newest } if seen.insert(id.clone()) => {
requests += 1;
prefix = newest;
writeln!(out, "request {requests} prefix {prefix}")?;
}
Usage::Result if !result_seen => {
result_seen = true;

View file

@ -252,6 +252,8 @@ fn go(steps: Vec<Step>) -> Ran {
carry_with(&Seen::of(&mind), steps, Some(0), false)
}
type Seed = Box<dyn Fn(&TestMind)>;
fn flushes(ran: &Ran) -> usize {
ran.written().iter().filter(|text| text.as_str() == FLUSH_MESSAGE).count()
}
@ -260,7 +262,7 @@ fn flushes(ran: &Ran) -> usize {
#[test]
fn without_exactly_one_open_self_run_of_hers_it_is_no_run_and_no_child_is_spawned() {
let cases: Vec<(&str, Box<dyn Fn(&TestMind)>)> = vec![
let cases: Vec<(&str, Seed)> = vec![
("no run at all", Box::new(|_| {})),
("a Self run the operator operates", Box::new(|mind| mind.committed(vec![run("op", RunTurn::SelfRun, RunOperator::Operator, &[])]))),
("her Persona turn", Box::new(|mind| mind.committed(vec![run("persona", RunTurn::PersonaTurn, RunOperator::Mind, &[])]))),

View file

@ -2,7 +2,9 @@ mind_body: mod cli
mind_body: mod control
mind_body: mod launch
mind_body: mod queue
mind_body: mod self_run
mind_body: mod wake
mind_body::cli: fn instance_and_endpoint (args : & [String] , env_endpoint : Option < String > , usage : & str) -> Result < (Slug , SocketAddr) >
mind_body::cli: fn operator_name (sudo_user : Option < String > , user : Option < String >) -> String
mind_body::cli: fn run (args : & [String] , root : & Path , set_by : & str , now : DateTime < Utc > , out : & mut impl Write , stop_units : & mut dyn FnMut (& Slug) -> Result < () > ,) -> Result < () >
mind_body::control: # [derive (Clone , Copy , Debug , PartialEq , Eq)] pub enum HeldReason { BrakeAbsent , BrakeHeld , DialAbsent , DialOutOfBounds , Undecodable , }
@ -71,6 +73,30 @@ mind_body::queue: impl MindPort for HuginnMind < '_ >
mind_body::queue: impl< 'a > HuginnMind < 'a >
mind_body::queue: pub trait MindPort { fn instance (& self) -> & Slug ; fn query (& self , selection : & Selection) -> Result < PipelineSelectionPage > ; fn admit (& self , agent : & str , session : & str , documents : Vec < PipelineDocument >) -> Result < PipelineAdmissionOutcome > ; }
mind_body::queue: struct HuginnMind< 'a > pub-fields[]
mind_body::self_run: # [derive (Clone , Copy , Debug , PartialEq , Eq)] pub enum Cause { Own , Flushed , Interrupted , }
mind_body::self_run: # [derive (Clone , Debug , PartialEq , Eq)] pub enum Read { Line (String) , Timeout , Closed , }
mind_body::self_run: # [derive (Clone , Debug , PartialEq , Eq)] pub enum SelfRunOutcome { NoRun , Ended { cause : Cause , code : Option < i32 > , requests : u64 , prefix : u64 } , }
mind_body::self_run: # [derive (Clone , Debug , PartialEq , Eq)] pub enum Usage { Request { id : String , prefix : u64 } , Result , Other , Unreadable , }
mind_body::self_run: const AGENT : & str
mind_body::self_run: const CEILING_TOKENS : u64
mind_body::self_run: const FLUSH_ALLOWANCE_TOKENS : u64
mind_body::self_run: const FLUSH_GRACE_S : i64
mind_body::self_run: const FLUSH_MESSAGE : & str
mind_body::self_run: const MAX_TURNS : u32
mind_body::self_run: const SESSION_NAMESPACE : Uuid
mind_body::self_run: fn carry (mind : & dyn MindPort , clock : & dyn Clock , spawner : & dyn Spawner , out : & mut dyn Write) -> Result < SelfRunOutcome >
mind_body::self_run: fn claude_args (session : Uuid , budget_usd : & str) -> Vec < String >
mind_body::self_run: fn read_usage (line : & str) -> Usage
mind_body::self_run: fn session_id (run : & PipelineRef) -> Uuid
mind_body::self_run: fn start_message (instance : & Slug , run : & PipelineRef) -> String
mind_body::self_run: impl Child for ClaudeProcess
mind_body::self_run: impl SelfRunOutcome
mind_body::self_run: impl SelfRunOutcome: fn exit_status (& self) -> i32
mind_body::self_run: impl Spawner for ClaudeSpawner
mind_body::self_run: impl fmt :: Display for SelfRunOutcome
mind_body::self_run: pub trait Child { fn write_line (& mut self , line : & str) ; fn close_input (& mut self) ; fn next_line (& mut self , timeout : StdDuration) -> Read ; fn interrupt (& mut self) ; fn wait (& mut self) -> Option < i32 > ; }
mind_body::self_run: pub trait Spawner { fn spawn (& self , args : & [String]) -> Result < Box < dyn Child > > ; }
mind_body::self_run: struct ClaudeSpawner pub-fields[]
mind_body::wake: # [derive (Clone , Debug , PartialEq , Eq)] pub enum WakeOutcome { Held { reason : HeldReason } , NotYet { until : DateTime < Utc > } , Busy { run : PipelineRef } , Launched { run : PipelineRef } , Refused (Declined) , }
mind_body::wake: const AGENT : & str
mind_body::wake: fn cycle (ports : & Ports , control : & impl ControlSource) -> Result < WakeOutcome >