style: applied uniform style across files

This commit is contained in:
2026-08-28 11:35:45 -06:00
parent c170d08654
commit 1e15bc31d5
6 changed files with 13 additions and 23 deletions
+3 -15
View File
@@ -34,7 +34,6 @@ impl fmt::Display for LayerSource {
} }
impl LayerSource { impl LayerSource {
/// The bare level keyword, for compact diagnostics.
pub fn short_label(&self) -> &'static str { pub fn short_label(&self) -> &'static str {
match self { match self {
LayerSource::Global => "global", LayerSource::Global => "global",
@@ -69,14 +68,12 @@ impl ToolFilter {
}); });
} }
/// Each layer's source and raw patterns, in application order.
pub fn layers(&self) -> impl Iterator<Item = (&LayerSource, &[String])> { pub fn layers(&self) -> impl Iterator<Item = (&LayerSource, &[String])> {
self.layers self.layers
.iter() .iter()
.map(|layer| (&layer.source, layer.raw.as_slice())) .map(|layer| (&layer.source, layer.raw.as_slice()))
} }
/// A tool is allowed iff it matches at least one pattern in every layer.
pub fn allows(&self, tool: &str) -> bool { pub fn allows(&self, tool: &str) -> bool {
self.layers.iter().all(|layer| { self.layers.iter().all(|layer| {
layer layer
@@ -105,12 +102,7 @@ impl ToolFilter {
Ok(matched) Ok(matched)
} }
/// Context-layer patterns that match none of the advertised tools pub fn dead_context_patterns(&self, advertised: &[String]) -> Vec<(&LayerSource, &str)> {
/// surviving the global layer — dead weight, usually a typo.
pub fn dead_context_patterns<'a>(
&'a self,
advertised: &[String],
) -> Vec<(&'a LayerSource, &'a str)> {
let surviving: Vec<&String> = advertised let surviving: Vec<&String> = advertised
.iter() .iter()
.filter(|name| { .filter(|name| {
@@ -140,6 +132,7 @@ impl ToolFilter {
} }
} }
} }
dead dead
} }
} }
@@ -280,10 +273,6 @@ fn push_level(
} }
} }
/// Expands map keys to server ids: a key that is a server id maps to itself;
/// a key that is an alias expands to every configured id in its
/// comma-separated value; anything else is dropped. Keys expanding to the
/// same server merge their pattern lists.
fn expand_server_keys( fn expand_server_keys(
mcp_config: &McpServersConfig, mcp_config: &McpServersConfig,
aliases: &IndexMap<String, String>, aliases: &IndexMap<String, String>,
@@ -308,11 +297,10 @@ fn expand_server_keys(
} }
} }
} }
expanded expanded
} }
/// Expands a `mapping_mcp_servers` alias key into its comma-separated server
/// ids. A key with no alias entry expands to nothing.
pub(crate) fn expand_mcp_server_alias( pub(crate) fn expand_mcp_server_alias(
aliases: &IndexMap<String, String>, aliases: &IndexMap<String, String>,
key: &str, key: &str,
+2 -1
View File
@@ -1229,6 +1229,7 @@ impl RequestContext {
app.enabled_tools.clone(), app.enabled_tools.clone(),
app.enabled_mcp_servers.clone(), app.enabled_mcp_servers.clone(),
); );
role role
}; };
@@ -3063,7 +3064,6 @@ impl RequestContext {
.any(|id| has_layers(id)) .any(|id| has_layers(id))
} }
/// The `.list mcp-servers` output, or `None` when nothing is configured.
pub fn mcp_servers_listing(&self) -> Option<String> { pub fn mcp_servers_listing(&self) -> Option<String> {
let mut names: Vec<String> = vec![]; let mut names: Vec<String> = vec![];
if let Some(mcp_config) = &self.app.mcp_config { if let Some(mcp_config) = &self.app.mcp_config {
@@ -3108,6 +3108,7 @@ impl RequestContext {
}; };
out.push_str(&format!(" {marker} {name}{tag}\n")); out.push_str(&format!(" {marker} {name}{tag}\n"));
} }
Some(out) Some(out)
} }
+2 -1
View File
@@ -152,7 +152,6 @@ impl Skill {
self.enabled_mcp_servers.as_deref() self.enabled_mcp_servers.as_deref()
} }
#[allow(dead_code)]
pub fn mcp_tools(&self) -> Option<&IndexMap<String, Vec<String>>> { pub fn mcp_tools(&self) -> Option<&IndexMap<String, Vec<String>>> {
self.mcp_tools.as_ref() self.mcp_tools.as_ref()
} }
@@ -198,6 +197,7 @@ fn parse_skill_string_or_array(value: &Value) -> Option<Vec<String>> {
fn parse_skill_mcp_tools_map(value: &Value) -> Option<IndexMap<String, Vec<String>>> { fn parse_skill_mcp_tools_map(value: &Value) -> Option<IndexMap<String, Vec<String>>> {
let map = value.as_object()?; let map = value.as_object()?;
let mut mcp_tools = IndexMap::new(); let mut mcp_tools = IndexMap::new();
for (server, tools) in map { for (server, tools) in map {
if tools.is_null() { if tools.is_null() {
mcp_tools.insert(server.clone(), Vec::new()); mcp_tools.insert(server.clone(), Vec::new());
@@ -205,6 +205,7 @@ fn parse_skill_mcp_tools_map(value: &Value) -> Option<IndexMap<String, Vec<Strin
mcp_tools.insert(server.clone(), tools); mcp_tools.insert(server.clone(), tools);
} }
} }
Some(mcp_tools) Some(mcp_tools)
} }
+3
View File
@@ -107,13 +107,16 @@ impl McpRuntime {
if let Some(filter) = self.tool_filters.get(server) { if let Some(filter) = self.tool_filters.get(server) {
let advertised: Vec<String> = let advertised: Vec<String> =
tools.iter().map(|tool| tool.name.to_string()).collect(); tools.iter().map(|tool| tool.name.to_string()).collect();
for (source, pattern) in filter.dead_context_patterns(&advertised) { for (source, pattern) in filter.dead_context_patterns(&advertised) {
warn!( warn!(
"MCP tool pattern '{pattern}' from {source} matches no allowed tools on server '{server}'" "MCP tool pattern '{pattern}' from {source} matches no allowed tools on server '{server}'"
); );
} }
tools.retain(|tool| filter.allows(&tool.name)); tools.retain(|tool| filter.allows(&tool.name));
} }
merge_catalog_items( merge_catalog_items(
&mut items, &mut items,
tools tools
-3
View File
@@ -363,9 +363,6 @@ fn whitelist_rejection(tool: &str) -> Option<Value> {
}) })
} }
/// Whether a declared tool could be run as a background job. This is the
/// declare-side twin of `whitelist_rejection`: a tool is backgroundable
/// exactly when `job__start` would not reject it by name.
pub fn is_backgroundable_tool(tool: &str) -> bool { pub fn is_backgroundable_tool(tool: &str) -> bool {
whitelist_rejection(tool).is_none() whitelist_rejection(tool).is_none()
} }
+3 -3
View File
@@ -1,6 +1,7 @@
use super::state::template_root_keys; use super::state::template_root_keys;
use super::types::{Graph, Node, NodeType}; use super::types::{Graph, Node, NodeType};
use crate::client::{Model, ModelType}; use crate::client::{Model, ModelType};
use crate::config;
use crate::config::{Agent, AppConfig, paths}; use crate::config::{Agent, AppConfig, paths};
use crate::rag::{GraphRagConfig, RagData}; use crate::rag::{GraphRagConfig, RagData};
use anyhow::{Result, bail}; use anyhow::{Result, bail};
@@ -214,9 +215,8 @@ impl GraphValidator {
return; return;
}; };
let expand_alias = |name: &str| { let expand_alias =
crate::config::expand_mcp_server_alias(&ctx.app_config.mapping_mcp_servers, name) |name: &str| config::expand_mcp_server_alias(&ctx.app_config.mapping_mcp_servers, name);
};
let mut enabled_servers: HashSet<String> = ctx.mcp_servers.clone(); let mut enabled_servers: HashSet<String> = ctx.mcp_servers.clone();
for server in &ctx.mcp_servers { for server in &ctx.mcp_servers {
enabled_servers.extend(expand_alias(server)); enabled_servers.extend(expand_alias(server));