pub(in crate::mcp::policy) use assay_common::tool_pattern::matches_tool_pattern;
#[cfg(test)]
mod tests {
use super::matches_tool_pattern;
use crate::runtime::glob_matches_impl;
#[test]
fn the_two_tool_pattern_languages_differ_deliberately() {
assert!(matches_tool_pattern("read_file", "read_*"));
assert!(glob_matches_impl("read_*", "read_file"));
assert!(
matches_tool_pattern("fs.read_file", "*"),
"the policy matcher's `*` is unbounded"
);
assert!(
!glob_matches_impl("*", "fs.read_file"),
"the mandate matcher's `*` stops at a dot; `**` is the crossing form"
);
assert!(
glob_matches_impl("**", "fs.read_file"),
"`**` crosses, which is why it exists"
);
assert!(
glob_matches_impl("read_*_file", "read_config_file"),
"the mandate matcher expands an interior star"
);
assert!(
!matches_tool_pattern("read_config_file", "read_*_file"),
"the policy matcher reads it as a literal asterisk"
);
assert!(
glob_matches_impl(r"file\*name", "file*name"),
r"`\*` is a literal asterisk to the mandate matcher"
);
assert!(
!matches_tool_pattern("file*name", r"file\*name"),
"to the policy matcher the backslash is part of the name it is looking for"
);
assert!(matches_tool_pattern("fs.read_file", "**"));
}
}