Cotton code
779 lines · 30.8 KB · RustRaw
//! The verb grid's gates, and the catalogue's own identity.//! Guard tool ownership, access and destructive annotations here. Retry//! behavior is guarded at each write, rather than by a duplicate name list.use std::collections::{HashMap, HashSet};use super::*;use crate::mcp::protocol::{tool_catalogue, McpScope, TOOLS};static DESTRUCTIVE: &[&str] = &[    "archive_database",    // Definition acts can cancel an existing claim or change stored values;    // their shared runner must advertise the destructive possibility.    "run_record_act",    // `restore_version` writes old values over the record as it stands.    "restore_version",    // What a phone keeps: setting a rule rewrites the one a phone had, and    // clearing one takes it away.    "set_keep_rule",    "set_audience",    "clear_keep_rule",    // The day surface's owner verbs (4e). "Destructive" is Anthropic's own    // rule — a call that MODIFIES or DELETES something already in the file.    // Stopping a repeat removes the template and its unclaimed future    // occurrences; answering an invitation rewrites the row.    "stop_todo_recurrence",    "respond_to_invite",    // Making a todo repeat rewrites the todo itself into the series' anchor,    // and reshaping the rule rewrites and drops its future projections.    "make_todo_recurring",    "update_todo_recurrence",    // The guest list REPLACES: a guest left out is removed and every response    // goes back to needs_action. It is also the one 4e verb that is destructive    // WITHOUT being idempotent — see IDEMPOTENT's note.    "update_attendees",    // The OWNER scope (4f) — the work app's own verbs: each rewrites which    // project a session belongs to, or its name.    "move_session",    "rename_session",    // Secrets (v46): storing a key under a name that already holds one    // REPLACES the value, and deleting one erases it with no bin. Both modify    // or delete what is already there, which is Anthropic's rule verbatim.    // `update_secret` (v6 of the Rust ladder) rewrites the row it names, which    // is the same rule again.    "create_secret",    "delete_secret",    "update_secret",    // The mail client (v33): each rewrites state Gmail is then told about, and    // empty_bin is the one verb in the whole email surface that erases.    "update_email",    "update_emails",    "block_sender",    "unblock_sender",    // The sweep (12 Oct 2026): Add to People lifts a block and rewrites who the    // sender is; Empty Junk bins every Junk conversation.    "add_sender_to_people",    "empty_junk",    "restore_from_bin",    "empty_bin",    "complete_todo",    "update_todo",    "update_todos",    "update_person",    // It replaces the paragraph a person reads at the top of a record — prose    // somebody wrote, not a row it appends beside.    "update_summary",    "update_event",    "delete_event",    // The batch forms of the same two verbs (schema v32). Each row is a rewrite    // or a delete of an event the owner can see, and fifty of them at once is    // the reason a client should ask first rather than the reason it should not.    "update_events",    "delete_events",    // The generic record verbs (v47): each rewrites or removes what is already    // in a table — a patch, a delete, a new order, a moved link — and an undo    // puts back an earlier state over the current one.    "update_record",    "save_theme",    "update_board",    "delete_record",    "reorder_records",    "link_records",    "undo",    // Groups (Spec 6): each rewrites a group the owner already sees on the    // table — its members, their order, or the group itself. `create_group`    // makes a new one and is ADDITIVE.    "update_group",    "delete_group",    // A kept mapping replaces the one the connection read by.    "set_connection_mapping",    // Connecting a mailbox again replaces the vault secret it reads with.    "connect",    "remove_tool",    // Toolkits: saving over a kit at the same id, changing one, or deleting    // one rewrites what the chooser offers.    "save_toolkit",    "update_toolkit",    "delete_toolkit",    // It rewrites how a table's records look, over the definition as it stands.    "update_definition",    // It rewrites which tiles the owner keeps on Home.    "arrange_tools",    "update_transaction",    "delete_transaction",    "settle_expected",    "set_period",    "set_tag",    "set_person",    "mark_transfer",    // It takes a proof off a record the owner can open.    "remove_evidence",    // A rename, or putting an account away so it stops appearing in lists.    "update_money_account",    // It rewrites a line of the paper Cotton read — a row the owner can open    // and compare against their statement.    "update_statement_line",    // A re-read REPLACES the unbooked lines it re-reads, so a correction the    // owner made by hand to one of them is discarded. A booked line survives,    // which is what keeps the money safe — but "touches nothing that exists" is    // not true of this tool, and claiming it would stop a client asking first.    "read_statement",    "update_note",    "archive_note",    "unarchive_note",    "archive_person",    "unarchive_person",    // Repoints everything the duplicate anchored and archives them — the    // heaviest modify on the surface, preserved (snapshot comment, archive not    // delete) but absolutely one to ask about first.    "merge_people",    "upsert_managed_note",    "resolve_comment",    "file_document",    "update_document",    "delete_document",    "import_package",    "memory_update",    // It rewrites the `position` of a row the owner can see — their own    // arrangement, made by hand and not trivially recovered. The file's history    // trigger deliberately omits `position` (a drag is not an edit to any    // sentence), but that is about what HISTORY records; this hint is about    // whether a client should ask first, and it should.    "memory_reorder",    "memory_archive",    "update_project",    "link_to_project",    "unlink_from_project",    // Photos and videos (schema v31). `update_photo` and `update_video` rewrite    // a caption the owner wrote, or stamp a review note onto a row they will read    // on the Storage screen. `remove_photo` and `remove_video` are the heaviest    // pair on this list: a hard delete of the record AND of the bytes, which is    // the point of them — and the reason each takes one named id and there is no    // batch form.    "update_photo",    "remove_photo",    // v40: the owner's answer about a face rewrites `person_id` and its    // suggestion; a duplicate decision rewrites a proposal's state. Neither    // deletes a picture, but both change a row that is already there.    "update_face",    "decide_duplicate",    "update_video",    "remove_video",    // Albums (schema v42). `decide_album` flips a proposal's state — kept,    // dismissed, or open again — and `update_album` retitles, re-covers and    // adds or removes pictures on a row the person may already have kept.    "decide_album",    "update_album",    // ── 4m: the message-ARCHIVE write surface ───────────────────────    //    // "Destructive" is Anthropic's own rule — a call that MODIFIES or DELETES    // something already in the database — and every verb left here is one:    // hiding and clearing and deleting remove a line or a conversation from    // this copy, and a star, a mute, a pin, an archive and a read cursor all    // rewrite state the person set. None of them appends, which is why    // ADDITIVE carries no chat verb at all.    "hide_chat_messages",    "star_message",    "mark_thread_read",    "mark_thread_unread",    "set_thread_muted",    "set_thread_pinned",    "set_thread_archived",    "clear_thread",    "delete_thread",];fn catalogue() -> HashSet<&'static str> {    TOOLS.iter().map(|tool| tool.name).collect()}fn claimed() -> HashSet<&'static str> {    let mut claimed: HashSet<&'static str> = SHARED_TOOLS.iter().copied().collect();    // The developer tools are a claim of their own — see `surface::DEV_TOOLS`.    claimed.extend(DEV_TOOLS.iter().copied());    for kind in PRIMITIVE_KINDS {        for tool in owned_tools(kind) {            claimed.insert(tool);        }    }    claimed}// ── the developer tools ─────────────────────────────────────────────────────/// RULE: A developer tool is declared by its `dev_` name and by the developer list together, so neither can name one the other does not.#[test]fn the_developer_list_and_the_dev_prefix_name_the_same_six_tools() {    for name in DEV_TOOLS {        assert!(            crate::mcp::protocol::is_dev_tool(name),            "{name} is on the developer list and does not start with the developer prefix"        );        assert!(            catalogue().contains(name),            "{name} is on the developer list and is not a tool"        );    }    let declared: HashSet<&str> = DEV_TOOLS.iter().copied().collect();    for tool in TOOLS {        if crate::mcp::protocol::is_dev_tool(tool.name) {            assert!(                declared.contains(tool.name),                "{} is named as a developer tool and is not on the developer list — add it to \                 surface::DEV_TOOLS",                tool.name            );        }    }}/// RULE: No developer tool is shown to anybody while the server's developer switch is off.////// The switch is the ONLY thing that makes them exist, so the surface a server/// answers by default has to be exactly the surface it answered before they were/// written — for every scope, the owner's own app included, which carries every/// scope there is.#[test]fn no_developer_tool_is_listed_when_the_switch_is_off() {    for granted in [        scopes(&["read"]),        scopes(&["read", "write"]),        scopes(&["owner", "read", "write"]),    ] {        let listed: Vec<String> = tool_catalogue(&granted, false)            .iter()            .filter_map(|entry| entry.get("name").and_then(|name| name.as_str()))            .map(str::to_string)            .collect();        for name in DEV_TOOLS {            assert!(                !listed.contains(&(*name).to_string()),                "{name} is listed on a server whose developer switch is off"            );        }    }}/// RULE: With the developer switch on, every developer tool a caller's scopes cover is listed and nothing else changes.#[test]fn the_switch_adds_exactly_the_developer_tools_and_nothing_else() {    let granted = scopes(&["read", "write"]);    let off: HashSet<String> = tool_catalogue(&granted, false)        .iter()        .filter_map(|entry| entry.get("name").and_then(|name| name.as_str()))        .map(str::to_string)        .collect();    let on: HashSet<String> = tool_catalogue(&granted, true)        .iter()        .filter_map(|entry| entry.get("name").and_then(|name| name.as_str()))        .map(str::to_string)        .collect();    let added: HashSet<String> = on.difference(&off).cloned().collect();    let expected: HashSet<String> = DEV_TOOLS.iter().map(|name| (*name).to_string()).collect();    assert_eq!(        added, expected,        "the switch moved something other than the developer tools"    );    assert!(        off.difference(&on).next().is_none(),        "throwing the switch took a tool away"    );}/// RULE: Revoking a device stays impossible however the developer switch stands.////// It is the one act that decides who may open the database at all, it is/// monotone, and being wrong once is permanent — so the grid's written refusal/// is not something a switch may lift. The developer tools pass the gates a/// person stands at; they do not pass the ones that exist because being wrong/// cannot be undone.#[test]fn no_developer_tool_revokes_a_device_or_erases_a_secret() {    for banned in [        "dev_revoke_device",        "dev_remove_device",        "dev_delete_device",        "dev_erase_workspace",        "dev_empty_bin",        "dev_delete_secret",    ] {        assert!(            !catalogue().contains(banned),            "{banned} exists — a developer tool passes a gate a person stands at, never one that \             cannot be undone"        );    }}// ── the verb grid covers every primitive ────────────────────────────────────/// RULE: The list of tools for each kind of record is compiled from the one registry — one row per kind and nothing extra — so nobody keeps it by hand.#[test]fn one_row_per_primitive_kind_none_extra() {    let mut rows: Vec<&str> = TOOL_SURFACE.iter().map(|(kind, _)| *kind).collect();    let mut kinds: Vec<&str> = PRIMITIVE_KINDS.to_vec();    rows.sort_unstable();    kinds.sort_unstable();    assert_eq!(rows, kinds);}#[test]fn every_cell_names_a_real_tool_or_carries_a_written_refusal() {    let catalogue = catalogue();    for kind in PRIMITIVE_KINDS {        let row = verb_set(kind).unwrap_or_else(|| panic!("{kind} has no row"));        for (verb, cell) in row.verbs() {            match cell {                VerbCell::Tool(name) => assert!(                    catalogue.contains(name),                    "{kind}.{verb} names {name}, which is not in TOOLS"                ),                VerbCell::Not(reason) => assert!(                    reason.trim().len() >= 10,                    "{kind}.{verb}: a refusal needs a written reason"                ),            }        }        for extra in row.also {            assert!(                catalogue.contains(extra),                "{kind}.also names {extra}, which is not in TOOLS"            );        }    }}#[test]fn the_retired_session_inbox_has_no_tool_on_any_verb() {    // RULE (owner, 15 Nov 2026): the session inbox is retired. No tool writes,    // polls, reads or closes a session message; the rows already kept stay,    // and every verb says so in a sentence.    let row = verb_set("session_message").expect("the session_message row");    for cell in [&row.create, &row.list, &row.get, &row.update, &row.remove] {        assert!(cell.refusal().is_some());    }    for gone in [        "send_to_session",        "poll_session_inbox",        "get_session_message",        "update_session_message",    ] {        assert!(            crate::mcp::protocol::tool_by_name(gone).is_none(),            "{gone} is a tool again"        );    }}#[test]fn a_session_is_opened_by_the_owner_in_the_app_or_by_a_session_over_mcp() {    // v31 RETIRES "nothing over MCP starts a session". It was a rule about    // WHO, and a project's    // conversation is a session the owner opened on a Mac they admitted.    let row = verb_set("session").expect("the session row");    assert_eq!(row.create, VerbCell::Tool("create_session"));    assert_eq!(row.get, VerbCell::Tool("get_session"));    // `log_session` did not go anywhere — it moved to `also`, because a log    // records a session that already exists and a create brings one into    // being, and only one of them can hold the cell.    assert!(row.also.contains(&"log_session"));    assert!(row.also.contains(&"open_project_conversation"));    // The owner's own two: where it is filed and what it is called.    assert!(row.also.contains(&"move_session"));    assert!(row.also.contains(&"rename_session"));    // The two writes a session's row still refuses: nothing edits a session's    // state from outside the Mac that runs it, and nothing erases the log.    assert!(row.update.refusal().is_some());    assert!(row.remove.refusal().is_some());}#[test]fn the_launch_queue_and_the_logins_are_the_sessions_surfaces_own() {    // `list_agent_accounts` is gone with the AI-account tables (OPEN TABLES,    // owner, 24 Nov 2026): no surface names it.    let row = verb_set("session").expect("the session row");    assert!(!row.also.contains(&"list_agent_accounts"));    assert!(!SHARED_TOOLS.contains(&"list_agent_accounts"));    // `list_machines` and `forget_machine` are GONE (v14). A machine IS a    // device since v13 and the reading folded onto `cotton_devices`, so    // `list_devices` answers what a Mac is like; nothing forgets a device,    // because revoking one is a confirmed red row in the owner's own app.    let catalogue = catalogue();    for gone in ["list_machines", "forget_machine"] {        assert!(!catalogue.contains(gone), "{gone} is retired");        assert!(!row.also.contains(&gone));    }    // THE LAUNCH QUEUE'S THREE ARE GONE THE SAME WAY (v23). The launch folded    // into the session, so there is no second row for a verb to read or write:    // `list_sessions` answers `queued` rows with the rest, and the Mac that    // runs one claims its own row against its own copy of the file.    for gone in [        "list_launches",        "poll_session_launches",        "update_session_launch",    ] {        assert!(!catalogue.contains(gone), "{gone} is retired");        assert!(!row.also.contains(&gone));        assert!(!SHARED_TOOLS.contains(&gone));    }}// ── the grid and the catalogue agree exactly ────────────────────────────────/// The refusals ARE the device surface (v13). Four written "no"s and one read:/// every write to the device list is a person on a screen, so a grid hole here/// would be a model calling `revoke_device` on the strength of having seen/// `list_devices`.#[test]fn a_device_is_listed_and_never_approved_renamed_or_revoked_by_a_tool() {    let row = verb_set("device").expect("the device row");    assert_eq!(row.list, VerbCell::Tool("list_devices"));    assert_eq!(row.also, &[] as &[&str]);    for (verb, cell) in row.verbs() {        if verb == "list" {            continue;        }        assert!(            matches!(cell, VerbCell::Not(_)),            "{verb} must be a written refusal, not a tool"        );    }    // And nothing in the catalogue offers one under another name. The list is    // every spelling a model would reach for, because the refusal is only    // worth anything if the tool it refuses does not exist somewhere else.    for banned in [        "approve_device",        "create_device",        "pair_device",        "add_device",        "rename_device",        "update_device",        "revoke_device",        "remove_device",        "delete_device",        "forget_device",        "leave_database",        "get_device",    ] {        assert!(            !catalogue().contains(banned),            "{banned} exists, and the device row refuses that verb in writing"        );    }}#[test]fn shared_tools_exist_and_are_not_owned_by_any_primitive() {    let catalogue = catalogue();    for tool in SHARED_TOOLS {        assert!(            catalogue.contains(tool),            "{tool} is shared but not in TOOLS"        );    }}#[test]fn owned_tools_are_pairwise_disjoint_across_primitives() {    let mut owner: HashMap<&str, &str> = HashMap::new();    for kind in PRIMITIVE_KINDS {        for tool in owned_tools(kind) {            if let Some(first) = owner.get(tool) {                panic!("{tool} is claimed by both {first} and {kind} — one primitive owns a tool");            }            owner.insert(tool, kind);        }    }}#[test]fn every_tool_is_owned_by_exactly_one_primitive_or_shared() {    let catalogue = catalogue();    let claimed = claimed();    let mut unclaimed: Vec<&str> = catalogue        .iter()        .copied()        .filter(|t| !claimed.contains(t))        .collect();    unclaimed.sort_unstable();    assert!(        unclaimed.is_empty(),        "a new tool must take a place in TOOL_SURFACE (its primitive's verb or `also`) or \         SHARED_TOOLS: {unclaimed:?}"    );    let mut ghosts: Vec<&str> = claimed        .iter()        .copied()        .filter(|t| !catalogue.contains(t))        .collect();    ghosts.sort_unstable();    assert!(        ghosts.is_empty(),        "the grid names tools the catalogue does not have: {ghosts:?}"    );}#[test]fn a_get_record_cell_names_a_kind_get_record_can_expand() {    // The registry's `addressable` is the APP's flattened surface; the MCP    // expander vocabulary is GET_RECORD_KINDS, deliberately narrower. The grid    // is where the two meet, so the grid must never promise get_record for a    // kind the validator would refuse — and every kind get_record CAN expand    // must answer its get verb with SOME tool, not a refusal.    let expandable: HashSet<&str> = GET_RECORD_KINDS.iter().copied().collect();    for kind in PRIMITIVE_KINDS {        let cell = verb_set(kind).expect("a row").get;        if cell == VerbCell::Tool("get_record") {            assert!(                expandable.contains(kind),                "{kind}.get promises get_record, but GET_RECORD_KINDS refuses the kind"            );        }        if expandable.contains(kind) {            assert!(                cell.tool().is_some(),                "{kind} is in GET_RECORD_KINDS but the grid refuses its get verb"            );        }    }}// ── the tool catalogue's identity ───────────────────────────────────────────#[test]fn gives_every_tool_a_non_empty_title() {    for tool in TOOLS {        assert!(!tool.title.trim().is_empty(), "{}", tool.name);    }}#[test]fn names_every_tool_in_the_mcp_legal_alphabet_at_most_64_chars() {    for tool in TOOLS {        assert!(            !tool.name.is_empty() && tool.name.len() <= 64,            "{}",            tool.name        );        assert!(            tool.name                .bytes()                .all(|b| b.is_ascii_lowercase() || b.is_ascii_digit() || b == b'_'),            "{}",            tool.name        );    }}#[test]fn has_no_duplicate_names() {    assert_eq!(catalogue().len(), TOOLS.len());}// ── tool annotations ────────────────────────────────────────────────────────/// `PRIMITIVE_KINDS` is a hand copy of the registry's own list, and this is/// what makes it a HELD copy.////// It was unheld until 2026-09-20. Nothing compared it to/// `PrimitiveKind::ALL`, and `one_row_per_primitive_kind_none_extra` compares/// the grid to the COPY — so a kind added to the enum would have left a silent/// hole in the verb grid rather than going red, which is the exact failure the/// grid's own doc comment says it exists to prevent. Both directions, and by/// ORDER as well as by membership: the grid is walked in registry order and a/// reordering is a reordered tool list.#[test]fn the_kind_list_is_the_registrys_own() {    let registry: Vec<&str> = cotton_core::constants::PrimitiveKind::ALL        .iter()        .map(|kind| kind.as_str())        .collect();    assert_eq!(        PRIMITIVE_KINDS, registry,        "surface.rs's PRIMITIVE_KINDS and cotton_core::constants::PrimitiveKind::ALL disagree — \         add the kind to the copy AND give it a row in TOOL_SURFACE"    );}#[test]fn claims_no_open_world_every_tool_touches_the_owners_own_file() {    for tool in TOOLS {        assert!(!tool.annotations.open_world_hint, "{}", tool.name);    }}/// RULE: a read-only tool is never destructive — keyed on the ANNOTATION, because a `machines` tool can be a read.#[test]fn marks_a_read_tool_read_only_and_never_destructive() {    for tool in TOOLS.iter().filter(|t| t.annotations.read_only_hint) {        assert!(!tool.annotations.destructive_hint, "{}", tool.name);    }}/// RULE: `read` tools are read-only, `write` and `owner` tools are not; a `machines` tool may be either, because the scope says who may start work on a Mac (`dev_mac_status` reads, `dev_run_on_mac` writes) and the annotation says what the call does.#[test]fn marks_each_scope_read_only_or_not_as_it_must() {    for tool in TOOLS {        match tool.scope {            McpScope::Read => assert!(tool.annotations.read_only_hint, "{}", tool.name),            McpScope::Write | McpScope::Owner => {                assert!(!tool.annotations.read_only_hint, "{}", tool.name);            }            McpScope::Machines => {}        }    }}#[test]fn carries_destructive_hint_exactly_where_the_destructive_set_says() {    let destructive: HashSet<&str> = DESTRUCTIVE.iter().copied().collect();    for tool in TOOLS {        assert_eq!(            tool.annotations.destructive_hint,            destructive.contains(tool.name),            "{}",            tool.name        );    }}// ── toolCatalogue ───────────────────────────────────────────────────────────fn scopes(values: &[&str]) -> Vec<String> {    values.iter().map(|value| (*value).to_string()).collect()}/// RULE: A read/write client sees every non-owner, non-developer tool exactly once, because omitting one hides a capability and including one grants a capability the server did not offer.#[test]fn emits_annotations_on_every_entry_a_client_is_shown() {    let listed = tool_catalogue(&scopes(&["read", "write"]), false);    let expected: HashSet<&str> = TOOLS        .iter()        .filter(|tool| {            tool.scope != McpScope::Owner && !crate::mcp::protocol::is_dev_tool(tool.name)        })        .map(|tool| tool.name)        .collect();    let mut shown = HashSet::new();    for entry in &listed {        let name = entry["name"].as_str().expect("a name");        assert!(shown.insert(name), "{name} is advertised more than once");    }    assert_eq!(shown, expected);    for entry in &listed {        let annotations = entry.get("annotations").expect("annotations");        assert_eq!(            annotations.get("openWorldHint"),            Some(&serde_json::Value::Bool(false))        );        assert!(annotations            .get("readOnlyHint")            .is_some_and(serde_json::Value::is_boolean));        assert!(annotations            .get("destructiveHint")            .is_some_and(serde_json::Value::is_boolean));    }}#[test]fn keeps_a_read_only_catalogue_read_only() {    let listed = tool_catalogue(&scopes(&["read"]), false);    assert!(!listed.is_empty());    for entry in &listed {        let annotations = entry.get("annotations").expect("annotations");        assert_eq!(            annotations.get("readOnlyHint"),            Some(&serde_json::Value::Bool(true))        );        assert_eq!(            annotations.get("destructiveHint"),            Some(&serde_json::Value::Bool(false))        );    }}#[test]fn carries_the_same_annotations_the_definition_holds() {    for entry in tool_catalogue(&scopes(&["read", "write"]), false) {        let name = entry            .get("name")            .and_then(serde_json::Value::as_str)            .expect("a name");        let tool = crate::mcp::protocol::tool_by_name(name).expect("a definition");        assert_eq!(entry.get("annotations"), Some(&tool.annotations.to_json()));        // The catalogue carries no scope bookkeeping of ours.        assert!(entry.get("scope").is_none());        assert!(entry.get("outsideWriteLock").is_none());    }}/// **NO TOOL OF ANY NAME WRITES TO A REPOSITORY, AND THE GUARD IS THE GRID.**////// This holds the five rows themselves: every verb but `list` and `get` is a/// written refusal (all five are, while the code tables are held as retired),/// every tool the rows DO name is `McpScope::Read` and `read_only_hint`, and/// nothing was added under `also`. A write tool added to any of these kinds has/// to come through one of those, whatever it is called.#[test]fn nothing_in_the_grid_writes_to_a_repository_whatever_it_would_be_called() {    for kind in ["repository", "pull", "issue", "repo_comment", "release"] {        let row = verb_set(kind).unwrap_or_else(|| panic!("{kind} has a row"));        assert_eq!(row.also, &[] as &[&str], "{kind} owns no sixth verb");        for (verb, cell) in row.verbs() {            match verb {                "list" | "get" => {}                _ => assert!(                    matches!(cell, VerbCell::Not(_)),                    "{kind}'s `{verb}` is a tool — a write to a repository is a route the \                     serving Mac performs, never an MCP verb"                ),            }            // AND EVERY TOOL THESE ROWS DO NAME ONLY READS. A grid cell that            // said `list` while the tool behind it wrote would be the same            // hole by another door.            if let Some(name) = cell.tool() {                let tool = TOOLS                    .iter()                    .find(|tool| tool.name == name)                    .unwrap_or_else(|| panic!("{kind}.{verb} names `{name}`, which is no tool"));                assert_eq!(tool.scope, McpScope::Read, "{name} is not a read");                assert!(tool.annotations.read_only_hint, "{name} is not read-only");                assert!(!tool.annotations.destructive_hint, "{name} is destructive");            }        }    }}/// RULE: Retired Stores cannot return through Home, definitions, starter kits or MCP, and no definition revives the retired commerce storage./// The Stores tool was removed on 11 Oct 2026; the schema fold preserves/// its old rows in notes. This guards that retirement, not the word order.#[test]fn no_new_database_shows_stores() {    const STORE_VERBS: &[&str] = &[        "create_store",        "update_store",        "get_store",        "list_stores",        "record_order",        "list_orders",        "update_order",        "create_product",        "update_product",        "remove_product",        "store_report",    ];    // The four tables the Stores tool kept, dropped at schema 105.    const STORE_TABLES: [&str; 4] = ["cotton_stores", "cotton_products", "cotton_product_images", "cotton_orders"];    for definition in cotton_core::definitions::builtin_table_definitions() {        assert!(!["store", "product"].contains(&definition.id.as_str()), "{} is a built-in again", definition.id);        assert!(!definition.tables.iter().flatten().any(|table| STORE_TABLES.contains(&table.name.as_str())), "{} revives retired commerce storage", definition.id);        let key = definition.tool.as_ref().and_then(|home| home.key.clone()).unwrap_or_else(|| definition.id.clone());        assert_ne!(key, "stores", "{} is homed as Stores", definition.id);    }    for kit in cotton_core::toolkits::shipped() {        assert!(!kit.tools.iter().any(|tool| tool.key() == "stores"), "kit {} carries Stores", kit.id);    }    let offered: Vec<&str> = TOOLS.iter().map(|tool| tool.name).filter(|name| STORE_VERBS.contains(name)).collect();    assert!(offered.is_empty(), "the catalogue offers store verbs again: {offered:?}");}