style: cargo fmt on today's new code (883/884/886/opus-pin)
The mergemaster gates run rustfmt and rejected 864's merge because several files I added/touched in master today had not been fmt'd. Six files affected, mostly trivial line-wrapping nits. Fixes the formatting gate for the next 864 merge attempt.
This commit is contained in:
@@ -318,12 +318,12 @@ mod tests {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Set the typed CRDT register (this is the path 871's migration uses).
|
// Set the typed CRDT register (this is the path 871's migration uses).
|
||||||
let written =
|
let written = crate::crdt_state::set_agent("9971_story_pin_in_crdt", Some("coder-opus"));
|
||||||
crate::crdt_state::set_agent("9971_story_pin_in_crdt", Some("coder-opus"));
|
|
||||||
assert!(written, "set_agent should succeed for an existing item");
|
assert!(written, "set_agent should succeed for an existing item");
|
||||||
|
|
||||||
// The reader must return the CRDT register value, not None.
|
// The reader must return the CRDT register value, not None.
|
||||||
let agent = read_story_front_matter_agent(tmp.path(), "2_current", "9971_story_pin_in_crdt");
|
let agent =
|
||||||
|
read_story_front_matter_agent(tmp.path(), "2_current", "9971_story_pin_in_crdt");
|
||||||
assert_eq!(agent.as_deref(), Some("coder-opus"));
|
assert_eq!(agent.as_deref(), Some("coder-opus"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,9 +36,7 @@ pub fn spawn_permission_listener(
|
|||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let mut perm_rx = services.perm_rx.lock().await;
|
let mut perm_rx = services.perm_rx.lock().await;
|
||||||
let target_room_str = target_room.as_str().to_string();
|
let target_room_str = target_room.as_str().to_string();
|
||||||
slog!(
|
slog!("[matrix-bot] permission listener started; forwarding requests to {target_room_str}");
|
||||||
"[matrix-bot] permission listener started; forwarding requests to {target_room_str}"
|
|
||||||
);
|
|
||||||
|
|
||||||
while let Some(perm_fwd) = perm_rx.recv().await {
|
while let Some(perm_fwd) = perm_rx.recv().await {
|
||||||
let prompt_msg = format!(
|
let prompt_msg = format!(
|
||||||
@@ -131,13 +129,7 @@ mod tests {
|
|||||||
Ok("$test_event_id:example.com".to_string())
|
Ok("$test_event_id:example.com".to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn edit_message(
|
async fn edit_message(&self, _: &str, _: &str, _: &str, _: &str) -> Result<(), String> {
|
||||||
&self,
|
|
||||||
_: &str,
|
|
||||||
_: &str,
|
|
||||||
_: &str,
|
|
||||||
_: &str,
|
|
||||||
) -> Result<(), String> {
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,19 +138,14 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_services_with_tx() -> (
|
fn test_services_with_tx() -> (Arc<Services>, mpsc::UnboundedSender<PermissionForward>) {
|
||||||
Arc<Services>,
|
|
||||||
mpsc::UnboundedSender<PermissionForward>,
|
|
||||||
) {
|
|
||||||
let (perm_tx, perm_rx) = mpsc::unbounded_channel();
|
let (perm_tx, perm_rx) = mpsc::unbounded_channel();
|
||||||
let services = Arc::new(Services {
|
let services = Arc::new(Services {
|
||||||
project_root: std::path::PathBuf::from("/tmp/test"),
|
project_root: std::path::PathBuf::from("/tmp/test"),
|
||||||
agents: Arc::new(crate::agents::AgentPool::new_test(3000)),
|
agents: Arc::new(crate::agents::AgentPool::new_test(3000)),
|
||||||
bot_name: "Assistant".to_string(),
|
bot_name: "Assistant".to_string(),
|
||||||
bot_user_id: "@bot:example.com".to_string(),
|
bot_user_id: "@bot:example.com".to_string(),
|
||||||
ambient_rooms: Arc::new(std::sync::Mutex::new(
|
ambient_rooms: Arc::new(std::sync::Mutex::new(std::collections::HashSet::new())),
|
||||||
std::collections::HashSet::new(),
|
|
||||||
)),
|
|
||||||
perm_rx: Arc::new(TokioMutex::new(perm_rx)),
|
perm_rx: Arc::new(TokioMutex::new(perm_rx)),
|
||||||
pending_perm_replies: Arc::new(TokioMutex::new(HashMap::new())),
|
pending_perm_replies: Arc::new(TokioMutex::new(HashMap::new())),
|
||||||
permission_timeout_secs: 120,
|
permission_timeout_secs: 120,
|
||||||
|
|||||||
@@ -61,11 +61,7 @@ pub async fn mcp_get_handler() -> Response {
|
|||||||
/// `POST /mcp` — JSON-RPC 2.0 entry point for `initialize`, `tools/list`,
|
/// `POST /mcp` — JSON-RPC 2.0 entry point for `initialize`, `tools/list`,
|
||||||
/// `tools/call`, and `notifications/*`.
|
/// `tools/call`, and `notifications/*`.
|
||||||
#[handler]
|
#[handler]
|
||||||
pub async fn mcp_post_handler(
|
pub async fn mcp_post_handler(req: &Request, body: Body, ctx: Data<&Arc<AppContext>>) -> Response {
|
||||||
req: &Request,
|
|
||||||
body: Body,
|
|
||||||
ctx: Data<&Arc<AppContext>>,
|
|
||||||
) -> Response {
|
|
||||||
let content_type = req.header("content-type").unwrap_or("");
|
let content_type = req.header("content-type").unwrap_or("");
|
||||||
if !content_type.is_empty() && !content_type.contains("application/json") {
|
if !content_type.is_empty() && !content_type.contains("application/json") {
|
||||||
return json_response(JsonRpcResponse::error(
|
return json_response(JsonRpcResponse::error(
|
||||||
|
|||||||
@@ -366,12 +366,8 @@ async fn run_script_tool(
|
|||||||
|
|
||||||
// When verbose, fall back to the legacy truncated output so callers
|
// When verbose, fall back to the legacy truncated output so callers
|
||||||
// who actually want raw text still get a bounded payload.
|
// who actually want raw text still get a bounded payload.
|
||||||
let mut payload = build_diagnostic_response(
|
let mut payload =
|
||||||
result.status.success(),
|
build_diagnostic_response(result.status.success(), exit_code, &combined, verbose);
|
||||||
exit_code,
|
|
||||||
&combined,
|
|
||||||
verbose,
|
|
||||||
);
|
|
||||||
if verbose {
|
if verbose {
|
||||||
payload["output"] = serde_json::json!(truncate_output(&combined, MAX_OUTPUT_LINES));
|
payload["output"] = serde_json::json!(truncate_output(&combined, MAX_OUTPUT_LINES));
|
||||||
}
|
}
|
||||||
@@ -715,7 +711,10 @@ mod tests {
|
|||||||
"last error code should be parsed"
|
"last error code should be parsed"
|
||||||
);
|
);
|
||||||
let summary = parsed["summary"].as_str().expect("summary string");
|
let summary = parsed["summary"].as_str().expect("summary string");
|
||||||
assert!(summary.contains("150 error"), "summary mentions error count: {summary}");
|
assert!(
|
||||||
|
summary.contains("150 error"),
|
||||||
|
"summary mentions error count: {summary}"
|
||||||
|
);
|
||||||
// Default response should be small even with 150 errors.
|
// Default response should be small even with 150 errors.
|
||||||
assert!(
|
assert!(
|
||||||
result.len() < 50_000,
|
result.len() < 50_000,
|
||||||
@@ -724,9 +723,13 @@ mod tests {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Verbose mode: raw output is included.
|
// Verbose mode: raw output is included.
|
||||||
let result_v = tool_run_check(&json!({"verbose": true}), &ctx).await.unwrap();
|
let result_v = tool_run_check(&json!({"verbose": true}), &ctx)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
let parsed_v: serde_json::Value = serde_json::from_str(&result_v).unwrap();
|
let parsed_v: serde_json::Value = serde_json::from_str(&result_v).unwrap();
|
||||||
let output = parsed_v["output"].as_str().expect("verbose includes output");
|
let output = parsed_v["output"]
|
||||||
|
.as_str()
|
||||||
|
.expect("verbose includes output");
|
||||||
assert!(output.contains("error[E1]"), "verbose contains first line");
|
assert!(output.contains("error[E1]"), "verbose contains first line");
|
||||||
assert!(output.contains("error[E150]"), "verbose contains last line");
|
assert!(output.contains("error[E150]"), "verbose contains last line");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,12 +8,12 @@
|
|||||||
|
|
||||||
/// Side-effectful shell I/O — filesystem permission checks.
|
/// Side-effectful shell I/O — filesystem permission checks.
|
||||||
pub mod io;
|
pub mod io;
|
||||||
/// Pure command-safety checks, blocked-binary lists, and output truncation.
|
|
||||||
pub mod path_guard;
|
|
||||||
/// Cargo / rustc diagnostic parser — extracts structured errors and warnings
|
/// Cargo / rustc diagnostic parser — extracts structured errors and warnings
|
||||||
/// from raw cargo output. Used by run_check / run_build / run_lint MCP tools
|
/// from raw cargo output. Used by run_check / run_build / run_lint MCP tools
|
||||||
/// (bug 886).
|
/// (bug 886).
|
||||||
pub mod parse_diagnostics;
|
pub mod parse_diagnostics;
|
||||||
|
/// Pure command-safety checks, blocked-binary lists, and output truncation.
|
||||||
|
pub mod path_guard;
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
pub use path_guard::{
|
pub use path_guard::{
|
||||||
|
|||||||
@@ -59,8 +59,8 @@ pub fn parse_diagnostics(output: &str) -> Vec<Diagnostic> {
|
|||||||
// Anchored to start-of-line: "error" or "warning", optional [CODE], colon, message.
|
// Anchored to start-of-line: "error" or "warning", optional [CODE], colon, message.
|
||||||
Regex::new(r"^(error|warning)(?:\[([A-Za-z0-9]+)\])?: (.+)$").unwrap()
|
Regex::new(r"^(error|warning)(?:\[([A-Za-z0-9]+)\])?: (.+)$").unwrap()
|
||||||
});
|
});
|
||||||
let loc_re = LOC_RE
|
let loc_re =
|
||||||
.get_or_init(|| Regex::new(r"^\s*-->\s+([^:\s][^:]*):(\d+)(?::\d+)?\s*$").unwrap());
|
LOC_RE.get_or_init(|| Regex::new(r"^\s*-->\s+([^:\s][^:]*):(\d+)(?::\d+)?\s*$").unwrap());
|
||||||
|
|
||||||
let lines: Vec<&str> = output.lines().collect();
|
let lines: Vec<&str> = output.lines().collect();
|
||||||
let mut diagnostics = Vec::new();
|
let mut diagnostics = Vec::new();
|
||||||
@@ -155,7 +155,8 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ignores_non_diagnostic_lines() {
|
fn ignores_non_diagnostic_lines() {
|
||||||
let input = " Checking huskies v0.10.4\n Compiling foo v0.1.0\n Finished dev profile\n";
|
let input =
|
||||||
|
" Checking huskies v0.10.4\n Compiling foo v0.1.0\n Finished dev profile\n";
|
||||||
assert!(parse_diagnostics(input).is_empty());
|
assert!(parse_diagnostics(input).is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,8 +193,10 @@ error: could not compile `huskies` (bin \"huskies\") due to 3 previous errors; 1
|
|||||||
assert_eq!(summary.warning_count, 2);
|
assert_eq!(summary.warning_count, 2);
|
||||||
|
|
||||||
// The 3 main compile errors must be present with file + line.
|
// The 3 main compile errors must be present with file + line.
|
||||||
let e0061: Vec<&Diagnostic> =
|
let e0061: Vec<&Diagnostic> = diags
|
||||||
diags.iter().filter(|d| d.code.as_deref() == Some("E0061")).collect();
|
.iter()
|
||||||
|
.filter(|d| d.code.as_deref() == Some("E0061"))
|
||||||
|
.collect();
|
||||||
assert_eq!(e0061.len(), 3);
|
assert_eq!(e0061.len(), 3);
|
||||||
let files: Vec<Option<&str>> = e0061.iter().map(|d| d.file.as_deref()).collect();
|
let files: Vec<Option<&str>> = e0061.iter().map(|d| d.file.as_deref()).collect();
|
||||||
assert!(files.contains(&Some("server/src/agents/pool/auto_assign/merge.rs")));
|
assert!(files.contains(&Some("server/src/agents/pool/auto_assign/merge.rs")));
|
||||||
|
|||||||
Reference in New Issue
Block a user