fix: add --all to cargo fmt in script/test and autoformat codebase

cargo fmt without --all fails with "Failed to find targets" in
workspace repos. This was blocking every story's gates. Also ran
cargo fmt --all to fix all existing formatting issues.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
dave
2026-04-13 14:07:08 +00:00
parent ed2526ce41
commit 845b85e7a7
128 changed files with 3566 additions and 2395 deletions
+9 -12
View File
@@ -1,9 +1,9 @@
//! LLM chat — orchestrates multi-turn conversations with tool-calling LLM providers.
use crate::slog;
use crate::io::onboarding;
use crate::llm::prompts::{ONBOARDING_PROMPT, SYSTEM_PROMPT};
use crate::llm::providers::claude_code::ClaudeCodeResult;
use crate::llm::types::{Message, Role, ToolCall, ToolDefinition, ToolFunctionDefinition};
use crate::slog;
use crate::state::SessionState;
use crate::store::StoreOps;
use serde::Deserialize;
@@ -767,10 +767,7 @@ mod tests {
let store = MockStore::new();
let result = set_anthropic_api_key_impl(&store, "sk-my-key");
assert!(result.is_ok());
assert_eq!(
store.get("anthropic_api_key"),
Some(json!("sk-my-key"))
);
assert_eq!(store.get("anthropic_api_key"), Some(json!("sk-my-key")));
}
#[test]
@@ -868,8 +865,7 @@ mod tests {
let required = read_file.function.parameters["required"]
.as_array()
.unwrap();
let required_names: Vec<&str> =
required.iter().map(|v| v.as_str().unwrap()).collect();
let required_names: Vec<&str> = required.iter().map(|v| v.as_str().unwrap()).collect();
assert!(required_names.contains(&"path"));
}
@@ -883,8 +879,7 @@ mod tests {
let required = exec_shell.function.parameters["required"]
.as_array()
.unwrap();
let required_names: Vec<&str> =
required.iter().map(|v| v.as_str().unwrap()).collect();
let required_names: Vec<&str> = required.iter().map(|v| v.as_str().unwrap()).collect();
assert!(required_names.contains(&"command"));
assert!(required_names.contains(&"args"));
}
@@ -936,9 +931,11 @@ mod tests {
.await;
assert!(result.is_err());
assert!(result
.unwrap_err()
.contains("Unsupported provider: unsupported-provider"));
assert!(
result
.unwrap_err()
.contains("Unsupported provider: unsupported-provider")
);
}
// ---------------------------------------------------------------------------
+10 -13
View File
@@ -49,7 +49,9 @@ struct TokenRefreshError {
/// Returns the path to `~/.claude/.credentials.json`.
fn credentials_path() -> Result<PathBuf, String> {
let home = std::env::var("HOME").map_err(|_| "HOME not set".to_string())?;
Ok(PathBuf::from(home).join(".claude").join(".credentials.json"))
Ok(PathBuf::from(home)
.join(".claude")
.join(".credentials.json"))
}
/// Read OAuth credentials from disk.
@@ -61,12 +63,7 @@ pub fn read_credentials() -> Result<CredentialsFile, String> {
path.display()
)
})?;
serde_json::from_str(&data).map_err(|e| {
format!(
"Failed to parse {}: {e}",
path.display()
)
})
serde_json::from_str(&data).map_err(|e| format!("Failed to parse {}: {e}", path.display()))
}
/// Write updated credentials back to disk with 0600 permissions.
@@ -74,8 +71,7 @@ pub fn write_credentials(creds: &CredentialsFile) -> Result<(), String> {
let path = credentials_path()?;
let data = serde_json::to_string_pretty(creds)
.map_err(|e| format!("Failed to serialize credentials: {e}"))?;
std::fs::write(&path, &data)
.map_err(|e| format!("Failed to write {}: {e}", path.display()))?;
std::fs::write(&path, &data).map_err(|e| format!("Failed to write {}: {e}", path.display()))?;
// Restore 0600 permissions
#[cfg(unix)]
@@ -102,9 +98,7 @@ pub async fn refresh_access_token() -> Result<(), String> {
let refresh_token = creds.claude_ai_oauth.refresh_token.clone();
if refresh_token.is_empty() {
return Err(
"No refresh token found. Run `claude login` to authenticate.".to_string(),
);
return Err("No refresh token found. Run `claude login` to authenticate.".to_string());
}
let client = reqwest::Client::new();
@@ -215,7 +209,10 @@ mod tests {
assert_eq!(creds.claude_ai_oauth.access_token, "sk-ant-oat01-test");
assert_eq!(creds.claude_ai_oauth.refresh_token, "sk-ant-ort01-test");
assert_eq!(creds.claude_ai_oauth.expires_at, 1774466144677);
assert_eq!(creds.claude_ai_oauth.subscription_type.as_deref(), Some("max"));
assert_eq!(
creds.claude_ai_oauth.subscription_type.as_deref(),
Some("max")
);
}
#[test]
+2 -3
View File
@@ -752,9 +752,8 @@ mod tests {
"delta": {"type": "input_json_delta", "partial_json": "{}"}
});
let stop_event = json!({"type": "content_block_stop"});
let body = format!(
"data: {start_event}\ndata: {delta_event}\ndata: {stop_event}\ndata: [DONE]\n"
);
let body =
format!("data: {start_event}\ndata: {delta_event}\ndata: {stop_event}\ndata: [DONE]\n");
let _m = server
.mock("POST", "/v1/messages")
+21 -8
View File
@@ -77,12 +77,9 @@ impl ClaudeCodeProvider {
let auth_failed = Arc::new(AtomicBool::new(false));
let auth_failed_clone = auth_failed.clone();
let (token_tx, mut token_rx) =
tokio::sync::mpsc::unbounded_channel::<String>();
let (thinking_tx, mut thinking_rx) =
tokio::sync::mpsc::unbounded_channel::<String>();
let (activity_tx, mut activity_rx) =
tokio::sync::mpsc::unbounded_channel::<String>();
let (token_tx, mut token_rx) = tokio::sync::mpsc::unbounded_channel::<String>();
let (thinking_tx, mut thinking_rx) = tokio::sync::mpsc::unbounded_channel::<String>();
let (activity_tx, mut activity_rx) = tokio::sync::mpsc::unbounded_channel::<String>();
let (msg_tx, msg_rx) = std::sync::mpsc::channel::<Message>();
let (sid_tx, sid_rx) = tokio::sync::oneshot::channel::<String>();
@@ -1038,7 +1035,15 @@ mod tests {
let (sid_tx, mut sid_rx) = tokio::sync::oneshot::channel::<String>();
let mut sid_tx_opt = Some(sid_tx);
let json = json!({"type": "system", "session_id": "sess-abc-123"});
process_json_event(&json, &tok_tx, &thi_tx, &act_tx, &msg_tx, &mut sid_tx_opt, &AtomicBool::new(false));
process_json_event(
&json,
&tok_tx,
&thi_tx,
&act_tx,
&msg_tx,
&mut sid_tx_opt,
&AtomicBool::new(false),
);
// sid_tx should have been consumed
assert!(sid_tx_opt.is_none());
let received = sid_rx.try_recv().unwrap();
@@ -1051,7 +1056,15 @@ mod tests {
let (sid_tx, _sid_rx) = tokio::sync::oneshot::channel::<String>();
let mut sid_tx_opt = Some(sid_tx);
let json = json!({"type": "system"});
process_json_event(&json, &tok_tx, &thi_tx, &act_tx, &msg_tx, &mut sid_tx_opt, &AtomicBool::new(false));
process_json_event(
&json,
&tok_tx,
&thi_tx,
&act_tx,
&msg_tx,
&mut sid_tx_opt,
&AtomicBool::new(false),
);
// sid_tx should still be present since no session_id in event
assert!(sid_tx_opt.is_some());
}