//! The retired vocabulary, declared once (the owner's ruling, 2026-08-27://! [product-language-must-be-plain-software-tool-terms-everywhere-us]).//!//! Fifteen terms — twelve retired metaphors, plus three sentences the product//! must never say — and the plain word each one is replaced by. Two guards//! sweep with this table: the catalog sweep//! (`scripts/__tests__/plainLanguage.test.ts`, every user-visible string the//! app ships, plus the AGENTS.md partials and the generator) and the MCP sweep//! (`crates/cotton-tools/src/mcp/language_tests.rs`, every tool name, title,//! description and parameter). They used to keep four patterns and six,//! spelled differently — so `seats`, `nudges`, `laws`, "the box" and "the//! mark" were banned in prose nobody reads and free in every sentence a person//! sees.//!//! THE PATTERNS ARE AS NARROW AS THE RULE IS. Three of the twelve share a word//! with ordinary English the product genuinely says: "Mark read", "there isn't//! room to record", "unpack the archive". The dictionary's own phrasing is what//! makes the narrow form correct — it retires "the mark", "the box" and "the//! pack" as NAMES for the logo, the host and the briefing, not the words. A//! bare `\bmark\b` would fail eight honest strings and teach the next person to//! add an exception list instead of a better pattern.//!//! # What the port had to decide//!//! [`RetiredTerm::pattern`] carries the JavaScript SOURCE verbatim — the text//! between the slashes in `retiredTerms.ts` — and [`retired_regex`] is the one//! place that turns it into a Rust `Regex`. Two flags come with it and both//! matter://!//! - `i`, because every declared pattern carries it; and//! - `-u`, because a JavaScript regex WITHOUT the `u` flag matches on the ASCII//! word class and folds case only within ASCII, while Rust's `regex` is//! Unicode by default. The two disagree on real text: `édoor` and `seatÉ` are//! both hits in JavaScript (an accented letter is a NON-word character to an//! ASCII `\b`, so the boundary is there) and neither is a hit under a Unicode//! `\b`. `(?i-u)` reproduces the declaration exactly; the vectors in//! `retired_terms_tests.rs` pin both spellings against Node.//!//! Everything else — the slugs, the sentences, the order — is the TypeScript's.use std::sync::LazyLock;use regex::Regex;/// A retired word, and the plain one to say instead.#[derive(Debug, Clone, Copy, PartialEq, Eq)]pubstructRetiredTerm {/// Stable id, so a test can assert coverage without matching prose.pub slug: &'static str,/// The JavaScript pattern SOURCE, byte for byte as `retiredTerms.ts`/// declares it. The `i` and `-u` flags live in [`retired_regex`], because a/// flag repeated thirteen times is a flag that goes missing once.pub pattern: &'static str,/// What to say instead — this is the message a failing guard prints.pub instead: &'static str,}implRetiredTerm {/// Whether this term's pattern is anywhere in `text`.////// A declared term reads its regex out of the compiled-once table; anything/// else is compiled on the spot, so a caller holding a term of its own gets/// the same answer rather than a panic.pubfn matches(&self, text: &str) -> bool {match RETIRED_TERMS_STRICT .iter() .position(|term| term.pattern == self.pattern) {Some(index) => COMPILED[index].is_match(text),None => retired_regex(self.pattern).is_match(text), } }}/// The one translation from a JavaScript pattern to a Rust one — `(?i-u)` in/// front of the declared source, and nothing else.////// A pattern that will not compile is a declaration bug, not a runtime/// condition: there is nothing sensible to answer, and a guard that silently/// matched nothing would be worse than a loud failure on the first call. The/// panic names the pattern.pubfn retired_regex(pattern: &str) -> Regex {Regex::new(&format!("(?i-u){pattern}")) .unwrap_or_else(|error| panic!("retired term /{pattern}/ does not compile — {error}"))}// The declared vocabulary is the list at the end of this file, above its// tests, and this module owns it since step 5i folded in the file that was// generated.//// Hand-typing these was a real bug for a day: the copy rendered for// `cotton-server` carried `(?i)` where the declaration means `(?i-u)`, and// nothing could have caught the disagreement because both sides looked right// on their own. Whichever copy is hand-typed is the copy that drifts — so// there is one, and it is below. `retired_terms_tests.rs` asserts the// relationship between the two tables, which is what a hand edit gets wrong.//// Plain comments, not doc comments: with the re-export they documented gone,// a `///` block here would silently attach itself to the next item down./// Compiled once, in [`RETIRED_TERMS_STRICT`] order.static COMPILED: LazyLock<Vec<Regex>> = LazyLock::new(|| { RETIRED_TERMS_STRICT .iter() .map(|term| retired_regex(term.pattern)) .collect()});/// Every retired term `text` trips, in declared order.////// The TypeScript spells this as a `filter` at each of its four call sites;/// one function is what keeps the four asking the same question.pubfn violations_in(text: &str) -> Vec<&'staticRetiredTerm> { RETIRED_TERMS .iter() .filter(|term| term.matches(text)) .collect()}/// [`violations_in`], against the stricter dictionary.pubfn strict_violations_in(text: &str) -> Vec<&'staticRetiredTerm> { RETIRED_TERMS_STRICT .iter() .filter(|term| term.matches(text)) .collect()}// ---------------------------------------------------------------------------// The declared vocabulary, and this file is where a word is retired.//// It was generated from `packages/core/src/language/retiredTerms.ts` until step// 5i deleted that package (R18). Four sweeps derive from what is below — the// Rust one here, the two apps' Swift through `cotton-gen`, and// `scripts/__tests__/plainLanguage.test.ts` through the emitted// emitted JSON, which `emit_json_tests.rs` writes and diffs. Adding a// term retires it on every one of them at once, which is the whole point.//// The patterns are JavaScript SOURCE with no flags: `retired_regex` puts// `(?i-u)` in front of every one, because a `/…/i` declared without `u` folds// case and matches `\b`/`\w` against the ASCII classes, and Rust's `regex`// does neither by default.// ---------------------------------------------------------------------------/// The 15: the TypeScript's fourteen in its declared order, and the retired/// hosted-database sentences after them — this file is where a term is retired/// now, so a new one is declared at the end rather than woven into an order/// nothing else keeps.pubconst RETIRED_TERMS: [RetiredTerm; 15] = [RetiredTerm { slug: "door", pattern: r#"\bdoors?\b"#, instead: "say \"the server\"", },RetiredTerm { slug: "shelf", pattern: r#"\bshel(f|ves)\b"#, instead: "say \"project\"", },RetiredTerm { slug: "the-memory-room", pattern: r#"\bmemory room\b"#, instead: "say \"memory\"", },RetiredTerm { slug: "room", pattern: r#"\bthe rooms?\b|\b(People|Notes|Todos) room\b"#, instead: "say \"tool\", or name it", },RetiredTerm { slug: "your-file", pattern: r#"\byour file\b|\blife file\b|\bCotton file\b"#, instead: "say \"your database\"", },RetiredTerm { slug: "pack", pattern: r#"\bthe packs?\b"#, instead: "say \"the briefing\"", },RetiredTerm { slug: "box", pattern: r#"\bthe box(es)?\b"#, instead: "say \"the host\"", },RetiredTerm { slug: "mark", pattern: r#"\bthe marks?\b"#, instead: "say \"the logo\"", },RetiredTerm { slug: "seat", pattern: r#"\bseats?\b"#, instead: "say \"participant\"", },RetiredTerm { slug: "nudge", pattern: r#"\bnudges?\b"#, instead: "say \"trigger\"", },RetiredTerm { slug: "law", pattern: r#"\blaws?\b"#, instead: "say \"decision\" or \"rule\"", },RetiredTerm { slug: "canon", pattern: r#"\bcanons?\b"#, instead: "say what it is plainly", },RetiredTerm { slug: "life-record", pattern: r#"\blife records?\b"#, instead: "say \"records\", or \"your data\"", },RetiredTerm { slug: "model-on-device", pattern: r#"\bAI runs on your\b"#, instead: "never say where the model runs — say what the database does, and that any assistant can use it", },// THE HOSTED MULTI-ACCOUNT DATABASE, which is retired. There is no shared// database, no account row and no row-level policy: the data plane is ONE// SQLite file per person, on the Mac that holds it, opened for the devices// that server has admitted. The privacy sheet said the first thing for a// year after the second stopped being true, which is a legal document// describing somebody else's architecture.RetiredTerm { slug: "row-level-security", pattern: r#"\brow[- ]level security\b|\ban account can only\b|\beveryone else shares one\b|\bper-account security\b"#, instead: "say what is true — one database file per person, on the Mac that holds it, opened only for the devices it has admitted", },];/// Stricter, for sources that never talk about disk space or about marking a/// message read: a bare `room` here is always the retired metaphor — which is/// what "room block not rendered" was, and what the narrow pattern above would/// let straight through.////// The first 14 entries are [`RETIRED_TERMS`] by index, not by copy, because/// Rust cannot spread one `const` array into another and two hand-listed/// copies would be free to disagree.pubconst RETIRED_TERMS_STRICT: [RetiredTerm; 16] = [ RETIRED_TERMS[0], RETIRED_TERMS[1], RETIRED_TERMS[2], RETIRED_TERMS[3], RETIRED_TERMS[4], RETIRED_TERMS[5], RETIRED_TERMS[6], RETIRED_TERMS[7], RETIRED_TERMS[8], RETIRED_TERMS[9], RETIRED_TERMS[10], RETIRED_TERMS[11], RETIRED_TERMS[12], RETIRED_TERMS[13], RETIRED_TERMS[14],RetiredTerm { slug: "room-bare", pattern: r#"\brooms?\b"#, instead: "say \"memory\", \"project\", or name the tool", },];#[cfg(test)]#[path = "retired_terms_tests.rs"]mod tests;