From 8aca67c97cfd65126756576b9f609d61f12889e4 Mon Sep 17 00:00:00 2001 From: Hare Date: Fri, 22 May 2026 22:03:27 +0900 Subject: [PATCH] style: run cargo fmt --- crates/pod/src/controller.rs | 4 +-- crates/pod/src/interrupt_prep.rs | 2 +- crates/pod/src/ipc/notify_buffer.rs | 4 ++- crates/pod/src/pod.rs | 15 +++------ crates/pod/src/segment_log_sink.rs | 4 +-- crates/pod/tests/compact_events_test.rs | 5 ++- crates/pod/tests/controller_test.rs | 36 ++++++++++++--------- crates/pod/tests/restore_test.rs | 22 +++++++++---- crates/session-store/src/fs_store.rs | 5 ++- crates/session-store/src/lib.rs | 2 +- crates/session-store/src/segment.rs | 2 +- crates/session-store/tests/fs_store_test.rs | 24 ++++++++++---- crates/session-store/tests/session_test.rs | 17 ++++++++-- crates/tui/src/app.rs | 4 +-- crates/tui/src/picker.rs | 10 +++--- 15 files changed, 94 insertions(+), 62 deletions(-) diff --git a/crates/pod/src/controller.rs b/crates/pod/src/controller.rs index 6841f133..f2935650 100644 --- a/crates/pod/src/controller.rs +++ b/crates/pod/src/controller.rs @@ -639,9 +639,7 @@ async fn controller_loop( // sees the buffered notification(s) without a human // Run. if shared_state.get_status() == PodStatus::Idle { - pending = Some(PendingRun::RunForNotification( - protocol::InvokeKind::Notify, - )); + pending = Some(PendingRun::RunForNotification(protocol::InvokeKind::Notify)); } } diff --git a/crates/pod/src/interrupt_prep.rs b/crates/pod/src/interrupt_prep.rs index 226be8a4..2c240edc 100644 --- a/crates/pod/src/interrupt_prep.rs +++ b/crates/pod/src/interrupt_prep.rs @@ -11,9 +11,9 @@ //! happen at the front of `Pod::run` when //! `worker.last_run_interrupted()` is set; see `Pod::apply_interrupt_prep`. -use llm_worker::Item; #[cfg(test)] use crate::prompt::catalog::PromptCatalog; +use llm_worker::Item; /// Build synthetic `Item::ToolResult` items for every unanswered /// `Item::ToolCall` in `history`, preserving order. diff --git a/crates/pod/src/ipc/notify_buffer.rs b/crates/pod/src/ipc/notify_buffer.rs index 488afa6b..9745b17a 100644 --- a/crates/pod/src/ipc/notify_buffer.rs +++ b/crates/pod/src/ipc/notify_buffer.rs @@ -185,7 +185,9 @@ mod tests { let item = build_system_item(&entry, &catalog).unwrap(); match item { SystemItem::PodEvent { event, body } => { - assert!(matches!(event, PodEvent::TurnEnded { ref pod_name } if pod_name == "child")); + assert!( + matches!(event, PodEvent::TurnEnded { ref pod_name } if pod_name == "child") + ); assert!(body.contains("[Notification]")); assert!(body.contains("`child`")); } diff --git a/crates/pod/src/pod.rs b/crates/pod/src/pod.rs index c88e2276..0f1112de 100644 --- a/crates/pod/src/pod.rs +++ b/crates/pod/src/pod.rs @@ -1227,8 +1227,7 @@ impl Pod { self.commit_entry(LogEntry::UserInput { ts: segment_log::now_millis(), segments: input.clone(), - }) - ?; + })?; self.user_segments.push(input.clone()); // Resolve `@` refs, `#` Knowledge refs, and `/` @@ -1881,8 +1880,7 @@ impl Pod { self.commit_entry(LogEntry::TurnEnd { ts: segment_log::now_millis(), turn_count, - }) - ?; + })?; // Flush any sync-buffered metrics from this run first // (currently `prune.fire` / `prune.skip` from the prune observer). @@ -1922,8 +1920,7 @@ impl Pod { cache_read_tokens: record.cache_read_tokens, cache_write_tokens: record.cache_write_tokens, output_tokens: record.output_tokens, - }) - ?; + })?; if let Some(id) = correlation_id { let metric = session_metrics::Metric::now("prune.post_request") .with_correlation_id(&id) @@ -1945,16 +1942,14 @@ impl Pod { ts: segment_log::now_millis(), interrupted, result: r.clone(), - }) - ?; + })?; } Err(e) => { self.commit_entry(LogEntry::RunErrored { ts: segment_log::now_millis(), interrupted, message: e.to_string(), - }) - ?; + })?; } } diff --git a/crates/pod/src/segment_log_sink.rs b/crates/pod/src/segment_log_sink.rs index f59c4d68..16718f5a 100644 --- a/crates/pod/src/segment_log_sink.rs +++ b/crates/pod/src/segment_log_sink.rs @@ -119,9 +119,7 @@ impl SegmentLogSink { fn is_live_relevant(entry: &LogEntry) -> bool { matches!( entry, - LogEntry::SegmentStart { .. } - | LogEntry::SystemItem { .. } - | LogEntry::Invoke { .. } + LogEntry::SegmentStart { .. } | LogEntry::SystemItem { .. } | LogEntry::Invoke { .. } ) } diff --git a/crates/pod/tests/compact_events_test.rs b/crates/pod/tests/compact_events_test.rs index 1376b85c..102bba6a 100644 --- a/crates/pod/tests/compact_events_test.rs +++ b/crates/pod/tests/compact_events_test.rs @@ -240,7 +240,10 @@ max_tokens = 100 target = "./" permission = "write" "#; - let client = MockClient::new(vec![single_text_events("first"), single_text_events("second")]); + let client = MockClient::new(vec![ + single_text_events("first"), + single_text_events("second"), + ]); let mut pod = make_pod_with_manifest(NO_COMPACT_MANIFEST_TOML, client).await; pod.run_text("first").await.unwrap(); diff --git a/crates/pod/tests/controller_test.rs b/crates/pod/tests/controller_test.rs index ba79a007..9cc3a65c 100644 --- a/crates/pod/tests/controller_test.rs +++ b/crates/pod/tests/controller_test.rs @@ -777,13 +777,15 @@ async fn notify_while_idle_auto_starts_turn_and_injects_system_message() { // not on the `event_tx` broadcast that `handle.subscribe()` taps. // Verify the notification landed on the sink mirror instead. let (entries, _) = handle.sink.subscribe_with_snapshot(); - let saw_notify_in_mirror = entries.iter().any(|e| matches!( - e, - session_store::LogEntry::SystemItem { - item: session_store::SystemItem::Notification { message, .. }, - .. - } if message == "turn finished" - )); + let saw_notify_in_mirror = entries.iter().any(|e| { + matches!( + e, + session_store::LogEntry::SystemItem { + item: session_store::SystemItem::Notification { message, .. }, + .. + } if message == "turn finished" + ) + }); assert!( saw_notify_in_mirror, "Method::Notify should commit a SystemItem::Notification entry; mirror = {entries:?}" @@ -865,16 +867,18 @@ async fn pod_event_turn_ended_while_idle_auto_starts_turn_and_injects_system_mes // its Flush of the drain queue) runs afterwards. wait_for_status(&handle, PodStatus::Idle).await; let (entries, _) = handle.sink.subscribe_with_snapshot(); - let saw_pod_event_in_mirror = entries.iter().any(|e| matches!( - e, - session_store::LogEntry::SystemItem { - item: session_store::SystemItem::PodEvent { - event: protocol::PodEvent::TurnEnded { pod_name }, + let saw_pod_event_in_mirror = entries.iter().any(|e| { + matches!( + e, + session_store::LogEntry::SystemItem { + item: session_store::SystemItem::PodEvent { + event: protocol::PodEvent::TurnEnded { pod_name }, + .. + }, .. - }, - .. - } if pod_name == "child" - )); + } if pod_name == "child" + ) + }); assert!( saw_pod_event_in_mirror, "Method::PodEvent should commit a SystemItem::PodEvent entry" diff --git a/crates/pod/tests/restore_test.rs b/crates/pod/tests/restore_test.rs index 62044e5d..c2ce782e 100644 --- a/crates/pod/tests/restore_test.rs +++ b/crates/pod/tests/restore_test.rs @@ -78,9 +78,14 @@ async fn restore_from_manifest_rejects_empty_segment_log() { std::fs::create_dir_all(&dir).unwrap(); std::fs::write(dir.join(format!("{segid}.jsonl")), b"").unwrap(); - let result = - Pod::restore_from_manifest(sid, segid, manifest, store, pod::PromptLoader::builtins_only()) - .await; + let result = Pod::restore_from_manifest( + sid, + segid, + manifest, + store, + pod::PromptLoader::builtins_only(), + ) + .await; match result { Err(PodError::SegmentEmpty { segment_id }) => assert_eq!(segment_id, segid), @@ -106,9 +111,14 @@ async fn restore_from_manifest_rejects_segment_without_scope_snapshot() { }; session_store::create_segment_with_ids(&store, sid, segid, state).unwrap(); - let result = - Pod::restore_from_manifest(sid, segid, manifest, store, pod::PromptLoader::builtins_only()) - .await; + let result = Pod::restore_from_manifest( + sid, + segid, + manifest, + store, + pod::PromptLoader::builtins_only(), + ) + .await; match result { Err(PodError::SegmentScopeMissing { segment_id }) => assert_eq!(segment_id, segid), diff --git a/crates/session-store/src/fs_store.rs b/crates/session-store/src/fs_store.rs index 7a8738ed..fe0152c0 100644 --- a/crates/session-store/src/fs_store.rs +++ b/crates/session-store/src/fs_store.rs @@ -74,7 +74,10 @@ impl FsStore { if let Some(parent) = path.parent() { fs::create_dir_all(parent)?; } - let mut file = fs::OpenOptions::new().create(true).append(true).open(path)?; + let mut file = fs::OpenOptions::new() + .create(true) + .append(true) + .open(path)?; file.write_all(line.as_bytes())?; file.write_all(b"\n")?; // Append-mode write is the durability boundary; an explicit diff --git a/crates/session-store/src/lib.rs b/crates/session-store/src/lib.rs index c92608a7..9c326ffa 100644 --- a/crates/session-store/src/lib.rs +++ b/crates/session-store/src/lib.rs @@ -56,8 +56,8 @@ pub use segment_log::{ LogEntry, POD_SCOPE_EXTENSION_DOMAIN, PodScopeSnapshot, RestoredState, SegmentOrigin, collect_state, }; -pub use system_item::{SystemItem, render_pod_event}; pub use store::{Store, StoreError}; +pub use system_item::{SystemItem, render_pod_event}; /// Session identifier — the fork-tree root. UUID v7 (time-ordered). /// diff --git a/crates/session-store/src/segment.rs b/crates/session-store/src/segment.rs index 503a5675..7496febd 100644 --- a/crates/session-store/src/segment.rs +++ b/crates/session-store/src/segment.rs @@ -4,11 +4,11 @@ //! The caller (typically Pod) holds the Worker directly and calls these //! functions after state-mutating operations. -use crate::{SegmentId, SessionId}; use crate::logged_item::{LoggedItem, to_logged}; use crate::segment_log::{self, LogEntry, PodScopeSnapshot, SegmentOrigin}; use crate::store::{Store, StoreError}; use crate::system_item::SystemItem; +use crate::{SegmentId, SessionId}; use llm_worker::WorkerResult; use llm_worker::llm_client::RequestConfig; use llm_worker::llm_client::types::Item; diff --git a/crates/session-store/tests/fs_store_test.rs b/crates/session-store/tests/fs_store_test.rs index 5c817f8d..f4b0eb3b 100644 --- a/crates/session-store/tests/fs_store_test.rs +++ b/crates/session-store/tests/fs_store_test.rs @@ -112,9 +112,15 @@ fn list_sessions_and_segments() { let seg_a2 = new_segment_id(); let seg_b1 = new_segment_id(); - store.append(sid_a, seg_a1, &nil_session_start(1, sid_a)).unwrap(); - store.append(sid_a, seg_a2, &nil_session_start(2, sid_a)).unwrap(); - store.append(sid_b, seg_b1, &nil_session_start(3, sid_b)).unwrap(); + store + .append(sid_a, seg_a1, &nil_session_start(1, sid_a)) + .unwrap(); + store + .append(sid_a, seg_a2, &nil_session_start(2, sid_a)) + .unwrap(); + store + .append(sid_b, seg_b1, &nil_session_start(3, sid_b)) + .unwrap(); let sessions = store.list_sessions().unwrap(); assert_eq!(sessions, vec![sid_b, sid_a]); // newest first @@ -136,7 +142,9 @@ fn exists_returns_correct_state() { assert!(!store.exists(sid, segid).unwrap()); - store.append(sid, segid, &nil_session_start(1000, sid)).unwrap(); + store + .append(sid, segid, &nil_session_start(1000, sid)) + .unwrap(); assert!(store.exists(sid, segid).unwrap()); } @@ -159,7 +167,9 @@ fn trace_entries_in_separate_file() { let sid = new_session_id(); let segid = new_segment_id(); - store.append(sid, segid, &nil_session_start(1000, sid)).unwrap(); + store + .append(sid, segid, &nil_session_start(1000, sid)) + .unwrap(); let trace = TraceEntry { ts: 1500, @@ -221,7 +231,9 @@ fn lookup_session_of_finds_owning_session() { assert_eq!(store.lookup_session_of(segid).unwrap(), None); - store.append(sid, segid, &nil_session_start(1, sid)).unwrap(); + store + .append(sid, segid, &nil_session_start(1, sid)) + .unwrap(); assert_eq!(store.lookup_session_of(segid).unwrap(), Some(sid)); } diff --git a/crates/session-store/tests/session_test.rs b/crates/session-store/tests/session_test.rs index a18e8ac8..75f9ee93 100644 --- a/crates/session-store/tests/session_test.rs +++ b/crates/session-store/tests/session_test.rs @@ -475,7 +475,11 @@ async fn session_auto_forks_on_conflict() { let fork_entries = store.read_all(sid, segment_id).unwrap(); assert!(!fork_entries.is_empty()); let fork_state = collect_state(&fork_entries); - assert_eq!(fork_state.session_id, Some(sid), "auto-fork inherits Session"); + assert_eq!( + fork_state.session_id, + Some(sid), + "auto-fork inherits Session" + ); // The new segment records its lineage forward via forked_from; the // source segment is left immutable (no terminal marker written back). @@ -542,9 +546,16 @@ async fn nested_past_fork_leaves_ancestors_immutable() { } // The root and fork1 are untouched by forking their descendants. - assert_eq!(store.read_all(sid, root_segid).unwrap().len(), root_before.len()); + assert_eq!( + store.read_all(sid, root_segid).unwrap().len(), + root_before.len() + ); let fork1_entries = store.read_all(sid, fork1).unwrap(); - assert_eq!(fork1_entries.len(), 1, "fork1 is just its SegmentStart seed"); + assert_eq!( + fork1_entries.len(), + 1, + "fork1 is just its SegmentStart seed" + ); // fork2's lineage points at fork1, not the root. match &store.read_all(sid, fork2).unwrap()[0] { diff --git a/crates/tui/src/app.rs b/crates/tui/src/app.rs index df6de499..f3d5cbba 100644 --- a/crates/tui/src/app.rs +++ b/crates/tui/src/app.rs @@ -502,9 +502,7 @@ impl App { // for `tickets/invoke-turn-llmcall-semantics.md`; events flow // through to subscribers but the TUI currently derives its // turn header from `UserMessage` / `SystemItem` arrivals. - Event::InvokeStart { .. } - | Event::LlmCallStart { .. } - | Event::LlmCallEnd { .. } => {} + Event::InvokeStart { .. } | Event::LlmCallStart { .. } | Event::LlmCallEnd { .. } => {} Event::TextDelta { text } => { self.append_assistant_text(&text); } diff --git a/crates/tui/src/picker.rs b/crates/tui/src/picker.rs index 024aae85..8a38498f 100644 --- a/crates/tui/src/picker.rs +++ b/crates/tui/src/picker.rs @@ -65,7 +65,9 @@ pub enum PickerOutcome { /// User picked a session; resume at its leaf segment. The pod-cli /// rehydrates `session_id` via `Store::lookup_session_of` so we only /// need to surface the segment here. - Picked { segment_id: SegmentId }, + Picked { + segment_id: SegmentId, + }, Cancelled, } @@ -92,11 +94,7 @@ pub async fn run() -> Result { } let mut rows: Vec = Vec::with_capacity(MAX_ROWS); for session_id in sessions.into_iter().take(MAX_ROWS) { - let Some(leaf_segment_id) = store - .list_segments(session_id)? - .into_iter() - .next() - else { + let Some(leaf_segment_id) = store.list_segments(session_id)?.into_iter().next() else { continue; }; let preview = build_preview(&store, session_id, leaf_segment_id);