Skip to content

Commit 3ffa141

Browse files
hikejsclaude
andcommitted
fix: resolve clippy warnings in orchestrator module
- Add #[allow(dead_code)] to task_handle field (intentionally unused, keeps task alive) - Remove unused publish_event() and event_sender() methods - Events are published directly via event_tx.send() throughout the codebase Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 9b3d54b commit 3ffa141

9 files changed

Lines changed: 31 additions & 55 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/src/orchestrator/config.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,10 @@ pub enum SubAgentActivity {
102102
},
103103

104104
/// 正在请求 LLM
105-
RequestingLlm {
106-
message_count: usize,
107-
},
105+
RequestingLlm { message_count: usize },
108106

109107
/// 正在等待控制信号
110-
WaitingForControl {
111-
reason: String,
112-
},
108+
WaitingForControl { reason: String },
113109
}
114110

115111
impl SubAgentConfig {

core/src/orchestrator/control.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ pub enum ControlSignal {
2424
},
2525

2626
/// 注入新提示词
27-
InjectPrompt {
28-
prompt: String,
29-
},
27+
InjectPrompt { prompt: String },
3028
}
3129

3230
impl std::fmt::Display for ControlSignal {

core/src/orchestrator/events.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,10 @@ pub enum OrchestratorEvent {
5353
},
5454

5555
/// 规划开始
56-
PlanningStarted {
57-
id: String,
58-
goal: String,
59-
},
56+
PlanningStarted { id: String, goal: String },
6057

6158
/// 规划完成
62-
PlanningCompleted {
63-
id: String,
64-
plan: ExecutionPlan,
65-
},
59+
PlanningCompleted { id: String, plan: ExecutionPlan },
6660

6761
/// 工具执行开始
6862
ToolExecutionStarted {
@@ -83,10 +77,7 @@ pub enum OrchestratorEvent {
8377
},
8478

8579
/// 控制信号接收
86-
ControlSignalReceived {
87-
id: String,
88-
signal: ControlSignal,
89-
},
80+
ControlSignalReceived { id: String, signal: ControlSignal },
9081

9182
/// 控制信号应用
9283
ControlSignalApplied {

core/src/orchestrator/handle.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ pub struct SubAgentHandle {
2828
/// 当前活动
2929
pub(crate) activity: Arc<RwLock<SubAgentActivity>>,
3030

31-
/// 任务句柄
31+
/// 任务句柄(保持任务存活,不直接访问)
32+
#[allow(dead_code)]
3233
task_handle: Arc<tokio::task::JoinHandle<Result<String>>>,
3334
}
3435

core/src/orchestrator/orchestrator.rs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,10 @@ impl AgentOrchestrator {
135135
);
136136

137137
// 注册到 orchestrator
138-
self.subagents.write().await.insert(id.clone(), handle.clone());
138+
self.subagents
139+
.write()
140+
.await
141+
.insert(id.clone(), handle.clone());
139142

140143
Ok(handle)
141144
}
@@ -150,10 +153,12 @@ impl AgentOrchestrator {
150153
handle.send_control(signal.clone()).await?;
151154

152155
// 发布控制信号接收事件
153-
let _ = self.event_tx.send(OrchestratorEvent::ControlSignalReceived {
154-
id: id.to_string(),
155-
signal,
156-
});
156+
let _ = self
157+
.event_tx
158+
.send(OrchestratorEvent::ControlSignalReceived {
159+
id: id.to_string(),
160+
signal,
161+
});
157162

158163
Ok(())
159164
}
@@ -298,23 +303,16 @@ impl AgentOrchestrator {
298303
let subagents = self.subagents.read().await;
299304
subagents.get(id).cloned()
300305
}
301-
302-
/// 发布事件(内部使用)
303-
pub(crate) fn publish_event(&self, event: OrchestratorEvent) {
304-
let _ = self.event_tx.send(event);
305-
}
306-
307-
/// 获取事件发送器(用于 SubAgentWrapper)
308-
pub(crate) fn event_sender(&self) -> broadcast::Sender<OrchestratorEvent> {
309-
self.event_tx.clone()
310-
}
311306
}
312307

313308
impl std::fmt::Debug for AgentOrchestrator {
314309
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
315310
f.debug_struct("AgentOrchestrator")
316311
.field("event_buffer_size", &self.config.event_buffer_size)
317-
.field("max_concurrent_subagents", &self.config.max_concurrent_subagents)
312+
.field(
313+
"max_concurrent_subagents",
314+
&self.config.max_concurrent_subagents,
315+
)
318316
.finish()
319317
}
320318
}

core/src/orchestrator/state.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,13 @@ pub enum SubAgentState {
1515
Paused,
1616

1717
/// 已完成
18-
Completed {
19-
success: bool,
20-
output: String,
21-
},
18+
Completed { success: bool, output: String },
2219

2320
/// 已取消
2421
Cancelled,
2522

2623
/// 错误
27-
Error {
28-
message: String,
29-
},
24+
Error { message: String },
3025
}
3126

3227
impl SubAgentState {

core/src/orchestrator/tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,3 @@ async fn test_max_concurrent_subagents() {
190190
let result: Result<SubAgentHandle> = orchestrator.spawn_subagent(agent_config).await;
191191
assert!(result.is_err());
192192
}
193-

core/src/orchestrator/wrapper.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,12 @@ impl SubAgentWrapper {
210210
};
211211

212212
// 发布控制信号应用事件
213-
let _ = self
214-
.event_tx
215-
.send(OrchestratorEvent::ControlSignalApplied {
216-
id: self.id.clone(),
217-
signal,
218-
success: result.is_ok(),
219-
error: result.as_ref().err().map(|e| format!("{}", e)),
220-
});
213+
let _ = self.event_tx.send(OrchestratorEvent::ControlSignalApplied {
214+
id: self.id.clone(),
215+
signal,
216+
success: result.is_ok(),
217+
error: result.as_ref().err().map(|e| format!("{}", e)),
218+
});
221219

222220
result
223221
}

0 commit comments

Comments
 (0)