From baefb01c38d711f5532c04798db041bb44b14bb8 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 31 Oct 2026 10:02:42 +0100 Subject: [PATCH] mind-body: clippy clean at -D warnings (poll iterates its rows, a identity map and the unused Recording::stop go) Co-Authored-By: Claude Sonnet 5.5 --- crates/mind-body/src/heartbeat.rs | 17 ++++++++--------- crates/mind-body/src/heartbeat/tests.rs | 2 +- crates/mind-body/src/testkit.rs | 5 ----- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/crates/mind-body/src/heartbeat.rs b/crates/mind-body/src/heartbeat.rs index a56acad..f44fb6d 100644 --- a/crates/mind-body/src/heartbeat.rs +++ b/crates/mind-body/src/heartbeat.rs @@ -596,13 +596,12 @@ pub fn poll(organs: &Organs, config: &Config) -> Result { // Off the beat: the operator naming her, once per message, and her Self run // having ended since her last turn. Neither waits for the beat; both need her // idle and released. - for index in 0..rows.len() { - if !rows[index].idle() { + for row in &mut rows { + if !row.idle() { continue; } - let slug = rows[index].slug().clone(); + let slug = row.slug().clone(); let mentioned = { - let row = &rows[index]; let mut pending: Vec<&ChatDelivery> = row.pending.iter().collect(); pending.sort_by_key(|delivery| delivery.seq); pending @@ -611,7 +610,7 @@ pub fn poll(organs: &Organs, config: &Config) -> Result { .map(|delivery| format!("{}:{}", slug.0, delivery.event_id)) .find(|key| !state.handled_mentions.contains(key)) }; - let self_ended = rows[index].read.as_ref().is_some_and(|read| match (read.self_end, read.last_turn) { + let self_ended = row.read.as_ref().is_some_and(|read| match (read.self_end, read.last_turn) { (Some(ended), Some(turn)) => ended > turn, (Some(_), None) => true, _ => false, @@ -619,19 +618,19 @@ pub fn poll(organs: &Organs, config: &Config) -> Result { if mentioned.is_none() && !self_ended { continue; } - match launch(organs, &rows[index])? { + match launch(organs, row)? { Launched::Run(label) => { if let Some(key) = mentioned { state.handled_mentions.push(key); let excess = state.handled_mentions.len().saturating_sub(MENTIONS_KEPT); state.handled_mentions.drain(..excess); } - rows[index].busy = true; + row.busy = true; launches.push(label); launched.push(slug); } - Launched::Busy => rows[index].busy = true, - Launched::Refused(why) => rows[index].note = why, + Launched::Busy => row.busy = true, + Launched::Refused(why) => row.note = why, } } diff --git a/crates/mind-body/src/heartbeat/tests.rs b/crates/mind-body/src/heartbeat/tests.rs index 6016c82..0172cac 100644 --- a/crates/mind-body/src/heartbeat/tests.rs +++ b/crates/mind-body/src/heartbeat/tests.rs @@ -589,7 +589,7 @@ fn an_old_heartbeat_store_fails_closed_naming_the_file_and_is_never_migrated() { cache.pull_all_backing_stores().unwrap(); cache.put("eureka", &OldInitiative { initiative: "3.5".into() }).unwrap(); let store = FileStore::new(&path); - for result in [store.check().map(|()| ()), store.load().map(|_| ()), store.latest().map(|_| ()), store.save(&HeartbeatState { last_beat_at: crate::testkit::at(1), handled_mentions: vec![] }), store.record(&trace_at(1, 900))] { + for result in [store.check(), store.load().map(|_| ()), store.latest().map(|_| ()), store.save(&HeartbeatState { last_beat_at: crate::testkit::at(1), handled_mentions: vec![] }), store.record(&trace_at(1, 900))] { let error = format!("{:#}", result.unwrap_err()); assert!(error.contains(&path.display().to_string()) && error.contains("archive it, nothing migrates it"), "{error}"); } diff --git a/crates/mind-body/src/testkit.rs b/crates/mind-body/src/testkit.rs index 5017f7f..de13722 100644 --- a/crates/mind-body/src/testkit.rs +++ b/crates/mind-body/src/testkit.rs @@ -55,11 +55,6 @@ impl Recording { self.running.borrow_mut().retain(|unit| *unit != (Slug(INSTANCE.into()), turn)); } - /// One named instance's unit ends. - pub(crate) fn stop(&self, instance: &Slug, turn: RunTurn) { - self.running.borrow_mut().retain(|unit| *unit != (instance.clone(), turn)); - } - pub(crate) fn revive(&self, turn: RunTurn) { self.running.borrow_mut().push((Slug(INSTANCE.into()), turn)); }