mirror of
https://github.com/instructkr/claw-code.git
synced 2026-04-07 00:24:50 +08:00
style: cargo fmt
This commit is contained in:
@@ -114,8 +114,12 @@ impl LaneEvent {
|
||||
|
||||
#[must_use]
|
||||
pub fn finished(emitted_at: impl Into<String>, detail: Option<String>) -> Self {
|
||||
Self::new(LaneEventName::Finished, LaneEventStatus::Completed, emitted_at)
|
||||
.with_optional_detail(detail)
|
||||
Self::new(
|
||||
LaneEventName::Finished,
|
||||
LaneEventStatus::Completed,
|
||||
emitted_at,
|
||||
)
|
||||
.with_optional_detail(detail)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
@@ -161,19 +165,14 @@ impl LaneEvent {
|
||||
mod tests {
|
||||
use serde_json::json;
|
||||
|
||||
use super::{
|
||||
LaneEvent, LaneEventBlocker, LaneEventName, LaneEventStatus, LaneFailureClass,
|
||||
};
|
||||
use super::{LaneEvent, LaneEventBlocker, LaneEventName, LaneEventStatus, LaneFailureClass};
|
||||
|
||||
#[test]
|
||||
fn canonical_lane_event_names_serialize_to_expected_wire_values() {
|
||||
let cases = [
|
||||
(LaneEventName::Started, "lane.started"),
|
||||
(LaneEventName::Ready, "lane.ready"),
|
||||
(
|
||||
LaneEventName::PromptMisdelivery,
|
||||
"lane.prompt_misdelivery",
|
||||
),
|
||||
(LaneEventName::PromptMisdelivery, "lane.prompt_misdelivery"),
|
||||
(LaneEventName::Blocked, "lane.blocked"),
|
||||
(LaneEventName::Red, "lane.red"),
|
||||
(LaneEventName::Green, "lane.green"),
|
||||
@@ -193,7 +192,10 @@ mod tests {
|
||||
];
|
||||
|
||||
for (event, expected) in cases {
|
||||
assert_eq!(serde_json::to_value(event).expect("serialize event"), json!(expected));
|
||||
assert_eq!(
|
||||
serde_json::to_value(event).expect("serialize event"),
|
||||
json!(expected)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -599,7 +599,10 @@ mod tests {
|
||||
));
|
||||
|
||||
match result {
|
||||
McpPhaseResult::Failure { phase: failed_phase, error } => {
|
||||
McpPhaseResult::Failure {
|
||||
phase: failed_phase,
|
||||
error,
|
||||
} => {
|
||||
assert_eq!(failed_phase, phase);
|
||||
assert_eq!(error.phase, phase);
|
||||
assert_eq!(
|
||||
|
||||
@@ -360,8 +360,10 @@ impl McpServerManagerError {
|
||||
}
|
||||
|
||||
fn recoverable(&self) -> bool {
|
||||
!matches!(self.lifecycle_phase(), McpLifecyclePhase::InitializeHandshake)
|
||||
&& matches!(self, Self::Transport { .. } | Self::Timeout { .. })
|
||||
!matches!(
|
||||
self.lifecycle_phase(),
|
||||
McpLifecyclePhase::InitializeHandshake
|
||||
) && matches!(self, Self::Transport { .. } | Self::Timeout { .. })
|
||||
}
|
||||
|
||||
fn discovery_failure(&self, server_name: &str) -> McpDiscoveryFailure {
|
||||
@@ -417,10 +419,9 @@ impl McpServerManagerError {
|
||||
("method".to_string(), (*method).to_string()),
|
||||
("timeout_ms".to_string(), timeout_ms.to_string()),
|
||||
]),
|
||||
Self::UnknownTool { qualified_name } => BTreeMap::from([(
|
||||
"qualified_tool".to_string(),
|
||||
qualified_name.clone(),
|
||||
)]),
|
||||
Self::UnknownTool { qualified_name } => {
|
||||
BTreeMap::from([("qualified_tool".to_string(), qualified_name.clone())])
|
||||
}
|
||||
Self::UnknownServer { server_name } => {
|
||||
BTreeMap::from([("server".to_string(), server_name.clone())])
|
||||
}
|
||||
@@ -1425,11 +1426,10 @@ mod tests {
|
||||
use crate::mcp_client::McpClientBootstrap;
|
||||
|
||||
use super::{
|
||||
spawn_mcp_stdio_process, JsonRpcId, JsonRpcRequest, JsonRpcResponse,
|
||||
McpInitializeClientInfo, McpInitializeParams, McpInitializeResult, McpInitializeServerInfo,
|
||||
McpListToolsResult, McpReadResourceParams, McpReadResourceResult, McpServerManager,
|
||||
McpServerManagerError, McpStdioProcess, McpTool, McpToolCallParams,
|
||||
unsupported_server_failed_server,
|
||||
spawn_mcp_stdio_process, unsupported_server_failed_server, JsonRpcId, JsonRpcRequest,
|
||||
JsonRpcResponse, McpInitializeClientInfo, McpInitializeParams, McpInitializeResult,
|
||||
McpInitializeServerInfo, McpListToolsResult, McpReadResourceParams, McpReadResourceResult,
|
||||
McpServerManager, McpServerManagerError, McpStdioProcess, McpTool, McpToolCallParams,
|
||||
};
|
||||
use crate::McpLifecyclePhase;
|
||||
|
||||
@@ -2698,7 +2698,10 @@ mod tests {
|
||||
);
|
||||
assert!(!report.failed_servers[0].recoverable);
|
||||
assert_eq!(
|
||||
report.failed_servers[0].context.get("method").map(String::as_str),
|
||||
report.failed_servers[0]
|
||||
.context
|
||||
.get("method")
|
||||
.map(String::as_str),
|
||||
Some("initialize")
|
||||
);
|
||||
assert!(report.failed_servers[0].error.contains("initialize"));
|
||||
|
||||
@@ -4,7 +4,6 @@ use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::UNIX_EPOCH;
|
||||
|
||||
|
||||
use crate::session::{Session, SessionError};
|
||||
|
||||
pub const PRIMARY_SESSION_EXTENSION: &str = "jsonl";
|
||||
|
||||
@@ -66,11 +66,7 @@ pub fn validate_packet(packet: TaskPacket) -> Result<ValidatedPacket, TaskPacket
|
||||
&packet.reporting_contract,
|
||||
&mut errors,
|
||||
);
|
||||
validate_required(
|
||||
"escalation_policy",
|
||||
&packet.escalation_policy,
|
||||
&mut errors,
|
||||
);
|
||||
validate_required("escalation_policy", &packet.escalation_policy, &mut errors);
|
||||
|
||||
for (index, test) in packet.acceptance_tests.iter().enumerate() {
|
||||
if test.trim().is_empty() {
|
||||
@@ -146,9 +142,9 @@ mod tests {
|
||||
assert!(error
|
||||
.errors()
|
||||
.contains(&"repo must not be empty".to_string()));
|
||||
assert!(error.errors().contains(
|
||||
&"acceptance_tests contains an empty value at index 1".to_string()
|
||||
));
|
||||
assert!(error
|
||||
.errors()
|
||||
.contains(&"acceptance_tests contains an empty value at index 1".to_string()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -76,11 +76,7 @@ impl TaskRegistry {
|
||||
}
|
||||
|
||||
pub fn create(&self, prompt: &str, description: Option<&str>) -> Task {
|
||||
self.create_task(
|
||||
prompt.to_owned(),
|
||||
description.map(str::to_owned),
|
||||
None,
|
||||
)
|
||||
self.create_task(prompt.to_owned(), description.map(str::to_owned), None)
|
||||
}
|
||||
|
||||
pub fn create_from_packet(
|
||||
|
||||
@@ -257,7 +257,9 @@ impl WorkerRegistry {
|
||||
let prompt_preview = prompt_preview(worker.last_prompt.as_deref().unwrap_or_default());
|
||||
let message = match observation.target {
|
||||
WorkerPromptTarget::Shell => {
|
||||
format!("worker prompt landed in shell instead of coding agent: {prompt_preview}")
|
||||
format!(
|
||||
"worker prompt landed in shell instead of coding agent: {prompt_preview}"
|
||||
)
|
||||
}
|
||||
WorkerPromptTarget::WrongTarget => format!(
|
||||
"worker prompt landed in the wrong target instead of {}: {}",
|
||||
@@ -312,7 +314,9 @@ impl WorkerRegistry {
|
||||
worker.last_error = None;
|
||||
}
|
||||
|
||||
if detect_ready_for_prompt(screen_text, &lowered) && worker.status != WorkerStatus::ReadyForPrompt {
|
||||
if detect_ready_for_prompt(screen_text, &lowered)
|
||||
&& worker.status != WorkerStatus::ReadyForPrompt
|
||||
{
|
||||
worker.status = WorkerStatus::ReadyForPrompt;
|
||||
worker.prompt_in_flight = false;
|
||||
if matches!(
|
||||
@@ -412,7 +416,10 @@ impl WorkerRegistry {
|
||||
worker_id: worker.worker_id.clone(),
|
||||
status: worker.status,
|
||||
ready: worker.status == WorkerStatus::ReadyForPrompt,
|
||||
blocked: matches!(worker.status, WorkerStatus::TrustRequired | WorkerStatus::Failed),
|
||||
blocked: matches!(
|
||||
worker.status,
|
||||
WorkerStatus::TrustRequired | WorkerStatus::Failed
|
||||
),
|
||||
replay_prompt_ready: worker.replay_prompt.is_some(),
|
||||
last_error: worker.last_error.clone(),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user