//! The catalogue words name tools that exist.//!//! `cotton_core::primitives::words::feeds` says, one line per kind, what//! CREATES rows of it — and where a tool does the creating it says the tool by//! name. Those names are the half of the sentence a reader acts on: an//! assistant reading "create_todo" goes and calls it, and a person reading it//! on the catalogue screen learns what their database's vocabulary is.//!//! A NAME THAT NO LONGER EXISTS IS THE FAILURE THIS FILE CATCHES, and nothing//! else would: the words are `&'static str`, so a tool renamed in//! `protocol.ts` leaves the sentence compiling, the generator green and//! `gen:check` byte-identical, while the line quietly starts pointing at//! nothing.//!//! It lives in `cotton-tools` rather than beside the words in `cotton-core`//! because the catalogue is here: `cotton-core` is pure and knows nothing about//! the tool surface, and a guard has to be able to see both halves.use std::collections::BTreeSet;use cotton_core::constants::PrimitiveKind;use cotton_core::primitives::words::feeds;use cotton_tools::mcp::protocol::tool_by_name;/// The names a `feeds` line may carry that are NOT tools, each with its reason.////// A written list, never a pattern: "anything with an underscore that is not a/// tool is fine" would let a typo through, and the whole point of the guard is/// that a name in these sentences is a promise.const NOT_TOOLS: &[(&str, &str)] = &[("create_thought","there is no create_thought and there never will be — a thought is something the person SAID \ (`crates/cotton-core/src/primitives.rs`), so the thought line names the verb by its ABSENCE. The \ phone writes a capture through `capture.create`, which is a method and not a tool for \ exactly this reason.",)];/// Every `snake_case` word in a sentence — the shape a tool name has here.fn candidate_names(line: &str) -> Vec<String> { line.split(|character: char| !(character.is_ascii_alphanumeric() || character == '_')) .filter(|word| word.contains('_')) .map(str::to_string) .collect()}#[test]fn every_tool_a_feeds_line_names_is_in_the_catalogue() {let excused: BTreeSet<&str> = NOT_TOOLS.iter().map(|(name, _)| *name).collect();letmut named = 0usize;for kind inPrimitiveKind::ALL {for name in candidate_names(feeds(kind)) {if excused.contains(name.as_str()) {continue; } named += 1; assert!( tool_by_name(&name).is_some(),"{kind:?}'s feeds line names `{name}`, which is not a tool this database has. \ Either the tool was renamed and the sentence did not follow, or the word belongs \ in NOT_TOOLS with the reason it is not one." ); } }// A guard that found nothing to check is a guard that has stopped working —// one refactor of `candidate_names` away from passing on an empty set. assert!( named > 0,"the scan found no tool names" );}