Skip to content
Back to search

ru-text

MarketplaceWorks with Claude CodeGitHubIncomplete

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/talkstream--ru-text/badge.svg)](/listings/talkstream--ru-text)

HTML

<a href="/listings/talkstream--ru-text"><img src="/api/listings/talkstream--ru-text/badge.svg" alt="findsafeskills safety rating" /></a>

Install

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Дайте эту фразу своему ИИ-агенту:

> Установи навык https://github.com/talkstream/ru-text глобально и вызывай его, когда работа идёт над качеством русского текста: вычитка, типографика, очистка от нейрослопа, редактура, UX-тексты, деловая переписка — или по прямому упоминанию ru-text.

Обычно этого достаточно: где его площадка держит навыки, агент знает лучше, чем инструкция, написанная год назад. Работает в Claude Code, Codex и ChatGPT, Cursor, GitHub Copilot, Gemini CLI, Google Antigravity, Windsurf, Continue.dev, Cline, JetBrains Junie, OpenClaw и Notion.

Если привычнее команда — навык ставят два установщика: `npx skills add talkstream/ru-text` кладёт в проект все три навыка, `npx skillsbd add talkstream/ru-text/ru-text` — один, в свой каталог. Подробности и флаги — в [INSTALL.md](INSTALL.md#одной-командой).

В ChatGPT эта фраза не нужна — там есть карточка в каталоге плагинов:

Откройте её и нажмите «плюс». Навык станет доступен в ChatGPT — в браузере, в десктопном приложении и на телефоне. В Codex он работает внутри того же десктопного приложения; в Codex CLI его ставит фраза выше.

Агент подхватывает навыки при старте сессии, поэтому начните новую. Проверьте на живом тексте: дайте агенту абзац и попросите «вычитай». В ответе придут исправленный вариант и список правок. Списка нет — навык не поднялся, смотрите [INSTALL.md](INSTALL.md).

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

.claude-plugin/marketplace.json · Manifest · 32 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. {
  2. "name": "ru-text",
  3. "metadata": {
  4. "description": "Russian text quality for AI agents — neuroslop cleanup, typography, information style, editorial standards, UX writing, business correspondence. Scores text 0–10. 2,000+ linguistic atoms.",
  5. "version": "2.10.10"
  6. },
  7. "owner": {
  8. "name": "Arseniy Kamyshev",
  9. "email": "nafigator@gmail.com",
  10. "url": "https://t.me/nafigator"
  11. },
  12. "plugins": [
  13. {
  14. "name": "ru-text",
  15. "displayName": "ru-text",
  16. "source": "./",
  17. "version": "2.10.10",
  18. "description": "Russian text quality for AI agents — neuroslop cleanup, typography, information style, editorial standards, UX writing, business correspondence. Scores text 0–10. 2,000+ linguistic atoms.",
  19. "category": "productivity",
  20. "homepage": "https://github.com/talkstream/ru-text",
  21. "tags": [
  22. "russian",
  23. "neuroslop",
  24. "ai-text-detection",
  25. "typography",
  26. "editorial",
  27. "ux-writing",
  28. "text-quality"
  29. ]
  30. }
  31. ]
  32. }
README.md · README · 168 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # ru-text
  2. [![Version](https://img.shields.io/github/v/release/talkstream/ru-text?label=version&color=2ea44f)](https://github.com/talkstream/ru-text/releases/latest) [![License](https://img.shields.io/github/license/talkstream/ru-text?label=license&color=blue)](LICENSE) [![GitHub stars](https://img.shields.io/github/stars/talkstream/ru-text?style=flat&label=stars)](https://github.com/talkstream/ru-text)
  3. [English](README.en.md) · [Установка](INSTALL.md) · [Что изменилось](CHANGELOG.md) · [Источники](skills/ru-text/references/sources.md)
  4. ИИ-агент уже записывает ваши мысли по-русски, и это видно: прямые кавычки вместо ёлочек, дефис вместо тире, «в целях повышения эффективности», «Отличный вопрос!». Мысль ваша, а звучит как машина.
  5. ru-text — навык вычитки русского текста для ИИ-агентов. Он работает внутри агента и чистит это по ходу дела: типографику, канцелярит и 17 признаков машинного текста (нейрослоп). На каждую правку даёт цитату и правило, по которому она сделана.
  6. Ваши слова, стиль и тон он не трогает: это не ошибки. И ваш файл он не перепишет, пока вы сами не попросите.
  7. ## Установка
  8. Дайте эту фразу своему ИИ-агенту:
  9. > Установи навык https://github.com/talkstream/ru-text глобально и вызывай его, когда работа идёт над качеством русского текста: вычитка, типографика, очистка от нейрослопа, редактура, UX-тексты, деловая переписка — или по прямому упоминанию ru-text.
  10. Обычно этого достаточно: где его площадка держит навыки, агент знает лучше, чем инструкция, написанная год назад. Работает в Claude Code, Codex и ChatGPT, Cursor, GitHub Copilot, Gemini CLI, Google Antigravity, Windsurf, Continue.dev, Cline, JetBrains Junie, OpenClaw и Notion.
  11. Если привычнее команда — навык ставят два установщика: `npx skills add talkstream/ru-text` кладёт в проект все три навыка, `npx skillsbd add talkstream/ru-text/ru-text` — один, в свой каталог. Подробности и флаги — в [INSTALL.md](INSTALL.md#одной-командой).
  12. В ChatGPT эта фраза не нужна — там есть карточка в каталоге плагинов:
  13. [![Установить в ChatGPT и Codex](https://img.shields.io/badge/%D0%A3%D1%81%D1%82%D0%B0%D0%BD%D0%BE%D0%B2%D0%B8%D1%82%D1%8C_%D0%B2_ChatGPT_%D0%B8_Codex-000000?style=for-the-badge)](https://chatgpt.com/plugins/plugins_6a6b66a0142c81918659256b4a12adba)
  14. Откройте её и нажмите «плюс». Навык станет доступен в ChatGPT — в браузере, в десктопном приложении и на телефоне. В Codex он работает внутри того же десктопного приложения; в Codex CLI его ставит фраза выше.
  15. Агент подхватывает навыки при старте сессии, поэтому начните новую. Проверьте на живом тексте: дайте агенту абзац и попросите «вычитай». В ответе придут исправленный вариант и список правок. Списка нет — навык не поднялся, смотрите [INSTALL.md](INSTALL.md).
  16. ## Как это выглядит в работе
  17. Каждый день — три коротких действия.
  18. **Пишете сами — просите вычитать.** «Вычитай это письмо». Вернётся исправленный текст и список: что заменено и по какому правилу. Согласиться можно не со всем, правило названо и спорить есть с чем.
  19. **Пишет агент — он чистит на ходу.** В тексте, который агент пишет сам, типографику навык ставит молча: кавычки, тире, неразрывные пробелы. Это норма языка, и сообщать о ней нечего.
  20. **Перед публикацией — просите балл.** «Оцени этот текст по ru-text»: 0–10 по пяти шкалам, к каждому замечанию — цитата и правило. Балл можно проверить построчно и оспорить.
  21. Рубрика печатает и то, чего она не мерила: фактическую точность, попадание в аудиторию, авторский голос, оригинальность, эффективность, соответствие брифу. Голос в балл не входит: 8,0 у осторожного текста и 8,0 у резкого значат одно и то же.
  22. Два верхних ярлыка, «Эталонный» и «Хороший», не достаются документу, который остался стенограммой чата или писался для поисковика: такой текст бывает чист в каждой фразе и бесполезен целиком.
  23. В Claude Code у этих действий есть команды: `/ru-text:ru-check` — разбор с правилом на каждую находку, `/ru-text:ru-score` — балл. На остальных площадках достаточно слов. Команда `/ru-text:ru-check` идёт на последней версии Sonnet; если Sonnet вам недоступен, переключитесь на последнюю версию Opus (`/model opus`) — подробности в [INSTALL.md](INSTALL.md#claude-code).
  24. ## Что он ловит
  25. Ловить модель по словарю бесполезно: словарь у неё наш. Выдаёт её манера. Она хвалит ваш вопрос и спорит с тем, чего никто не говорил.
  26. Вот пять предложений, в которых нет ни одного факта:
  27. > Отличный вопрос! Сейчас всё объясню — коротко, без воды и по делу. Скажу честно: тут есть нюанс. Давайте разберёмся, как это работает. Дело не в скорости, а в предсказуемости.
  28. Тот же ответ, когда автору есть что сказать:
  29. > Под нагрузкой система замедляется предсказуемо: очередь растёт линейно до 800 запросов в секунду, дальше отказы. Вот замеры.
  30. Приёмы по порядку:
  31. - «Отличный вопрос!» — сервисная реплика ассистента;
  32. - «коротко, без воды и по делу» — похвала себе за краткость;
  33. - «скажу честно» — объявленная искренность;
  34. - «давайте разберёмся» — пустой зачин;
  35. - «дело не в скорости, а в предсказуемости» — ложная антитеза: отрицается то, чего никто не утверждал.
  36. Первый вариант я вижу каждый день — в чужих README и в своих черновиках. Он читается гладко и ничего не сообщает.
  37. Прежде чем сделать замечание, навык смотрит оговорки. В цитате, в разборе чужого текста и в юридической формуле приём законен. А триада, любимый у модели ритм из трёх, законна, когда элементов правда три.
  38. Всего таких признаков 17. Два предъявляются документу целиком, потому что правкой на месте не лечатся: текст, оставшийся стенограммой диалога с нейросетью, и текст, который писали под поисковый запрос.
  39. Канцелярит навык разбирает так же: «в целях повышения эффективности взаимодействия» становится «чтобы отделы работали быстрее», «осуществляется контроль» — «следит Петрова». Отглагольные существительные снова становятся глаголами, у безличного контроля появляется фамилия. Фактов навык не сочиняет: фамилию он спросит у вас.
  40. Кроме прозы он знает интерфейсы и переписку: кнопка называет действие — «Отмена» вместо «Нет»; ошибка говорит, что случилось и что делать дальше; тема письма начинается с дела; «довожу до сведения» разворачивается в «сообщаю».
  41. В лендинге и документации вместо «команды профессионалов» встаёт то, что можно проверить, вывод поднимается наверх, а ссылка говорит, куда ведёт.
  42. ## Что решаете вы
  43. **Правила уступают вашей просьбе.** Скажете «пиши разговорно» — будет разговорно. Академический, юридический, SEO, литературный — то же. Это умолчания, ваша прямая просьба их отменяет.
  44. **Мандат выдаёте вы.** Фраза установки просит вызывать навык, когда работа идёт над качеством русского текста или когда вы прямо упоминаете ru-text. Нужен мандат поуже: «вызывай ru-text, только когда я прошу вычитку». Нужен пошире: «вызывай ru-text на любом русском тексте». Агент исполняет вашу формулировку.
  45. **Ничего не переписывается молча.** При проверке навык возвращает исправленный вариант и список изменений; правит файл, только если вы прямо об этом попросили.
  46. **Чужой текст остаётся чужим.** Цитаты, код, чужие фрагменты внутри вашего документа воспроизводятся как есть: замечание — возможно, правка — никогда.
  47. **Выключается одной командой.** В Claude Code — `/plugin`; на остальных площадках удалите каталог навыка.
  48. ## Сколько это стоит контекста
  49. ru-text не гоняет корпус целиком на каждый абзац: это было бы расточительством за ваш счёт.
  50. Постоянно в контексте висит один файл (4 килобайта): таблица типографики и верхушка стоп-слов. Справочники лежат рядом и подгружаются, когда до них доходит дело. Скажете «вычитай» — навык читает весь корпус.
  51. Когда агент проверяет себя сам, идёт быстрый проход: типографика и стоп-слова — то, что решается по одной строке. Наберётся пять замечаний или мелькнёт след машинного текста — проход сам разворачивается в полную вычитку. Признаки машинного текста он не судит: у каждого есть оговорка, где приём законен, а оговорки живут только в полном справочнике. И полной вычиткой быстрый проход себя никогда не называет.
  52. ## Корпус
  53. Более 2 000 лингвистических атомов: правил, пар «плохо → хорошо», словарных статей и исключений. Это пол, а не точное число, и он считается командой:
  54. ```bash
  55. tools/extract-atoms.sh skills/ru-text | wc -l
  56. ```
  57. Раньше я вписывал это число руками, оно разъехалось по девяти файлам, и в записи о правке я ошибся даже в числе файлов. Теперь его печатает скрипт.
  58. Корпус лежит в 10 справочниках, они подгружаются по запросу. Откройте любой и посчитайте правила сами.
  59. - [`typography.md`](skills/ru-text/references/typography.md) — кавычки, тире, неразрывные пробелы, разрядка чисел, сокращения
  60. - [`info-style.md`](skills/ru-text/references/info-style.md) — каталог из 92 стоп-слов, структура текста, факты вместо оценок
  61. - [`editorial-punctuation.md`](skills/ru-text/references/editorial-punctuation.md) — сложные предложения, запятые-ловушки, вводные слова
  62. - [`editorial-grammar.md`](skills/ru-text/references/editorial-grammar.md) — согласование, плеоназмы, управление, деепричастия, омофоны
  63. - [`ux-writing.md`](skills/ru-text/references/ux-writing.md) — кнопки, ошибки, пустые состояния, формы, уведомления, диалоги подтверждения
  64. - [`business-writing.md`](skills/ru-text/references/business-writing.md) — письма, мессенджеры, тон, заметки к встречам
  65. - [`anti-patterns.md`](skills/ru-text/references/anti-patterns.md) — пары «плохо → хорошо» по степени серьёзности
  66. - [`addenda.md`](skills/ru-text/references/addenda.md) — 17 признаков машинного текста с оговорками и правило о капслоке
  67. - [`scoring.md`](skills/ru-text/references/scoring.md) — рубрика оценки: измерения, веса, нижние границы
  68. - [`sources.md`](skills/ru-text/references/sources.md) — источники и атрибуция
  69. ## Что нового в 2.10
  70. Эта версия освежает README и собирает в одном месте главное из версий 2.4–2.9.
  71. - **Разбор в Claude Code идёт на Sonnet.** В `SKILL.md` команды `/ru-text:ru-check` записаны `model: sonnet` и `effort: medium`, и он велит читать справочники по прямому пути; поиск остался запасным ходом.
  72. - **Процент в общем и веб-тексте пишется слитно с числом:** `100%`, а не `100 %`. Обычный пробел разрешает перенос, и знак может уехать в начало следующей строки. Правило стоит в постоянной таблице. Типографика самих инструкций (например, шаблона с `100 %`) — привычка, а не просьба о стиле.
  73. - **Многоточие внутри предложения ставится без пробела перед ним и с пробелом после.** В начале и в конце предложения многоточие примыкает к слову без пробела. Пропуск в цитате набирается так же, как пауза. Противоречие двух правил о многоточии снято.
  74. - **Разряды и десятичная запятая больше не спорят.** В `1,500,000` две запятые: они уходят, встают пробелы. Одиночную запятую правило снимать запрещает: это может быть десятичная дробь.
  75. - **Точка после единицы измерения остаётся, когда на ней кончается предложение:** «Вес 5 кг.» не сливается со следующей фразой.
  76. - **Неразрывный пробел ставится после всех восьми однобуквенных слов:** в, к, с, о, у, и, а, я. Краткие пересказы правила теряли «я», теперь проверка репозитория сверяет их с правилом.
  77. - **Запись таблицы плеоназмов — находка, а не автоправка.** Лишнее слово может нести противопоставление, и тогда его удаление меняет смысл.
  78. Полный список — в [CHANGELOG](CHANGELOG.md).
  79. ## Обновление
  80. У разовой установки нет механизма обновления: агент поставил навык и забыл о нём. Сигнал один — релизы репозитория: Watch → Custom → Releases. Когда придёт письмо, попросите агента обновить навык. Повторять команду копирования из установки бесполезно: она не обновляет, а вкладывает новую версию внутрь старой. Команды для каждой площадки — в [INSTALL.md](INSTALL.md#обновление).
  81. В community-маркетплейсе Claude Code ru-text отстаёт от свежей версии на месяцы. Установленную версию покажет `claude plugins list`; если она старая, поставьте навык копированием: три команды в [INSTALL.md](INSTALL.md#общий-каталог).
  82. ## Источники и благодарности
  83. Эти книги, гайды и инструменты научили меня работать с русским текстом. Если ru-text экономит вам время — купите эти книги и пользуйтесь этими инструментами.
  84. **Типографика и вёрстка.** Артём Горбунов, «Типографика и вёрстка» · [Советы Бюро Горбунова](https://bureau.ru/soviet/) · А. Э. Мильчин, Л. К. Чельцова, «Справочник издателя и автора» · [Типографская раскладка Ильи Бирмана](https://ilyabirman.ru/typography-layout/) · [Журнал Type.today](https://type.today)
  85. **Информационный стиль.** Максим Ильяхов, «Пиши, сокращай» и «Ясно, понятно» · [Редполитика Т—Ж](https://journal.tinkoff.ru/manual/) · [Гайды Контура](https://guides.kontur.ru) · [Яндекс Gravity UI](https://gravity-ui.com)
  86. **Язык и письмо.** Артемий Лебедев, «[Ководство](https://www.artlebedev.ru/kovodstvo/)» · Нора Галь, «[Слово живое и мёртвое](http://lib.ru/TRANSLATORS/NORA_GAL/slowo.txt)» · справочники Д. Э. Розенталя · М. Ильяхов, Л. Сарычева, «Новые правила деловой переписки» · [UX-практики Ozon](https://habr.com/ru/companies/ozontech/articles/821383/) · ГОСТ Р 7.0.12-2011 и ГОСТ 7.12-93
  87. Полный список и вклад каждого источника — в [`sources.md`](skills/ru-text/references/sources.md). Рядом стоят и инструменты: [Главред](https://glvrd.ru), [Типограф Лебедева](https://www.artlebedev.ru/typograf/), [Орфограммка](https://orfogrammka.ru).
  88. ## Правовая справка
  89. ru-text — самостоятельное авторское произведение Арсения Камышева. Правила в нём — то, как автор понимает стандарты русской типографики и редактуры; это понимание сложилось за годы практики и чтения перечисленных источников. Формулировки оригинальные, дословных цитат нет. Сами принципы (правила типографики, нормы грамматики, приёмы редактуры) авторским правом не охраняются: ст. 1259(5) ГК РФ, 17 USC §102(b), Бернская конвенция.
  90. Авторы и издатели перечисленных источников этот навык не одобряли и не рецензировали. Ссылки — для удобства читателя. Названия продуктов принадлежат их правообладателям.
  91. ## Автор
  92. Арсений Камышев — [nafigator@gmail.com](mailto:nafigator@gmail.com) · [Telegram](https://t.me/nafigator) · [GitHub](https://github.com/talkstream)
  93. Дальше хочу телеграм-бота и расширение для браузера. Идеи и замечания — в [issues](https://github.com/talkstream/ru-text/issues) или [обсуждениях](https://github.com/talkstream/ru-text/discussions). Нашли неверное правило? Напишите: корпус растёт и от таких находок. В CHANGELOG я ставлю имя автора находки.
  94. Если ru-text сэкономил вам время на вычитке — [GitHub Sponsors](https://github.com/sponsors/talkstream).
  95. [MIT](LICENSE) · [Политика конфиденциальности](PRIVACY_POLICY.md) · навык не делает сетевых запросов и не собирает данные. Эта страница вычитана текущей версией ru-text.
tools/selftest-check-private.sh · Bundled script · 108 lines
  1. #!/bin/sh
  2. # selftest-check-private.sh — proves check-private.sh reds, and reds for the right reason.
  3. #
  4. # A gate nobody has seen fail is a gate nobody knows works. This one guards an irreversible
  5. # event — an identifier of the private contour reaching a public commit — so «it passed on a
  6. # clean tree» is worth nothing on its own: a script that always prints PASS passes too.
  7. #
  8. # Each case plants ONE identifier into a throwaway clone and asserts that the run fails AND
  9. # that the label naming that class appears. Asserting only the exit code would let a single
  10. # over-broad pattern cover for six missing ones.
  11. set -eu
  12. export LC_ALL=C
  13. ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
  14. GATE="$ROOT/tools/check-private.sh"
  15. WORK=$(mktemp -d)
  16. trap 'chmod -R u+w "$WORK" 2>/dev/null || true; find "$WORK" -mindepth 1 -delete 2>/dev/null || true' EXIT INT TERM
  17. pass=0
  18. fail=0
  19. # A minimal git tree: the gate walks tracked files, so the fixture must be a repository.
  20. prepare() {
  21. d="$WORK/case"
  22. find "$d" -mindepth 1 -delete 2>/dev/null || true
  23. mkdir -p "$d/tools"
  24. cp "$GATE" "$d/tools/check-private.sh"
  25. printf '# ru-text\n\nПравила русского текста.\n' > "$d/README.md"
  26. ( cd "$d" && git init -q && git add -A && git -c user.email=t@t -c user.name=t commit -qm init )
  27. }
  28. # case <name> <text to plant> <label that must appear>
  29. case_run() {
  30. name="$1"; text="$2"; want="$3"
  31. prepare
  32. printf '%s\n' "$text" >> "$d/README.md"
  33. ( cd "$d" && git add -A && git -c user.email=t@t -c user.name=t commit -qm plant )
  34. out=$(sh "$d/tools/check-private.sh" "$d" 2>&1) && rc=0 || rc=$?
  35. if [ "$rc" = "0" ]; then
  36. printf 'FAIL %-34s — gate PASSED with the identifier present\n' "$name"
  37. fail=$((fail + 1))
  38. return
  39. fi
  40. if printf '%s' "$out" | grep -q "FAIL $want"; then
  41. printf 'ok %-34s — reds as «%s»\n' "$name" "$want"
  42. pass=$((pass + 1))
  43. else
  44. printf 'FAIL %-34s — red, but not as «%s»\n' "$name" "$want"
  45. printf '%s\n' "$out" | sed 's/^/ /'
  46. fail=$((fail + 1))
  47. fi
  48. }
  49. echo "selftest: check-private.sh"
  50. echo
  51. # The control comes first: without it, every case below could be passing because the gate
  52. # reds on everything.
  53. prepare
  54. if sh "$d/tools/check-private.sh" "$d" >/dev/null 2>&1; then
  55. printf 'ok %-34s — clean tree passes\n' "control"
  56. pass=$((pass + 1))
  57. else
  58. printf 'FAIL %-34s — clean tree already reds\n' "control"
  59. fail=$((fail + 1))
  60. fi
  61. # ⚠ The second control is the one that keeps this gate usable. The public repository
  62. # legitimately talks ABOUT the paid service; if that reddened the gate, the gate would be
  63. # switched off within a week. The deny-list is identifiers, and this case proves it.
  64. prepare
  65. printf 'Этот раздел заморожен ради контракта с платным сервисом ru-text MCP.\n' >> "$d/README.md"
  66. ( cd "$d" && git add -A && git -c user.email=t@t -c user.name=t commit -qm topic )
  67. if sh "$d/tools/check-private.sh" "$d" >/dev/null 2>&1; then
  68. printf 'ok %-34s — the SUBJECT of the paid service is allowed\n' "topic control"
  69. pass=$((pass + 1))
  70. else
  71. printf 'FAIL %-34s — gate reds on the mere topic\n' "topic control"
  72. fail=$((fail + 1))
  73. fi
  74. # ⚠ Every planted value below is a STAND-IN, and that is the point of this block. The first
  75. # draft of this file planted the real ones — the actual repository name, the actual service
  76. # host, the actual server address — and a background security review flagged it as
  77. # infrastructure disclosure inside the very commit meant to prevent that. Nothing had been
  78. # pushed. The fix is not «be careful»: the gate's patterns now match shapes, so a fixture can
  79. # prove them with addresses reserved for documentation (RFC 5737) and names that exist nowhere.
  80. # Fixtures carry only the identifier a pattern matches, never a shell command around it: a
  81. # planted command reads to the Anthropic directory scan as the plugin acting on the user's
  82. # machine and sending data out (09.10.2026). Two strings are split and joined by the
  83. # shell so that the source holds no literal external scanners take for a real secret.
  84. case_run "sibling repository" "see talkstream/ru-text-example for details" "sibling repository under this owner"
  85. case_run "service sub-domain" "docs at service.ru-text.org" "service sub-domain"
  86. case_run "IP address literal" "host 203.0.113.10" "any IP address literal"
  87. case_run "payment provider" "оплата через ЮKassa" "payment provider"
  88. # ⚠ Регистр латиницы: до 16.08.2026 образцы шли без -i, и «YooKassa» — как пишет сам
  89. # бренд — проходило насквозь. Случай стоит отдельно от предыдущего, потому что
  90. # кириллическая и латинская руки ловятся разными половинами образца.
  91. case_run "provider, brand casing" "payments via YooKassa" "payment provider"
  92. case_run "provider, upper case" "хостинг SELECTEL" "hosting provider"
  93. case_run "hosting provider" "хостинг Selectel, СПб" "hosting provider"
  94. case_run "admin token" "ADMIN""_TOKEN is set" "admin token variable"
  95. case_run "deploy key material" "-----BEGIN OPENSSH PRI""VATE KEY-----" "deploy key material"
  96. echo
  97. echo "passed $pass, failed $fail"
  98. [ "$fail" -eq 0 ] || exit 1
tools/selftest.sh · Bundled script · 2,033 lines
  1. #!/bin/sh
  2. # selftest.sh — proves every tool in this directory can FAIL.
  3. #
  4. # A checker nobody has watched fail is a checker nobody has tested. Each case below
  5. # corrupts a throwaway copy of the corpus in one specific way and asserts two things:
  6. # that the tool exits non-zero, and that the SPECIFIC check it should have caught is the
  7. # one that reported. Exit code alone is not enough — a mutation that happens to break a
  8. # different check would pass a weaker test and leave the intended one unpinned.
  9. #
  10. # Corruption always happens in a copy under a temporary directory — the corpus and the
  11. # baseline both. Several cases DO read the real corpus, read-only, to check assumptions
  12. # the tools rest on (that it is still NFC, that the frozen section still parses). The real
  13. # tree is a measurement subject and never a mutation subject; an earlier version of this
  14. # header said it was never a test subject at all, which was not true of those cases.
  15. #
  16. # Run: tools/selftest.sh
  17. set -eu
  18. export LC_ALL=C
  19. ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
  20. TMPROOT=$(mktemp -d "${TMPDIR:-/tmp}/ru-text-selftest.XXXXXX")
  21. # The trap does two jobs, and the second exists because the first one hid a disaster: an EXIT
  22. # handler RESETS the status, so a suite that aborted mid-run — `set -eu` on an unset name, a
  23. # syntax error, a killed child — exited ZERO and every caller read it as a pass. `finished` is
  24. # set on the last line of this file, so anything that stops the run short is reported here and
  25. # exits non-zero. gates.sh ALSO requires the summary line, and that is not redundant: CI does
  26. # not call gates.sh (.github/workflows/gates.yml runs this file directly), so a guard living
  27. # only there would protect the local path and leave CI on the old footing.
  28. finished=0
  29. trap 'st=$?; rm -rf "$TMPROOT"; if [ "$finished" -ne 1 ]; then printf "selftest: ABORTED before the summary — the run did not finish\\n" >&2; exit 1; fi; exit $st' EXIT
  30. trap 'rm -rf "$TMPROOT"; exit 130' INT TERM
  31. pass=0
  32. fail=0
  33. # Initialised, and it was not. Under `set -eu` an unset name in $(( )) aborts bash 3.2 —
  34. # which IS /bin/sh on macOS — and the EXIT trap then resets the status, so the suite died
  35. # at case 145 printing no summary and exiting ZERO. gates.sh read that as a pass. The trigger
  36. # is any `skip`, and the only live one fires when build-og --check fails: an OG rebuild would
  37. # have turned the whole verification chain green-while-dead. Measured 10.08.2026.
  38. #
  39. # HELD BY: `gates.sh` requiring a summary line, which covers the CLASS — any abort, any
  40. # cause — and has its own case. This initialisation itself is a latent arm: no `skip` fires
  41. # on this tree locally (0 today), so removing the line changes nothing a case can see. It
  42. # fires on CI, where dash tolerates the unset name anyway. Written down rather than left to
  43. # be rediscovered by mutation.
  44. skipped=0
  45. note() { printf ' %s\n' "$1"; }
  46. ok() { pass=$((pass + 1)); printf ' ok %s\n' "$1"; }
  47. bad() { fail=$((fail + 1)); printf ' FAIL %s\n' "$1"; }
  48. # Counted separately and printed in the summary: a skipped case must never read
  49. # as a passing one, and must never be invisible. §No silent caps.
  50. skip() { skipped=$((skipped + 1)); printf ' skip %s\n' "$1"; }
  51. # fresh_copy — a self-contained repository slice: corpus, tools and baseline, all writable
  52. fresh_copy() {
  53. d=$(mktemp -d "$TMPROOT/case.XXXXXX")
  54. # The WHOLE skills tree, not just references/ and SKILL.md. The baseline counts atoms in
  55. # skills/ru-text/agents/*.yaml too, so a copy missing them starts eight atoms short and
  56. # any no-loss gate run against it fails for a reason that has nothing to do with the case.
  57. cp -R "$ROOT/skills" "$d/skills"
  58. cp -R "$ROOT/tools" "$d/tools"
  59. # Everything a checker reads has to be in the copy, or gates.sh fails inside a case for a
  60. # reason the case is not about. This list grows when a checker learns to read a new file:
  61. # check-version.sh added the manifests and the two READMEs. Missing files are copied
  62. # silently rather than fatally — a case may deliberately be run against a partial tree.
  63. cp -R "$ROOT/.claude-plugin" "$ROOT/.codex-plugin" "$ROOT/.cursor-plugin" "$d/" 2>/dev/null || true
  64. mkdir -p "$d/.claude"
  65. for f in gemini-extension.json openclaw.plugin.json README.md README.en.md INSTALL.md INSTALL.en.md .claude/CLAUDE.md; do
  66. [ -f "$ROOT/$f" ] && cp "$ROOT/$f" "$d/$f" 2>/dev/null
  67. done
  68. cp -R "$ROOT/notion" "$d/notion" 2>/dev/null || true
  69. # docs/ joined the list when the roadmaps stopped being exempt from the tell sweep: two of
  70. # them state the count in the present tense, so they are consumers, and a copy without them
  71. # fails every case with «does not say» — a failure about the fixture, not about the case.
  72. cp -R "$ROOT/docs" "$d/docs" 2>/dev/null || true
  73. # The images the manifests point at. check-assets.sh reads them, and a copy without them
  74. # reports every reference as missing — a failure about the fixture, not about the case.
  75. cp -R "$ROOT/assets" "$d/assets" 2>/dev/null || true
  76. cp "$ROOT/logo-round.png" "$d/logo-round.png" 2>/dev/null || true
  77. # A repository, not just a directory: check-dogfood walks `git ls-files`, so a copy that
  78. # is not one fails inside every case for a reason no case is about.
  79. ( cd "$d" && git init -q . && git add -A ) >/dev/null 2>&1 || true
  80. printf '%s' "$d"
  81. }
  82. # expect_fail <case-name> <substring the output must contain> <dir>
  83. # Runs check-frozen against the prepared copy and asserts it fails FOR THAT REASON.
  84. expect_fail() {
  85. name=$1; needle=$2; d=$3
  86. out=$("$d/tools/check-frozen.sh" "$d" 2>&1) && status=0 || status=$?
  87. if [ "$status" -eq 0 ]; then
  88. bad "$name — check-frozen PASSED on corrupted input"
  89. return
  90. fi
  91. if printf '%s' "$out" | grep -qF "$needle"; then
  92. ok "$name"
  93. else
  94. bad "$name — failed, but not for the stated reason (wanted: $needle)"
  95. printf '%s\n' "$out" | sed 's/^/ /'
  96. fi
  97. }
  98. printf 'selftest: check-frozen.sh\n'
  99. # ── the control: an untouched copy must pass ──────────────────────────────────
  100. # Without this the whole file could be passing because every case fails for some
  101. # incidental reason, such as a broken copy step.
  102. d=$(fresh_copy)
  103. if "$d/tools/check-frozen.sh" "$d" >/dev/null 2>&1; then
  104. ok "an untouched copy passes"
  105. else
  106. bad "an untouched copy FAILS — the harness itself is broken, ignore everything below"
  107. "$d/tools/check-frozen.sh" "$d" 2>&1 | sed 's/^/ /'
  108. fi
  109. # ── 1. file count ─────────────────────────────────────────────────────────────
  110. d=$(fresh_copy)
  111. rm "$d/skills/ru-text/references/sources.md"
  112. expect_fail "a deleted reference file is caught" "references/ holds 9 .md files" "$d"
  113. # ── 2. §B byte identity ───────────────────────────────────────────────────────
  114. # A replacement reworded inside the frozen section. The paid MCP serves this string
  115. # verbatim, so a silent edit here is a silent change to what customers are told.
  116. d=$(fresh_copy)
  117. sed 's/^осуществлять|.*/осуществлять|делать/' "$d/skills/ru-text/references/info-style.md" > "$d/t" \
  118. && mv "$d/t" "$d/skills/ru-text/references/info-style.md"
  119. expect_fail "a byte changed inside §B is caught" "§B changed" "$d"
  120. # ── 3. table header count ─────────────────────────────────────────────────────
  121. # Drop one category's header row. The rows beneath it still parse, so the entry count
  122. # is unchanged and only this check notices — which is exactly why it exists separately.
  123. d=$(fresh_copy)
  124. awk 'BEGIN { done = 0 } /^слово\|замена$/ && !done { done = 1; next } { print }' \
  125. "$d/skills/ru-text/references/info-style.md" > "$d/t" \
  126. && mv "$d/t" "$d/skills/ru-text/references/info-style.md"
  127. expect_fail "a missing слово|замена header is caught" "7 table headers" "$d"
  128. # ── 4. entry count ────────────────────────────────────────────────────────────
  129. d=$(fresh_copy)
  130. grep -v '^впрочем|' "$d/skills/ru-text/references/info-style.md" > "$d/t" \
  131. && mv "$d/t" "$d/skills/ru-text/references/info-style.md"
  132. expect_fail "a deleted catalog row is caught" "91 catalog entries" "$d"
  133. # ── 5. the probe row ──────────────────────────────────────────────────────────
  134. # perl, not sed: the pattern and the replacement both contain the pipe that sed would
  135. # need as its delimiter, and BSD sed's -i wants an explicit backup suffix.
  136. d=$(fresh_copy)
  137. perl -i -pe 's{^является\|тире / перестроить$}{является|тире}' \
  138. "$d/skills/ru-text/references/info-style.md"
  139. expect_fail "a reworded probe row is caught" "probe row is" "$d"
  140. # ── 5b. the root SKILL.md guard ───────────────────────────────────────────────
  141. # The check added in v2.0 when the duplicate root file was removed. Without a case it is
  142. # a check nobody has watched fire, which is how the DOC credit shipped dead.
  143. d=$(fresh_copy)
  144. cp "$d/skills/ru-text/SKILL.md" "$d/SKILL.md"
  145. expect_fail "a returning root SKILL.md is caught" "registers ru-text twice" "$d"
  146. # ── 6. the baseline itself ────────────────────────────────────────────────────
  147. # A checker that reads its expectations from a file must fail loudly when the file has
  148. # lost one, rather than quietly skipping the check it can no longer make.
  149. d=$(fresh_copy)
  150. grep -v '^catalog_entries=' "$d/tools/frozen.sha256" > "$d/t" && mv "$d/t" "$d/tools/frozen.sha256"
  151. expect_fail "a baseline key gone missing is caught" "catalog_entries is not recorded" "$d"
  152. # ── 6b. §E.1, the pleonasm table (since 2.8.0) ────────────────────────────────
  153. # One case per check, each failing for its own stated reason.
  154. d=$(fresh_copy)
  155. perl -i -pe 's{^памятный сувенир\|сувенир\|.*$}{памятный сувенир|сувенир|souvenir}' "$d/skills/ru-text/references/editorial-grammar.md"
  156. expect_fail "a byte changed inside §E.1 is caught" "§E.1 changed" "$d"
  157. d=$(fresh_copy)
  158. grep -v '^прейскурант цен|' "$d/skills/ru-text/references/editorial-grammar.md" > "$d/t" && mv "$d/t" "$d/skills/ru-text/references/editorial-grammar.md"
  159. expect_fail "a deleted pleonasm row is caught" "53 pleonasm entries" "$d"
  160. # Carve-out prose that happens to carry two pipes passes the row predicate. The gap between
  161. # window rows and entries stays one — both grow — so only the absolute counts see it.
  162. d=$(fresh_copy)
  163. perl -i -pe 's{^wrong\|correct\|why$}{Проза: «дешевле|дороже» и «выше|ниже» правилом не ловятся.\n\nwrong|correct|why}' "$d/skills/ru-text/references/editorial-grammar.md"
  164. expect_fail "prose with two pipes inside §E.1 is caught" "56 rows of §E.1" "$d"
  165. d=$(fresh_copy)
  166. perl -i -pe 's{^свободная вакансия\|вакансия\|.*$}{свободная вакансия|вакансия|free position}' "$d/skills/ru-text/references/editorial-grammar.md"
  167. expect_fail "a reworded pleonasm probe row is caught" "pleonasm probe row is" "$d"
  168. d=$(fresh_copy)
  169. grep -v '^pleonasm_entries=' "$d/tools/frozen.sha256" > "$d/t" && mv "$d/t" "$d/tools/frozen.sha256"
  170. expect_fail "a missing §E.1 baseline key is caught" "pleonasm_entries is not recorded" "$d"
  171. # --print must refuse, not record an absence as the new truth.
  172. d=$(fresh_copy)
  173. grep -v '^свободная вакансия|' "$d/skills/ru-text/references/editorial-grammar.md" > "$d/t" && mv "$d/t" "$d/skills/ru-text/references/editorial-grammar.md"
  174. if "$d/tools/check-frozen.sh" --print "$d" >/dev/null 2>&1; then
  175. bad "--print emitted a baseline from a §E.1 that lost its probe row"
  176. else
  177. ok "--print refuses a §E.1 without its probe row"
  178. fi
  179. # ── 6c. the passive-voice table of anti-patterns.md ───────────────────────────
  180. d=$(fresh_copy)
  181. perl -i -pe 's{^Работа выполняется\|.*$}{Работа выполняется|Команда работает}' "$d/skills/ru-text/references/anti-patterns.md"
  182. expect_fail "a byte changed inside the passive table is caught" "passive table changed" "$d"
  183. d=$(fresh_copy)
  184. grep -v '^Совещание проведено|' "$d/skills/ru-text/references/anti-patterns.md" > "$d/t" && mv "$d/t" "$d/skills/ru-text/references/anti-patterns.md"
  185. expect_fail "a deleted passive row is caught" "9 passive entries" "$d"
  186. d=$(fresh_copy)
  187. perl -i -pe 's{^Passive\|Active$}{Проза: «было|стало» правилом не ловится.\n\nPassive|Active}' "$d/skills/ru-text/references/anti-patterns.md"
  188. expect_fail "prose with one pipe inside the passive table is caught" "12 rows of the passive table" "$d"
  189. d=$(fresh_copy)
  190. perl -i -pe 's{^Было принято решение\|.*$}{Было принято решение|Мы решили}' "$d/skills/ru-text/references/anti-patterns.md"
  191. expect_fail "a reworded passive probe row is caught" "passive probe row is" "$d"
  192. d=$(fresh_copy)
  193. grep -v '^passive_entries=' "$d/tools/frozen.sha256" > "$d/t" && mv "$d/t" "$d/tools/frozen.sha256"
  194. expect_fail "a missing passive baseline key is caught" "passive_entries is not recorded" "$d"
  195. d=$(fresh_copy)
  196. grep -v '^Было принято решение|' "$d/skills/ru-text/references/anti-patterns.md" > "$d/t" && mv "$d/t" "$d/skills/ru-text/references/anti-patterns.md"
  197. if "$d/tools/check-frozen.sh" --print "$d" >/dev/null 2>&1; then
  198. bad "--print emitted a baseline from a passive table that lost its probe row"
  199. else
  200. ok "--print refuses a passive table without its probe row"
  201. fi
  202. # ── 6d. the AD trigger blocks of addenda.md ───────────────────────────────────
  203. A=skills/ru-text/references/addenda.md
  204. d=$(fresh_copy)
  205. perl -i -pe 's{^- «различные факторы» / «ряд факторов»}{- «различные факторы» / «ряд причин»}' "$d/$A"
  206. expect_fail "a byte changed inside a trigger block is caught" "AD trigger blocks changed" "$d"
  207. # The heading travels with the block: renumbering a rule changes nothing inside its list, and
  208. # only the checksum over heading + block sees it.
  209. d=$(fresh_copy)
  210. perl -i -pe 's{^## AD-12\. }{## AD-19. }' "$d/$A"
  211. expect_fail "a trigger block moved to another rule number is caught" "AD trigger blocks changed" "$d"
  212. d=$(fresh_copy)
  213. grep -v '^- «исследования показывают»' "$d/$A" > "$d/t" && mv "$d/t" "$d/$A"
  214. expect_fail "a deleted trigger item is caught" "61 items in the trigger blocks" "$d"
  215. # A singular header turned plural drags its prose quotes into the window — only the plural
  216. # count moves, the total stays 14.
  217. d=$(fresh_copy)
  218. perl -i -pe 's{^\*\*Trigger construction:\*\* `U\+002C`}{**Trigger constructions:** `U+002C`}' "$d/$A"
  219. expect_fail "a singular trigger header turned plural is caught" "13 plural trigger blocks" "$d"
  220. # A new singular block — codepoint triggers the service does not read — moves only the total.
  221. d=$(fresh_copy)
  222. perl -i -pe 's{^(\*\*Trigger constructions:\*\*)$}{**Trigger construction:** a new codepoint trigger.\n\n$1} if $. == 263' "$d/$A"
  223. expect_fail "a new singular trigger block is caught" "15 trigger blocks of either number" "$d"
  224. # A top-level heading dropped between a rule and its block cuts the block off: the service no
  225. # longer reads it, and neither does the window — checksum, block count and items all move.
  226. d=$(fresh_copy)
  227. perl -i -pe 's{^(\*\*Trigger constructions:\*\*)$}{## Sources\n\n$1} if $. == 774' "$d/$A"
  228. expect_fail "a trigger block cut off from its rule by a heading is caught" "11 plural trigger blocks" "$d"
  229. d=$(fresh_copy)
  230. perl -i -pe 's{^- «Отличный вопрос!» / }{- «Отличный вопрос» / }' "$d/$A"
  231. expect_fail "a reworded trigger probe item is caught" "trigger probe item is" "$d"
  232. d=$(fresh_copy)
  233. grep -v '^trigger_items=' "$d/tools/frozen.sha256" > "$d/t" && mv "$d/t" "$d/tools/frozen.sha256"
  234. expect_fail "a missing trigger baseline key is caught" "trigger_items is not recorded" "$d"
  235. d=$(fresh_copy)
  236. grep -v '^- «Отличный вопрос!»' "$d/$A" > "$d/t" && mv "$d/t" "$d/$A"
  237. if "$d/tools/check-frozen.sh" --print "$d" >/dev/null 2>&1; then
  238. bad "--print emitted a baseline from trigger blocks that lost their probe item"
  239. else
  240. ok "--print refuses trigger blocks without their probe item"
  241. fi
  242. # The header names how many sections are frozen byte-for-byte; the baseline must carry one
  243. # checksum per extraction, or a section was added to one side only.
  244. sections=$(grep -c '^section_[a-z0-9]*() {' "$ROOT/tools/check-frozen.sh" | tr -d ' ')
  245. keys=$(grep -c '^section_[a-z0-9]*_sha256=' "$ROOT/tools/frozen.sha256" | tr -d ' ')
  246. if [ "$sections" -eq "$keys" ] && [ "$keys" -gt 0 ]; then
  247. ok "one checksum per frozen section ($keys)"
  248. else
  249. bad "frozen sections: $sections extractions, $keys checksums in frozen.sha256"
  250. fi
  251. # ── 7. the locale trap: a canary, reported per platform ───────────────────────
  252. # Why LC_ALL=C is exported everywhere. Under a UTF-8 locale the BSD awk on macOS reports
  253. # distinct Cyrillic strings as equal, and the catalog parser silently returns 84 of its 92
  254. # entries. Reproduce there with:
  255. # printf 'ну|убрать\n' | awk '$0 == "слово|замена" { print "EQ" }'
  256. #
  257. # The first version of this case asserted the trap exists, full stop — and CI failed on
  258. # its very first run, because gawk on the Linux runner is not affected. That was a
  259. # property of one machine's awk stated as a property of every awk: the same
  260. # over-quantification this project keeps having to correct, this time caught by a second
  261. # platform instead of a reviewer. So the canary now reports what it finds and fails only
  262. # on the outcome that would actually mislead someone — the trap having quietly vanished on
  263. # a platform that used to have it, which is the day LC_ALL=C could be reconsidered.
  264. # The probe needs a UTF-8 locale to be MEANINGFUL: with none installed the C locale is
  265. # used silently, no match occurs, and "this awk is unaffected" is indistinguishable from
  266. # "the experiment never ran". So the locale is checked first and an absent one is reported
  267. # as what it is — an inconclusive probe — rather than as a clean bill of health.
  268. utf8_locale=$(locale -a 2>/dev/null | /usr/bin/grep -iE '^(en_US|C)\.(utf-?8)$' | head -1 || true)
  269. if [ -z "$utf8_locale" ]; then
  270. ok "no UTF-8 locale on this machine — the awk trap probe is inconclusive, LC_ALL=C stays"
  271. trap_probe=SKIP
  272. else
  273. trap_probe=$(printf 'ну|убрать\n' | LC_ALL="$utf8_locale" awk '$0 == "слово|замена" { print "EQ" }' 2>/dev/null || true)
  274. fi
  275. case "$(uname -s)" in
  276. Darwin)
  277. if [ "$trap_probe" = "SKIP" ]; then
  278. :
  279. elif [ "$trap_probe" = "EQ" ]; then
  280. ok "the awk multibyte == trap is present on this platform, as expected (LC_ALL=C required)"
  281. else
  282. bad "the awk multibyte == trap is GONE on macOS — re-examine why LC_ALL=C is set, then update this case"
  283. fi
  284. ;;
  285. *)
  286. if [ "$trap_probe" = "SKIP" ]; then
  287. :
  288. elif [ "$trap_probe" = "EQ" ]; then
  289. bad "this platform's awk has the multibyte == trap too — widen the note in check-frozen.sh"
  290. else
  291. ok "no awk multibyte == trap on $(uname -s); LC_ALL=C stays for the platforms that have it"
  292. fi
  293. ;;
  294. esac
  295. printf 'selftest: extract-atoms.sh + diff-atoms.sh\n'
  296. # expect_diff <case> <expected exit: 0|1> <needle or -> <old> <new> [map]
  297. # The default map is EMPTY, not the repository's own. These cases compare snapshots of the
  298. # current corpus against each other, and every row of the real map names an atom the
  299. # current corpus no longer has — so in such a comparison every real row is legitimately
  300. # STALE, and «identical snapshots pass» started failing the moment the map stopped being
  301. # empty. What is under test here is diff-atoms on a synthetic pair; the real map is
  302. # exercised for real by gates.sh, and by the cases below that pass their own fixture.
  303. expect_diff() {
  304. name=$1; want=$2; needle=$3; o=$4; n=$5; m=${6:-$EMPTY_MAP}
  305. out=$("$ROOT/tools/diff-atoms.sh" "$o" "$n" "$m" 2>&1) && st=0 || st=$?
  306. if [ "$st" -ne "$want" ]; then
  307. bad "$name — exit $st, wanted $want"
  308. printf '%s\n' "$out" | sed 's/^/ /'
  309. return
  310. fi
  311. if [ "$needle" != "-" ] && ! printf '%s' "$out" | grep -qF "$needle"; then
  312. bad "$name — right exit, wrong reason (wanted: $needle)"
  313. printf '%s\n' "$out" | sed 's/^/ /'
  314. return
  315. fi
  316. ok "$name"
  317. }
  318. W=$(mktemp -d "$TMPROOT/atoms.XXXXXX")
  319. EMPTY_MAP="$W/empty-map.tsv"
  320. printf '# no rows: see the note above expect_diff\n' > "$EMPTY_MAP"
  321. "$ROOT/tools/extract-atoms.sh" "$ROOT/skills/ru-text" > "$W/a.tsv"
  322. "$ROOT/tools/extract-atoms.sh" "$ROOT/skills/ru-text" > "$W/b.tsv"
  323. # Determinism. Hashes, ordering and text must not depend on the machine or the run —
  324. # otherwise every future comparison is noise and the gate is unreadable.
  325. if cmp -s "$W/a.tsv" "$W/b.tsv"; then
  326. ok "extract-atoms is deterministic across runs"
  327. else
  328. bad "extract-atoms output differs between two runs of the same corpus"
  329. fi
  330. # ── the golden fixture ────────────────────────────────────────────────────────
  331. # tools/testdata/corpus is a small corpus carrying one instance of every shape and every
  332. # exclusion: frontmatter, an H1, both spellings of a table of contents, a Sources section,
  333. # a bare a|b table with its header, a markdown table with its separator, a heading that IS
  334. # a rule, a two-line До/После rule, a fenced specification, a --- separator, and a .yaml
  335. # manifest. Its expected output is committed beside it.
  336. #
  337. # This is what pins ORDERING and the file:line column. Running the extractor twice on one
  338. # machine cannot see a machine-dependent construct, and comparing against the live corpus
  339. # would start failing legitimately at the first stage that moves a rule. A fixture keeps
  340. # working forever, and two corruptions of extract-atoms that previously passed 22/22 are
  341. # caught here.
  342. if "$ROOT/tools/extract-atoms.sh" "$ROOT/tools/testdata/corpus" > "$W/fixture.tsv" 2>"$W/fixture.err"; then
  343. if cmp -s "$W/fixture.tsv" "$ROOT/tools/testdata/expected-atoms.tsv"; then
  344. ok "the fixture corpus extracts exactly as recorded ($(wc -l < "$W/fixture.tsv" | tr -d ' ') atoms)"
  345. else
  346. bad "the fixture corpus no longer extracts as recorded"
  347. diff "$ROOT/tools/testdata/expected-atoms.tsv" "$W/fixture.tsv" | head -12 | sed 's/^/ /'
  348. fi
  349. else
  350. bad "extract-atoms failed on the fixture corpus"
  351. sed 's/^/ /' < "$W/fixture.err"
  352. fi
  353. # ── proof that extract-atoms itself can fail ──────────────────────────────────
  354. # Every other extract-atoms case reads the pristine corpus and asserts a string is
  355. # present, so none of them had ever been seen to fire — the probes could have been passing
  356. # because grep matches, not because the control works. This removes one rule from a copy
  357. # of the fixture and requires the extractor to notice.
  358. FX=$(mktemp -d "$TMPROOT/fx.XXXXXX")
  359. cp -R "$ROOT/tools/testdata/corpus" "$FX/corpus"
  360. /usr/bin/grep -v '^осуществлять|делать$' "$FX/corpus/references/rules.md" > "$FX/t" \
  361. && mv "$FX/t" "$FX/corpus/references/rules.md"
  362. "$ROOT/tools/extract-atoms.sh" "$FX/corpus" > "$FX/cut.tsv"
  363. if cmp -s "$FX/cut.tsv" "$ROOT/tools/testdata/expected-atoms.tsv"; then
  364. bad "extract-atoms produced identical output after a rule was deleted — it cannot fail"
  365. else
  366. ok "extract-atoms notices a deleted rule"
  367. fi
  368. expect_diff "the gate catches a rule deleted from the fixture" 1 "UNACCOUNTED" \
  369. "$ROOT/tools/testdata/expected-atoms.tsv" "$FX/cut.tsv"
  370. # ── the exclusions are exclusions, and the inclusions are inclusions ──────────
  371. # Named against the fixture rather than the live corpus so these stay meaningful when the
  372. # corpus changes. Each line here was, at some point, wrong in the extractor.
  373. fixture_has() { if /usr/bin/grep -qF "$2" "$W/fixture.tsv"; then ok "fixture keeps $1"; else bad "fixture LOST $1 — wanted: $2"; fi; }
  374. fixture_lacks() { if /usr/bin/grep -qF "$2" "$W/fixture.tsv"; then bad "fixture leaked $1 — found: $2"; else ok "fixture drops $1"; fi; }
  375. fixture_has "a fenced specification" "Оценка XX 10"
  376. fixture_has "a fenced table header" "Измерение | Балл |"
  377. fixture_has "the SKILL.md description" "это триггер активации"
  378. fixture_has "a yaml manifest descriptor" "fixture descriptor"
  379. fixture_has "a heading that is a rule" "Канцелярит bureaucratic"
  380. fixture_has "both halves of a two-line rule" "До Наша компания"
  381. fixture_lacks "a table of contents" "[A](#a)"
  382. fixture_lacks "the other table of contents" "Разметка](#"
  383. fixture_lacks "a Sources section" "атрибуция"
  384. fixture_lacks "an H1 title" "Заголовок первого уровня"
  385. fixture_lacks "a bare table header" "слово|замена"
  386. fixture_lacks "a markdown table header" "Условие | Действие"
  387. # Recall on the four shapes the reconnaissance flagged as easiest to lose. The probes are
  388. # written in POST-normalisation form — punctuation is gone by then, so the frozen row
  389. # «является|тире / перестроить» is stored as «является|тире перестроить». A first draft
  390. # compared against the raw source lines and reported four losses that were not losses.
  391. # Testing a tool against what it actually emits is the only version of this that means
  392. # anything; testing it against what you assumed it emits reports on your assumptions.
  393. probe_recall() {
  394. # cut's stderr is discarded: grep -q exits on the first match, cut takes SIGPIPE, and
  395. # GNU cut prints "write error: Broken pipe" where BSD cut is silent. The message is
  396. # noise either way, but noise in a gate's output teaches people to skim it.
  397. if cut -f3 "$W/a.tsv" 2>/dev/null | /usr/bin/grep -qF "$2"; then
  398. ok "extract-atoms keeps $1"
  399. else
  400. bad "extract-atoms LOST $1 — wanted a line containing: $2"
  401. fi
  402. }
  403. # a bare a|b row — the syntax five of the ten files use, which no markdown table parser sees
  404. probe_recall "a bare-syntax table row" "является|тире перестроить"
  405. # a rule that exists ONLY as a heading: the stop-word taxonomy is written nowhere else
  406. probe_recall "a heading-only rule" "Канцелярит bureaucratic"
  407. # the content half of a two-line rule, whose numbered line above it is only a label
  408. probe_recall "a multi-line rule's content" "До Наша компания на протяжении долгих лет"
  409. # a leading-pipe markdown row — the syntax the other four files use
  410. probe_recall "a markdown table row" "Форма обращения"
  411. # Exclusions actually exclude.
  412. if cut -f3 "$W/a.tsv" | grep -qE '^-+$'; then
  413. bad "extract-atoms emits bare separator lines"
  414. else
  415. ok "extract-atoms drops separators and frontmatter delimiters"
  416. fi
  417. # A snapshot compared with itself must pass. This is the control that caught the tool
  418. # reporting the entire corpus as lost: awk matched both arguments to the first pass when
  419. # the two paths were identical.
  420. expect_diff "identical snapshots pass" 0 "PASS" "$W/a.tsv" "$W/a.tsv"
  421. # One rule gone, no map row: the whole point.
  422. sed '$d' "$W/a.tsv" > "$W/short.tsv"
  423. expect_diff "a deleted atom is caught" 1 "UNACCOUNTED" "$W/a.tsv" "$W/short.tsv"
  424. # Reworded: fails unmapped, passes once someone writes down what happened.
  425. H=$(head -1 "$W/a.tsv" | cut -f1)
  426. { sed '1d' "$W/a.tsv"; printf 'f00d000000000000000000000000000000000000\tSKILL.md:2\treworded\n'; } > "$W/re.tsv"
  427. expect_diff "a reworded atom is caught with no map row" 1 "UNACCOUNTED" "$W/a.tsv" "$W/re.tsv"
  428. printf '%s\tNORMALISED\tf00d000000000000000000000000000000000000\tselftest\n' "$H" > "$W/map-ok.tsv"
  429. expect_diff "a mapped rewording passes" 0 "PASS" "$W/a.tsv" "$W/re.tsv" "$W/map-ok.tsv"
  430. # A map row pointing at an atom that is not in the new snapshot is worse than none: it
  431. # reads as accounted for.
  432. printf '%s\tNORMALISED\t0000000000000000000000000000000000000000\tselftest\n' "$H" > "$W/map-broken.tsv"
  433. expect_diff "a map row pointing nowhere is caught" 1 "BROKEN TARGET" "$W/a.tsv" "$W/re.tsv" "$W/map-broken.tsv"
  434. # There is no DELETED disposition, and a map that tries to use one must say so out loud
  435. # rather than silently ignoring the row.
  436. printf '%s\tDELETED\tf00d000000000000000000000000000000000000\tselftest\n' "$H" > "$W/map-del.tsv"
  437. expect_diff "a DELETED disposition is rejected" 1 "BAD DISPOSITION" "$W/a.tsv" "$W/re.tsv" "$W/map-del.tsv"
  438. # A row that accounts for nothing means the map and the corpus have drifted apart.
  439. printf 'abcabcabcabcabcabcabcabcabcabcabcabcabca\tMOVED\tf00d000000000000000000000000000000000000\tselftest\n' > "$W/map-stale.tsv"
  440. expect_diff "a stale map row is caught" 1 "STALE MAP ROW" "$W/a.tsv" "$W/a.tsv" "$W/map-stale.tsv"
  441. # The corpus is already NFC, which is why the extractor does not normalise it. If that
  442. # ever stops being true the comparison starts depending on how a file was saved.
  443. # ── every diagnostic diff-atoms can print, exercised ─────────────────────────
  444. # None of the checks added after the panel had a case: not the DOC branches, not
  445. # OVERSUBSCRIBED, not DUPLICATE MAP ROW. That is how a DOC fix shipped as dead code with
  446. # the suite at 37/37 and the commit body announcing it closed. One case per diagnostic.
  447. DG=$(mktemp -d "$TMPROOT/diag.XXXXXX")
  448. printf 'a1b2c3\tf.md:1\tправило уехало в доки\nd4e5f6\tf.md:2\tостаётся\n' > "$DG/old.tsv"
  449. printf 'd4e5f6\tf.md:2\tостаётся\n' > "$DG/new.tsv"
  450. mkdir -p "$DG/docs"
  451. # the documentation must carry the NORMALISED text, which is what UNACCOUNTED prints
  452. printf '# перенесённые правила\n\nправило уехало в доки\n' > "$DG/docs/moved.md"
  453. printf 'a1b2c3\tDOC\t%s/docs/moved.md\tпереехало в документацию\n' "$DG" > "$DG/map-doc.tsv"
  454. expect_diff "a clean DOC row passes" 0 "PASS" "$DG/old.tsv" "$DG/new.tsv" "$DG/map-doc.tsv"
  455. printf 'a1b2c3\tDOC\t%s/tools/testdata/expected-atoms.tsv\tотмычка\n' "$ROOT" > "$DG/map-snap.tsv"
  456. expect_diff "a DOC row aimed at an atom snapshot is refused" 1 "DOC TARGET IS AN ATOM SNAPSHOT" \
  457. "$DG/old.tsv" "$DG/new.tsv" "$DG/map-snap.tsv"
  458. printf 'a1b2c3\tf.md:1\tдубль\na1b2c3\tf.md:2\tдубль\na1b2c3\tf.md:3\tдубль\nd4e5f6\tf.md:9\tживой\n' > "$DG/many.tsv"
  459. printf 'd4e5f6\tf.md:9\tживой\n' > "$DG/one.tsv"
  460. printf 'a1b2c3\tMOVED\td4e5f6\tодна строка на три потери\n' > "$DG/map-over.tsv"
  461. expect_diff "one map row cannot absorb three lost copies" 1 "TARGET OVERSUBSCRIBED" \
  462. "$DG/many.tsv" "$DG/one.tsv" "$DG/map-over.tsv"
  463. printf 'a1b2c3\tMERGED\td4e5f6\tраз\na1b2c3\tMOVED\td4e5f6\tдва\n' > "$DG/map-dup.tsv"
  464. expect_diff "two map rows for one hash are refused" 1 "DUPLICATE MAP ROW" \
  465. "$DG/many.tsv" "$DG/one.tsv" "$DG/map-dup.tsv"
  466. # ── check-frozen --print, round trip and refusal ─────────────────────────────
  467. # --print is documented as the only supported way to regenerate the baseline, and until
  468. # now nothing ran it. Both directions: it reproduces the committed values exactly, and it
  469. # refuses rather than recording an absence as the new truth.
  470. d=$(fresh_copy)
  471. if "$d/tools/check-frozen.sh" --print "$d" > "$d/printed" 2>"$d/printed.err"; then
  472. # a temp file rather than <(…): this script is /bin/sh, and process substitution is a
  473. # bash extension that dash on the CI runner does not have
  474. /usr/bin/grep -v '^#' "$ROOT/tools/frozen.sha256" | /usr/bin/grep . > "$d/committed"
  475. if diff -q "$d/committed" "$d/printed" >/dev/null; then
  476. ok "--print reproduces the committed baseline exactly"
  477. else
  478. bad "--print disagrees with tools/frozen.sha256"
  479. diff "$d/committed" "$d/printed" | sed 's/^/ /'
  480. fi
  481. else
  482. bad "--print failed on an untouched copy"
  483. sed 's/^/ /' < "$d/printed.err"
  484. fi
  485. d=$(fresh_copy)
  486. perl -i -pe 's{^является\|тире / перестроить$}{}' "$d/skills/ru-text/references/info-style.md"
  487. if "$d/tools/check-frozen.sh" --print "$d" >"$d/out" 2>"$d/err"; then
  488. bad "--print emitted a baseline from a corpus missing the probe row"
  489. elif /usr/bin/grep -q 'refusing to emit' "$d/err"; then
  490. ok "--print refuses a corpus that has lost the probe row"
  491. else
  492. bad "--print failed, but not with the refusal message"
  493. sed 's/^/ /' < "$d/err"
  494. fi
  495. # ── the case-folding measurement, pinned ─────────────────────────────────────
  496. # extract-atoms.sh states a number — six collapsed groups, five of them one rule in two
  497. # files — as the reason case is not folded. A measured number in a comment is a promise;
  498. # this is the case that keeps it honest. The arbiter made that the rule after two
  499. # successive commits shipped a different wrong count in this very sentence.
  500. if command -v python3 >/dev/null 2>&1; then
  501. folded=$(python3 - "$ROOT" <<'PYEOF'
  502. import sys, glob, io, re, collections
  503. R = sys.argv[1]
  504. DASH = {'\u2014':'-','\u2013':'-','\u2212':'-','\u2012':'-','\u2015':'-'}
  505. SP = {'\u00a0':' ','\u202f':' ','\u2009':' ','\t':' '}
  506. def norm(s):
  507. s = s.replace('\u0451','\u0435').replace('\u0401','\u0415')
  508. s = ''.join(DASH.get(c, c) for c in s)
  509. s = ''.join(SP.get(c, c) for c in s)
  510. s = re.sub(r'[\u00ab\u00bb\u201c\u201d\u201e]', '', s)
  511. s = re.sub(r'^\|', '', s)
  512. s = re.sub(r'^ *[-*+] +', '', s)
  513. s = re.sub(r'^ *#+ +', '', s)
  514. s = re.sub(r'^ *(R[0-9]+|AD-[0-9]+(\.[0-9]+)?|[0-9]+)[.:)]? +', '', s)
  515. s = re.sub(r'[*_`]', '', s)
  516. s = re.sub(r'[!"#$%&()+,./:;<=>?@\[\]^{}~]', '', s)
  517. return re.sub(r' +', ' ', s).strip()
  518. groups = collections.defaultdict(set)
  519. files = sorted(glob.glob(R + '/skills/ru-text/references/*.md')) + [R + '/skills/ru-text/SKILL.md']
  520. for f in files:
  521. for line in io.open(f, encoding='utf-8').read().split('\n'):
  522. if line.strip():
  523. n = norm(line)
  524. groups[n.lower()].add(n)
  525. print(sum(1 for v in groups.values() if len(v) > 1))
  526. PYEOF
  527. )
  528. if [ "$folded" = "6" ]; then
  529. ok "case folding still collapses exactly 6 groups, as extract-atoms.sh states"
  530. else
  531. bad "case folding now collapses $folded groups, not the 6 extract-atoms.sh claims"
  532. fi
  533. else
  534. bad "python3 is absent, so the folding figure in extract-atoms.sh is unverified here"
  535. fi
  536. # The interpreter is checked separately from the claim. Folded together, a machine with no
  537. # python3 exited 127, landed in the else branch, and announced that the CORPUS had changed
  538. # — a true-sounding sentence about the wrong file, with 2>/dev/null hiding the one line
  539. # that would have said otherwise.
  540. if ! command -v python3 >/dev/null 2>&1; then
  541. bad "python3 is absent, so the NFC assumption behind extract-atoms is unverified here"
  542. # $ROOT arrives through argv, never interpolated into the source. Spliced in, a repository
  543. # checked out into a directory whose name contains an apostrophe closes the string literal
  544. # and runs whatever follows it — and the milder half is worse to debug: the interpreter
  545. # raises, the else branch fires, and the selftest announces that THE CORPUS is no longer
  546. # NFC. A true-sounding sentence about the wrong file. The folding check above already
  547. # passes ROOT this way; this one did not.
  548. elif python3 - "$ROOT" <<'PYEOF'; then
  549. import unicodedata, glob, io, sys
  550. R = sys.argv[1]
  551. bad = [(f, i + 1)
  552. for f in glob.glob(R + '/skills/ru-text/references/*.md') + [R + '/skills/ru-text/SKILL.md']
  553. for i, l in enumerate(io.open(f, encoding='utf-8').read().split(chr(10)))
  554. if unicodedata.normalize('NFC', l) != l]
  555. sys.exit(1 if bad else 0)
  556. PYEOF
  557. ok "the corpus is still NFC (no normalisation step needed)"
  558. else
  559. bad "the corpus is no longer NFC — extract-atoms must normalise, or comparisons will drift"
  560. fi
  561. printf 'selftest: check-version.sh\n'
  562. # expect_version <case-name> <substring the output must contain> <dir>
  563. expect_version() {
  564. name=$1; needle=$2; d=$3
  565. out=$("$d/tools/check-version.sh" 2>&1) && status=0 || status=$?
  566. if [ "$status" -eq 0 ]; then
  567. bad "$name — check-version PASSED on corrupted input"
  568. elif printf '%s' "$out" | grep -qF "$needle"; then
  569. ok "$name"
  570. else
  571. bad "$name — failed, but not for the stated reason (wanted: $needle)"
  572. printf '%s\n' "$out" | sed 's/^/ /'
  573. fi
  574. }
  575. d=$(fresh_copy)
  576. if "$d/tools/check-version.sh" >/dev/null 2>&1; then
  577. ok "an untouched copy passes check-version"
  578. else
  579. bad "an untouched copy FAILS check-version — the cases below mean nothing"
  580. "$d/tools/check-version.sh" 2>&1 | sed 's/^/ /'
  581. fi
  582. # One manifest moved and the rest did not: the exact shape of the v1.10.1 slip, where both
  583. # READMEs advertised the previous release while the manifests were current.
  584. d=$(fresh_copy)
  585. # [^"]*, not [0-9.]*: on a pre-release tree the narrow class matches nothing, the sed
  586. # no-ops, and this case passes or fails on whatever else is wrong with the copy.
  587. sed 's/"version": "[^"]*"/"version": "9.9.9"/' "$d/gemini-extension.json" > "$d/v" && mv "$d/v" "$d/gemini-extension.json"
  588. expect_version "one manifest out of step is caught" "version points disagree" "$d"
  589. # A pre-release is a version like any other. The v2.0.0-rc.1 bump caught the prose pattern
  590. # truncating the suffix — 2.0.0-rc.1 read as 2.0.0 — so a correct tree failed as an
  591. # eight-way disagreement. This copy pins the fix after the release strips the suffix from
  592. # the tree itself.
  593. d=$(fresh_copy)
  594. for m in .claude-plugin/plugin.json .claude-plugin/marketplace.json .codex-plugin/plugin.json \
  595. .cursor-plugin/plugin.json gemini-extension.json openclaw.plugin.json; do
  596. sed 's/"version": "[^"]*"/"version": "9.9.9-rc.1"/' "$d/$m" > "$d/v" && mv "$d/v" "$d/$m"
  597. done
  598. sed 's/\*\*Version:\*\* [^ ]*/**Version:** 9.9.9-rc.1/' "$d/.claude/CLAUDE.md" > "$d/v" && mv "$d/v" "$d/.claude/CLAUDE.md"
  599. # The social image carries the major.minor line as a literal, and a real version bump moves
  600. # it too — build-og.sh re-renders from this source. Leaving it behind would make this case
  601. # fail for a reason it is not about, and would model a bump nobody should perform.
  602. sed 's|class="ver">[0-9.]*<|class="ver">9.9<|' "$d/assets/og/og.html" > "$d/v" && mv "$d/v" "$d/assets/og/og.html"
  603. if "$d/tools/check-version.sh" >/dev/null 2>&1; then
  604. ok "a pre-release version agreeing at every point passes"
  605. else
  606. bad "a pre-release version agreeing at every point FAILS — the prose pattern is truncating the suffix again"
  607. "$d/tools/check-version.sh" 2>&1 | grep -A9 'FAIL' | sed 's/^/ /'
  608. fi
  609. # The prose copy is the half that actually went stale last time. Both READMEs dropped their
  610. # prose version in favour of a badge that renders live from the releases API, so the one
  611. # prose point left is the convention file — which is the one that went stale SECOND, after
  612. # the READMEs were fixed.
  613. d=$(fresh_copy)
  614. sed 's/\*\*Version:\*\*/**Versionn:**/' "$d/.claude/CLAUDE.md" > "$d/v" && mv "$d/v" "$d/.claude/CLAUDE.md"
  615. expect_version "a version line missing from the convention file is caught" "missing or duplicated" "$d"
  616. # A trigger phrase dropped from the description. This is the failure the file exists for:
  617. # on a host with no instruction file the description IS the trigger, so losing a phrase
  618. # stops the skill firing for Russian-speaking users while every other gate stays green.
  619. d=$(fresh_copy)
  620. sed 's/вычитай, //' "$d/skills/ru-text/SKILL.md" > "$d/v" && mv "$d/v" "$d/skills/ru-text/SKILL.md"
  621. expect_version "a lost trigger phrase is caught" "lost a trigger phrase" "$d"
  622. # Present but pushed out of the head, where a truncating picker stops showing them.
  623. d=$(fresh_copy)
  624. python3 - "$d/skills/ru-text/SKILL.md" <<'PY'
  625. import io, sys
  626. p = sys.argv[1]
  627. s = io.open(p, encoding='utf-8').read()
  628. s = s.replace(' Russian text quality. Triggers: ',
  629. ' Russian text quality for typography, info-style, editorial, UX writing and\n'
  630. ' business correspondence, plus AI-text cleanup. Triggers: ')
  631. io.open(p, 'w', encoding='utf-8').write(s)
  632. PY
  633. expect_version "Russian phrases pushed past the head are caught" "past character" "$d"
  634. # Over our own style budget.
  635. d=$(fresh_copy)
  636. python3 - "$d/skills/ru-text/SKILL.md" <<'PY'
  637. import io, sys
  638. p = sys.argv[1]
  639. s = io.open(p, encoding='utf-8').read()
  640. s = s.replace(' причеши, ru-text.', ' причеши, ru-text. ' + ('padding words to overflow the budget ' * 3))
  641. io.open(p, 'w', encoding='utf-8').write(s)
  642. PY
  643. expect_version "a description over the budget is caught" "over our budget" "$d"
  644. # Neither README states the size of SKILL.md any more: the rewrite dropped it, because a
  645. # manifest's word count answers «did the author follow the spec», which is not a question a
  646. # reader has. §4 of check-version stays and is self-activating — if a size claim ever returns,
  647. # it is checked — so these cases BUILD the claim in the sandbox before corrupting it. Testing
  648. # a checker against a claim the product no longer makes would be testing nothing at all.
  649. add_size_claim() { # $1=dir $2=words $3=lines
  650. python3 - "$1/README.md" "$2" "$3" <<'PY'
  651. import io, sys
  652. p, w, l = sys.argv[1], sys.argv[2], sys.argv[3]
  653. s = io.open(p, encoding='utf-8').read()
  654. anchor = '## Обновление'
  655. assert s.count(anchor) == 1, 'anchor moved; fix the fixture'
  656. s = s.replace(anchor, '## Технические детали\n\n- SKILL.md: %s слов, %s строк\n\n' % (w, l) + anchor, 1)
  657. io.open(p, 'w', encoding='utf-8').write(s)
  658. PY
  659. }
  660. skill_words() { python3 -c "import io,re,sys;print(len(re.findall(r'[^ \t\n\r\f\v]+', io.open(sys.argv[1], encoding='utf-8').read())))" "$1/skills/ru-text/SKILL.md"; }
  661. skill_lines() { grep -c '' "$1/skills/ru-text/SKILL.md"; }
  662. # Word count wrong, line count right.
  663. d=$(fresh_copy)
  664. add_size_claim "$d" 999 "$(skill_lines "$d")"
  665. expect_version "a stale SKILL.md word count is caught" "states the size of SKILL.md wrongly" "$d"
  666. # Line count wrong, word count right — pinned separately, because a comparison that looked
  667. # only at words passed this and left the selftest green.
  668. d=$(fresh_copy)
  669. add_size_claim "$d" "$(skill_words "$d")" 42
  670. expect_version "a stale SKILL.md line count is caught" "states the size of SKILL.md wrongly" "$d"
  671. # Two lines stating the size. §1 of this file has lived by «exactly once» since v1.10.1 and
  672. # §4 did not inherit it; it now allows none or one and refuses two.
  673. d=$(fresh_copy)
  674. add_size_claim "$d" 999 42
  675. add_size_claim "$d" 888 41
  676. expect_version "a second line stating the size is caught, not silently ignored" "want at most 1" "$d"
  677. # The file grows and a claim that was correct when written stops being true. This is the
  678. # failure that will actually happen: SKILL.md is edited far more often than the sentence.
  679. d=$(fresh_copy)
  680. add_size_claim "$d" "$(skill_words "$d")" "$(skill_lines "$d")"
  681. printf '\n- A line added to SKILL.md long after the README stopped being re-read.\n' >> "$d/skills/ru-text/SKILL.md"
  682. expect_version "SKILL.md growing past its stated size is caught" "states the size of SKILL.md wrongly" "$d"
  683. printf 'selftest: check-dogfood.sh\n'
  684. expect_dogfood() { # $1=case-name $2=needle $3=dir
  685. name=$1; needle=$2; d=$3
  686. out=$(cd "$d" && ./tools/check-dogfood.sh 2>&1) && status=0 || status=$?
  687. if [ "$status" -eq 0 ]; then
  688. bad "$name — check-dogfood PASSED on corrupted input"
  689. elif printf '%s' "$out" | grep -qF "$needle"; then
  690. ok "$name"
  691. else
  692. bad "$name — failed, but not for the stated reason (wanted: $needle)"
  693. printf '%s\n' "$out" | sed 's/^/ /'
  694. fi
  695. }
  696. # The word guard, and it exists because the word came back. «онбординг» was written into the
  697. # README's description of ux-writing.md, corrected when a check found the file has no such
  698. # section, and written back in during a rewrite two days later. Numbers had a guard; names did
  699. # not.
  700. d=$(fresh_copy)
  701. python3 - "$d/README.md" <<'PYEOF'
  702. import io, sys
  703. p = sys.argv[1]
  704. s = io.open(p, encoding='utf-8').read()
  705. old = 'уведомления, диалоги подтверждения'
  706. assert s.count(old) == 1, 'anchor moved; fix the fixture'
  707. io.open(p, 'w', encoding='utf-8').write(s.replace(old, 'уведомления, онбординг'))
  708. PYEOF
  709. expect_dogfood "a file credited with a section it does not have is caught" "does not contain it" "$d"
  710. # The install prompt, quoted in three files. The divergence this catches was invisible: a
  711. # typography normaliser put two non-breaking spaces inside the copyable command, so the README
  712. # stopped matching the string tools/probe-install.sh hands a fresh agent — and the probe began
  713. # testing a string we do not publish. Two non-breaking spaces are exactly the mutation.
  714. d=$(fresh_copy)
  715. python3 - "$d/README.md" <<'PYEOF'
  716. import io, re, sys
  717. p = sys.argv[1]
  718. s = io.open(p, encoding='utf-8').read()
  719. m = re.search(r'Установи навык.*?ru-text\.', s, re.S)
  720. assert m, 'anchor moved; fix the fixture'
  721. io.open(p, 'w', encoding='utf-8').write(
  722. s.replace(m.group(0), m.group(0).replace('\u00a0вызывай', '\u00a0\u00a0вызывай', 1), 1))
  723. PYEOF
  724. expect_dogfood "an install prompt that drifted between files is caught" "must quote it identically" "$d"
  725. # The two install guides, which nothing compared. `62a164f` corrected «re-running the command
  726. # updates it» in INSTALL.md and not in INSTALL.en.md, and the English half carried the
  727. # disproved instruction for eleven days while the English README began asserting it was fixed.
  728. # Prose translates; COMMANDS do not, so the set of commands each file quotes must be the same,
  729. # and a command that exists in one guide and not the other is a half-applied correction.
  730. d=$(fresh_copy)
  731. python3 - "$d/INSTALL.en.md" <<'PYEOF'
  732. import io, sys
  733. p = sys.argv[1]
  734. s = io.open(p, encoding='utf-8').read()
  735. old = 'rsync -a --delete ru-text/skills/ru-text/ ~/.agents/skills/ru-text/'
  736. assert s.count(old) == 1, 'anchor moved; fix the fixture'
  737. io.open(p, 'w', encoding='utf-8').write(s.replace(old, 'cp -r ru-text/skills/ru-text ~/.agents/skills/'))
  738. PYEOF
  739. expect_dogfood "a command that exists in one install guide and not the other is caught" \
  740. "the install guides quote different commands" "$d"
  741. # The golden set's own size, stated in prose. Two AD-17 cases landed and the figure stayed at
  742. # 22 — a hand-maintained number in the file that documents the measurement, which is the defect
  743. # this release spent two days removing from the READMEs.
  744. d=$(fresh_copy)
  745. mkdir -p "$d/tools/golden/99-a-case-nobody-counted"
  746. : > "$d/tools/golden/99-a-case-nobody-counted/text.md"
  747. expect_dogfood "a golden case the README did not count is caught" "cases and holds" "$d"
  748. # The noun agrees with the numeral, and the guard used to hard-code one form. At 28 the file
  749. # correctly says «текстов», the pattern wanted «текста», and the guard reported «no longer
  750. # states how many cases the set holds» — failing on correct Russian, in the repository whose
  751. # subject is correct Russian. The case pins the READING, not the agreement: whatever form the
  752. # prose takes, the guard must come back with the NUMBER and compare it.
  753. d=$(fresh_copy)
  754. python3 - "$d/tools/golden/README.md" <<'PYEOF'
  755. import io, re, sys
  756. p = sys.argv[1]
  757. s = io.open(p, encoding='utf-8').read()
  758. # «Все 21 текст» — the singular form, which no fixed «текста» pattern can see.
  759. io.open(p, 'w', encoding='utf-8').write(re.sub(r'Все[\s\u00a0]+[0-9]+[\s\u00a0]+текст(а|ов)?',
  760. 'Все 21 текст', s, count=1))
  761. PYEOF
  762. expect_dogfood "a size stated in another numeral agreement is still read" "says 21 cases" "$d"
  763. # The word budget for the one file loaded on every turn. It was stated twice in the convention
  764. # file and checked nowhere, and it was FALSE while it stood: «under 600 words» over a file of
  765. # 615. A budget nobody can fail is not a budget. Two cases, one per direction: the count must
  766. # be read against the stated number, and a missing statement must not read as «within budget».
  767. d=$(fresh_copy)
  768. python3 - "$d/skills/ru-text/SKILL.md" <<'PYEOF'
  769. import io, sys
  770. p = sys.argv[1]
  771. s = io.open(p, encoding='utf-8').read()
  772. io.open(p, 'w', encoding='utf-8').write(s + '\n' + ('padding word ' * 200) + '\n')
  773. PYEOF
  774. expect_dogfood "a SKILL.md over its stated budget is caught" "over the stated budget" "$d"
  775. d=$(fresh_copy)
  776. python3 - "$d/.claude/CLAUDE.md" <<'PYEOF'
  777. import io, re, sys
  778. p = sys.argv[1]
  779. s = io.open(p, encoding='utf-8').read()
  780. io.open(p, 'w', encoding='utf-8').write(re.sub(r'at most \*\*[0-9]+ words\*\*', 'as small as it can be', s, count=1))
  781. PYEOF
  782. expect_dogfood "a budget removed from the convention file is caught" "no longer states a word budget" "$d"
  783. d=$(fresh_copy)
  784. if (cd "$d" && ./tools/check-dogfood.sh >/dev/null 2>&1); then
  785. ok "an untouched copy passes check-dogfood"
  786. else
  787. bad "an untouched copy FAILS check-dogfood — the cases below mean nothing"
  788. (cd "$d" && ./tools/check-dogfood.sh 2>&1) | sed 's/^/ /'
  789. fi
  790. # A consumer left behind when the catalogue moves. This is the defect the checker exists
  791. # for: four files went stale unnoticed the last time the number changed.
  792. d=$(fresh_copy)
  793. sed 's/Full stop-word catalog (92 entries)/Full stop-word catalog (91 entries)/' \
  794. "$d/skills/ru-text/SKILL.md" > "$d/v" && mv "$d/v" "$d/skills/ru-text/SKILL.md"
  795. expect_dogfood "a consumer left behind is caught" "and these do not" "$d"
  796. # A claim nobody registered. The explicit list is only safe because this guard exists.
  797. d=$(fresh_copy)
  798. # A file NOT on the list: appending to README.md would prove nothing, because the guard
  799. # skips listed files by design.
  800. printf 'The catalogue holds 92 entries.\n' > "$d/CONTRIBUTING.md"
  801. ( cd "$d" && git add -A ) >/dev/null 2>&1
  802. expect_dogfood "an unregistered claim is caught" "no claim is registered" "$d"
  803. # The corpus itself moving, with every claim left at the old number.
  804. d=$(fresh_copy)
  805. python3 - "$d/skills/ru-text/references/info-style.md" <<'PY'
  806. import io, re, sys
  807. p = sys.argv[1]
  808. s = io.open(p, encoding='utf-8').read()
  809. s = re.sub(r'(?m)^(## B\. Каталог стоп-слов.*\n)', r'\1\nвыдуманное|заменённое\n', s, count=1)
  810. io.open(p, 'w', encoding='utf-8').write(s)
  811. PY
  812. expect_dogfood "the corpus growing past its claims is caught" "and these do not" "$d"
  813. # The number of machine-text tells, stated six times across two READMEs and measured nowhere.
  814. # The count is not the number of rules in the file: AD-18 is a rule about human emphasis and
  815. # says so in its own body, so «eighteen rules, seventeen tells» are both true and a reader
  816. # counting headings gets the other number. A handoff note spent a session calling this a
  817. # contradiction. Three mutations: the corpus moving, one claim left behind, and a statement
  818. # nobody registered.
  819. d=$(fresh_copy)
  820. python3 - "$d/skills/ru-text/references/addenda.md" <<'PYEOF'
  821. import io, sys
  822. p = sys.argv[1]
  823. s = io.open(p, encoding='utf-8').read()
  824. old = '**Not a neuroslop tell, deliberately.**'
  825. assert s.count(old) == 1, 'anchor moved; fix the fixture'
  826. io.open(p, 'w', encoding='utf-8').write(s.replace(old, '**A tell like any other.**'))
  827. PYEOF
  828. expect_dogfood "a rule that stopped excluding itself is counted" "the corpus holds 18" "$d"
  829. d=$(fresh_copy)
  830. python3 - "$d/README.md" <<'PYEOF'
  831. import io, sys
  832. p = sys.argv[1]
  833. s = io.open(p, encoding='utf-8').read()
  834. old = 'Всего таких признаков 17'
  835. assert s.count(old) == 1, 'anchor moved; fix the fixture'
  836. io.open(p, 'w', encoding='utf-8').write(s.replace(old, 'Всего таких признаков 16'))
  837. PYEOF
  838. expect_dogfood "one README left behind when the tells move is caught" "the corpus holds 17" "$d"
  839. d=$(fresh_copy)
  840. printf 'Навык знает семнадцать признаков машинного текста.\n' > "$d/CONTRIBUTING.md"
  841. ( cd "$d" && git add -A ) >/dev/null 2>&1
  842. expect_dogfood "an unregistered statement of the tell count is caught" "no claim is registered" "$d"
  843. # The minimal pair for the hole a reviewer opened: the SAME sentence, inside a file that is
  844. # on the claim list. The first version skipped claimant files wholesale, so a claim could rot
  845. # inside the very README the checker was reading — the substring test found the phrase
  846. # somewhere in the file and nothing looked at the rest of it. Registered claims are now
  847. # subtracted from the LINE, and the sweep knows every number it can spell, not just today's:
  848. # a site left behind states the OLD count, which the current value's patterns cannot see.
  849. d=$(fresh_copy)
  850. printf '\nВ справочнике шестнадцать признаков машинного текста.\n' >> "$d/README.md"
  851. expect_dogfood "a stale count left inside a claimant README is caught" "no claim is registered" "$d"
  852. # Every claim row, one at a time. Mutating all six at once proves nothing: a checker holding
  853. # one row would still fail. A reviewer showed the list could be cut from six rows to two and
  854. # the fixtures stayed green — four of the six sites were pinned by nothing.
  855. for claim in '17 признаков машинного текста (нейрослоп)|17 признаков письма машины (нейрослоп)' \
  856. 'Всего таких признаков 17|Всего таких признаков ровно столько' \
  857. '17 признаков машинного текста с|17 признаков письма машины с' \
  858. 'seventeen tells of machine-written text|seventeen marks of machine-written text' \
  859. 'There are seventeen such tells in all|There are seventeen such items in all' \
  860. 'seventeen tells of machine writing, with|seventeen tells of machine prose, with'; do
  861. old=${claim%%|*}
  862. new=${claim#*|}
  863. d=$(fresh_copy)
  864. for f in README.md README.en.md; do
  865. python3 - "$d/$f" "$old" "$new" <<'PYEOF'
  866. import io, sys
  867. p, old, new = sys.argv[1], sys.argv[2], sys.argv[3]
  868. s = io.open(p, encoding='utf-8').read()
  869. if old in s:
  870. io.open(p, 'w', encoding='utf-8').write(s.replace(old, new, 1))
  871. PYEOF
  872. done
  873. expect_dogfood "a tell claim rephrased away is caught: ${old}" "the corpus holds 17" "$d"
  874. done
  875. # Every form the sweep must see, one at a time, in a file no claim list mentions. The pattern
  876. # set could be cut from four to one and the fixtures stayed green.
  877. for form in 'Навык знает семнадцать признаков.' \
  878. 'The skill knows seventeen tells.' \
  879. 'Всего 17 признаков машинного письма.' \
  880. 'It carries 17 tells.'; do
  881. d=$(fresh_copy)
  882. printf '%s\n' "$form" > "$d/CONTRIBUTING.md"
  883. ( cd "$d" && git add -A ) >/dev/null 2>&1
  884. expect_dogfood "an unregistered count in the form «$form» is caught" "no claim is registered" "$d"
  885. done
  886. # A heading whose dot was forgotten. `## AD-19 Foo` used to be invisible to the parser, so a
  887. # rule added with a typo was silently uncounted — a wrong PASS produced by a slip of the hand.
  888. d=$(fresh_copy)
  889. printf '\n## AD-19 A rule added with the dot forgotten\n\nBody.\n' \
  890. >> "$d/skills/ru-text/references/addenda.md"
  891. expect_dogfood "an AD heading missing its dot is still counted" "the corpus holds 18" "$d"
  892. # The Notion template's own size, which was stated four times in two languages and measured
  893. # nowhere. One of the four overstated by more than double: «9 признаков в 4 категориях» over
  894. # a section holding four tells and nine examples.
  895. d=$(fresh_copy)
  896. python3 - "$d/notion/ru-text-notion-skill.md" <<'PYEOF'
  897. import io, sys
  898. p = sys.argv[1]
  899. s = io.open(p, encoding='utf-8').read()
  900. old = '### Пустой зачин'
  901. assert s.count(old) == 1, 'anchor moved; fix the fixture'
  902. io.open(p, 'w', encoding='utf-8').write(s.replace(old, '### Пустой зачин\n\nA fifth tell.\n\n### Ещё один признак'))
  903. PYEOF
  904. expect_dogfood "a tell added to the Notion template its README did not count is caught" "does not say" "$d"
  905. d=$(fresh_copy)
  906. python3 - "$d/notion/README.md" <<'PYEOF'
  907. import io, sys
  908. p = sys.argv[1]
  909. s = io.open(p, encoding='utf-8').read()
  910. old = '- 30 anti-patterns'
  911. assert s.count(old) == 1, 'anchor moved; fix the fixture'
  912. io.open(p, 'w', encoding='utf-8').write(s.replace(old, '- 31 anti-patterns'))
  913. PYEOF
  914. expect_dogfood "a Notion count left behind in the English half is caught" "does not say" "$d"
  915. # A claim whose numeral CONTAINS the true one. The collision was found on the word forms —
  916. # «восемнадцать» holds «семнадцать» letter for letter, and a substring test passed a README
  917. # claiming EIGHTEEN over a reference holding seventeen. The Russian sites state the count in
  918. # digits now (§G.1 of editorial-grammar: ten and up are digits), so the case is pinned on the
  919. # digit form, where the same collision lives: «117» contains «17». The word forms `bounded()`
  920. # still knows are what catches a stale claim that arrives spelled out.
  921. d=$(fresh_copy)
  922. python3 - "$d/README.md" <<'PYEOF'
  923. import io, sys
  924. p = sys.argv[1]
  925. s = io.open(p, encoding='utf-8').read()
  926. old = 'Всего таких признаков 17'
  927. assert s.count(old) == 1, 'anchor moved; fix the fixture'
  928. io.open(p, 'w', encoding='utf-8').write(s.replace(old, 'Всего таких признаков 117'))
  929. PYEOF
  930. expect_dogfood "a claim whose numeral CONTAINS the true one is caught" "the corpus holds 17" "$d"
  931. # A claim written across a line break. Claims are prose and prose wraps: the roadmap says
  932. # «seventeen tells\nof machine prose», and a checker reading line by line calls it missing.
  933. d=$(fresh_copy)
  934. python3 - "$d/docs/roadmap-v3-grammar.md" <<'PYEOF'
  935. import io, sys
  936. p = sys.argv[1]
  937. s = io.open(p, encoding='utf-8').read()
  938. old = 'seventeen tells'
  939. assert s.count(old) == 1, 'anchor moved; fix the fixture'
  940. io.open(p, 'w', encoding='utf-8').write(s.replace(old, 'a good number of tells'))
  941. PYEOF
  942. expect_dogfood "a wrapped claim rephrased away is caught" "the corpus holds 17" "$d"
  943. # The rest of the sweep's forms, and the rest of the window. The pattern set was pinned at
  944. # two values out of the eleven it covers, and the «таких» / «such» alternative at none.
  945. for form in 'Навык знает семнадцать таких признаков.' \
  946. 'The skill holds seventeen such tells.' \
  947. 'Раньше их было пятнадцать признаков.' \
  948. 'Двадцать признаков — потолок.' \
  949. 'Навык знает девять признаков ИИ-текста.' \
  950. 'Once there were five tells.'; do
  951. d=$(fresh_copy)
  952. printf '%s\n' "$form" > "$d/CONTRIBUTING.md"
  953. ( cd "$d" && git add -A ) >/dev/null 2>&1
  954. expect_dogfood "an unregistered count in the form «$form» is caught" "no claim is registered" "$d"
  955. done
  956. # A claim is about the words, not about which codepoint separates them. `notion/README.md`
  957. # states «в 8 категориях», and the typography gate binds that single-letter preposition with
  958. # U+00A0 — so a byte-exact search stopped finding a sentence that had just been made MORE
  959. # correct. Two gates on one line, disagreeing about a space. Both directions, because the
  960. # live file carries the non-breaking one and a case that only reads it proves nothing.
  961. d=$(fresh_copy)
  962. python3 - "$d/notion/README.md" <<'PYEOF'
  963. import io, sys
  964. p = sys.argv[1]
  965. s = io.open(p, encoding='utf-8').read()
  966. old = '- 92 stop-words across'
  967. assert s.count(old) == 1, 'anchor moved; fix the fixture'
  968. # The claim list writes an ordinary space here, so putting a NON-breaking one in the file
  969. # is what a byte-exact reader cannot survive. The first draft did the reverse and left file
  970. # and template byte-identical — a fixture written for the scenario, not for the contract.
  971. io.open(p, 'w', encoding='utf-8').write(
  972. s.replace(old, '- 92' + chr(0xA0) + 'stop-words across'))
  973. PYEOF
  974. if (cd "$d" && ./tools/check-dogfood.sh >/dev/null 2>&1); then
  975. ok "a claim separated by an ordinary space is still found"
  976. else
  977. bad "a claim stops being found when its space changes codepoint"
  978. (cd "$d" && ./tools/check-dogfood.sh 2>&1) | grep -F FAIL | sed 's/^/ /'
  979. fi
  980. # A claim deleted outright, then reassembled by two unrelated paragraphs standing next to
  981. # each other. The codepoint-agnostic reader collapsed newlines too, so it read the whole file
  982. # as one line and called the claim present — the very failure its sibling matcher documents
  983. # a hundred lines below.
  984. d=$(fresh_copy)
  985. python3 - "$d/notion/README.md" <<'PYEOF'
  986. import io, sys
  987. p = sys.argv[1]
  988. s = io.open(p, encoding='utf-8').read()
  989. old = '- 92 stop-words across 8 categories with replacements'
  990. assert s.count(old) == 1, 'anchor moved; fix the fixture'
  991. # ONLY the catalogue claim is broken. The first draft split the line in a way that destroyed
  992. # the CATEGORY claim too, and `verify_claims` words both failures identically — so the case
  993. # passed on the collateral damage and would have reported success forever while the arm it
  994. # was written for stayed unheld. `across 8 categories` is left contiguous on purpose.
  995. io.open(p, 'w', encoding='utf-8').write(
  996. s.replace(old, 'Ends in - 92\n\nstop-words across 8 categories with replacements'))
  997. PYEOF
  998. # The needle names the family, not the number: writing today's 92 into it would plant the
  999. # hand-maintained figure this very checker exists to remove.
  1000. expect_dogfood "a claim reassembled across a paragraph break is not counted as present" \
  1001. "stop-word catalogue: the corpus says" "$d"
  1002. # The blank line as a hard boundary. Flattening the file lets a claim be found across a line
  1003. # wrap — and, without this, lets a claim DELETED outright be satisfied by two unrelated
  1004. # paragraphs happening to end and begin with the right words.
  1005. d=$(fresh_copy)
  1006. python3 - "$d/README.en.md" <<'PYEOF'
  1007. import io, sys
  1008. p = sys.argv[1]
  1009. s = io.open(p, encoding='utf-8').read()
  1010. old = 'There are seventeen such tells in all.'
  1011. assert s.count(old) == 1, 'anchor moved; fix the fixture'
  1012. io.open(p, 'w', encoding='utf-8').write(
  1013. s.replace(old, 'There are seventeen such\n\ntells in all.'))
  1014. PYEOF
  1015. expect_dogfood "a claim split by a blank line is not counted as present" "the corpus holds 17" "$d"
  1016. # The offset map. Both writing fixtures above are one line long, so nothing proved the sweep
  1017. # reports the line a wrapped hit actually sits on rather than the first line of the file.
  1018. d=$(fresh_copy)
  1019. printf 'Первая строка ни о чём.\n\nВторая строка ни о чём.\n\nЗдесь их семнадцать\nпризнаков.\n' \
  1020. > "$d/CONTRIBUTING.md"
  1021. ( cd "$d" && git add -A ) >/dev/null 2>&1
  1022. out=$(cd "$d" && ./tools/check-dogfood.sh 2>&1) && status=0 || status=$?
  1023. if [ "$status" -eq 0 ]; then
  1024. bad "a wrapped unregistered count is not caught at all"
  1025. elif printf '%s' "$out" | grep -qF 'CONTRIBUTING.md:5'; then
  1026. ok "a wrapped unregistered count is reported on the line it starts at"
  1027. else
  1028. bad "a wrapped unregistered count is reported on the wrong line"
  1029. printf '%s\n' "$out" | grep -F 'CONTRIBUTING.md' | sed 's/^/ /'
  1030. fi
  1031. # The exemption list names two lines of ordinary prose that put a numeral beside «признак».
  1032. # A list of exceptions that is not itself checked becomes a list of lies.
  1033. d=$(fresh_copy)
  1034. python3 - "$d/skills/ru-text/references/info-style.md" <<'PYEOF'
  1035. import io, sys
  1036. p = sys.argv[1]
  1037. s = io.open(p, encoding='utf-8').read()
  1038. old = 'Три признака слабого текста'
  1039. assert s.count(old) == 1, 'anchor moved; fix the fixture'
  1040. io.open(p, 'w', encoding='utf-8').write(s.replace(old, 'Признаки слабого текста'))
  1041. PYEOF
  1042. expect_dogfood "an exemption naming a line that is gone is caught" "drop the exemption" "$d"
  1043. # The other direction, and the one that makes an exemption dangerous: a phrase that occurs
  1044. # twice silences two lines while the checker only ever needed one silenced. One entry could
  1045. # then hide a real stale claim that happened to be worded the same way.
  1046. d=$(fresh_copy)
  1047. printf '\nТри признака слабого текста: повтор той же формулировки ниже по файлу.\n' \
  1048. >> "$d/skills/ru-text/references/info-style.md"
  1049. expect_dogfood "an exemption that silences more than one line is caught" "not a phrase" "$d"
  1050. # The skip list and the extension filter, each of which could be widened or narrowed with the
  1051. # suite green. One case per boundary, in a file no claim mentions.
  1052. d=$(fresh_copy)
  1053. printf '\nЗдесь семнадцать признаков.\n' >> "$d/INSTALL.md"
  1054. expect_dogfood "an unregistered count in a top-level file outside the skip list is caught" \
  1055. "no claim is registered" "$d"
  1056. d=$(fresh_copy)
  1057. printf '\n# seventeen tells are described here\n' >> "$d/skills/ru-text/agents/openai.yaml"
  1058. expect_dogfood "an unregistered count in a YAML file is caught" "no claim is registered" "$d"
  1059. # Past twenty the checker refuses instead of demanding «двадцать один признаков», which is
  1060. # ungrammatical — in the repository whose subject is grammar.
  1061. d=$(fresh_copy)
  1062. python3 - "$d/skills/ru-text/references/addenda.md" <<'PYEOF'
  1063. import io, sys
  1064. p = sys.argv[1]
  1065. s = io.open(p, encoding='utf-8').read()
  1066. s += ''.join('\n## AD-%d. Filler\n\nBody.\n' % k for k in range(20, 24))
  1067. io.open(p, 'w', encoding='utf-8').write(s)
  1068. PYEOF
  1069. expect_dogfood "a count past the word table is refused, not guessed" "knows no word form" "$d"
  1070. # Outside a git checkout the sweep cannot run, and must say so rather than emit a traceback.
  1071. d=$(fresh_copy)
  1072. mv "$d/.git" "$d/.git-disabled"
  1073. expect_dogfood "a copy that is not a git checkout is named, not crashed on" "not a git checkout" "$d"
  1074. # --print is advertised as «what it measured, and every place that claims it», and no case
  1075. # ever ran it. A branch nobody executes is a branch nobody maintains.
  1076. d=$(fresh_copy)
  1077. out=$(cd "$d" && ./tools/check-dogfood.sh --print 2>&1) && status=0 || status=$?
  1078. if [ "$status" -ne 0 ]; then
  1079. bad "--print exits non-zero"
  1080. elif printf '%s' "$out" | grep -qF 'machine-text tells: 17' \
  1081. && printf '%s' "$out" | grep -qF 'seventeen tells of machine writing'; then
  1082. ok "--print lists the tell count and every place that states it"
  1083. else
  1084. bad "--print does not list the tell claims it advertises"
  1085. printf '%s\n' "$out" | sed 's/^/ /'
  1086. fi
  1087. # The Notion gate measures four numbers, and three of them could be replaced by the constant
  1088. # they were measuring with the suite green. One case per number: change the TEMPLATE and the
  1089. # README's figure must stop matching — which a constant cannot notice.
  1090. d=$(fresh_copy)
  1091. python3 - "$d/notion/ru-text-notion-skill.md" <<'PYEOF'
  1092. import io, sys
  1093. p = sys.argv[1]
  1094. s = io.open(p, encoding='utf-8').read()
  1095. old = '| Ruble symbol after number | 1500 руб | 1 500 ₽ |'
  1096. assert s.count(old) == 1, 'anchor moved; fix the fixture'
  1097. io.open(p, 'w', encoding='utf-8').write(
  1098. s.replace(old, old + '\n| Degree sign | 20 C | 20 °C |'))
  1099. PYEOF
  1100. expect_dogfood "a typography row the Notion README did not count is caught" "does not say" "$d"
  1101. d=$(fresh_copy)
  1102. python3 - "$d/notion/ru-text-notion-skill.md" <<'PYEOF'
  1103. import io, re, sys
  1104. p = sys.argv[1]
  1105. s = io.open(p, encoding='utf-8').read()
  1106. head = '### Плеоназмы (убрать лишнее слово)'
  1107. assert s.count(head) == 1, 'anchor moved; fix the fixture'
  1108. i = s.index(head)
  1109. j = s.index('\n\n', s.index('|---', i))
  1110. io.open(p, 'w', encoding='utf-8').write(s[:j] + '\n| совместное сотрудничество | сотрудничество |' + s[j:])
  1111. PYEOF
  1112. expect_dogfood "an anti-pattern row the Notion README did not count is caught" "does not say" "$d"
  1113. d=$(fresh_copy)
  1114. python3 - "$d/notion/ru-text-notion-skill.md" <<'PYEOF'
  1115. import io, sys
  1116. p = sys.argv[1]
  1117. s = io.open(p, encoding='utf-8').read()
  1118. old = '| Объясню чётко, по делу. | Объясню. |'
  1119. assert s.count(old) == 1, 'anchor moved; fix the fixture'
  1120. io.open(p, 'w', encoding='utf-8').write(
  1121. s.replace(old, old + '\n| Скажу коротко и ясно. | Скажу. |'))
  1122. PYEOF
  1123. expect_dogfood "a tell example the Notion README did not count is caught" "does not say" "$d"
  1124. # The template's own heading is a consumer too: «Top 30» over thirty-one rows is the same
  1125. # defect one level in, and it sits inside the file the gate measures.
  1126. d=$(fresh_copy)
  1127. python3 - "$d/notion/ru-text-notion-skill.md" <<'PYEOF'
  1128. import io, sys
  1129. p = sys.argv[1]
  1130. s = io.open(p, encoding='utf-8').read()
  1131. old = '## Anti-Patterns: Top 30'
  1132. assert s.count(old) == 1, 'anchor moved; fix the fixture'
  1133. io.open(p, 'w', encoding='utf-8').write(s.replace(old, '## Anti-Patterns: Top 29'))
  1134. PYEOF
  1135. expect_dogfood "a template heading that miscounts its own section is caught" "does not head its section" "$d"
  1136. # The Russian half of the Notion README was held by nothing: «сверяет с обеими половинами»
  1137. # was true of the code and false of the cases.
  1138. d=$(fresh_copy)
  1139. python3 - "$d/notion/README.md" <<'PYEOF'
  1140. import io, sys
  1141. p = sys.argv[1]
  1142. s = io.open(p, encoding='utf-8').read()
  1143. import re
  1144. m = re.findall(r'^- (\d+) правил типографики', s, re.M)
  1145. assert len(m) == 1, 'anchor moved; fix the fixture'
  1146. old = '- %s правил типографики' % m[0]
  1147. io.open(p, 'w', encoding='utf-8').write(s.replace(old, '- %d правил типографики' % (int(m[0]) + 1)))
  1148. PYEOF
  1149. expect_dogfood "a Notion count left behind in the Russian half is caught" "does not say" "$d"
  1150. # The Notion gate's own reader, both directions. It was left byte-exact when its sibling
  1151. # stopped being so — two readers of one file disagreeing about what a space is — and then
  1152. # both had to learn that a newline is NOT one.
  1153. d=$(fresh_copy)
  1154. python3 - "$d/notion/README.md" <<'PYEOF'
  1155. import io, sys
  1156. p = sys.argv[1]
  1157. s = io.open(p, encoding='utf-8').read()
  1158. old = '- 30 anti-patterns'
  1159. assert s.count(old) == 1, 'anchor moved; fix the fixture'
  1160. io.open(p, 'w', encoding='utf-8').write(s.replace(old, '- 30' + chr(0xA0) + 'anti-patterns'))
  1161. PYEOF
  1162. if (cd "$d" && ./tools/check-dogfood.sh >/dev/null 2>&1); then
  1163. ok "a Notion claim separated by a non-breaking space is still found"
  1164. else
  1165. bad "the Notion reader still compares spaces by codepoint"
  1166. (cd "$d" && ./tools/check-dogfood.sh 2>&1) | grep -F FAIL | sed 's/^/ /'
  1167. fi
  1168. d=$(fresh_copy)
  1169. python3 - "$d/notion/README.md" <<'PYEOF'
  1170. import io, sys
  1171. p = sys.argv[1]
  1172. s = io.open(p, encoding='utf-8').read()
  1173. import re
  1174. m = re.findall(r'^- (\d+) typography rules \(always applied\)', s, re.M)
  1175. assert len(m) == 1, 'anchor moved; fix the fixture'
  1176. old = '- %s typography rules (always applied)' % m[0]
  1177. io.open(p, 'w', encoding='utf-8').write(
  1178. s.replace(old, '- %s\n\ntypography rules (always applied)' % m[0]))
  1179. PYEOF
  1180. expect_dogfood "a Notion claim reassembled across a paragraph break is not counted as present" \
  1181. "does not say" "$d"
  1182. printf 'selftest: build-release.sh\n'
  1183. expect_build() { # $1=case-name $2=needle $3=dir [$4=mode: check|build]
  1184. # NOT `${4:---check}`: that substitutes the default for an EMPTY fourth argument too, so
  1185. # the «dirty tree» case silently ran in --check mode and passed. A named mode cannot do
  1186. # that, and the mistake is invisible in the output when it happens.
  1187. name=$1; needle=$2; d=$3
  1188. if [ "${4:-check}" = "build" ]; then flag=""; else flag="--check"; fi
  1189. out=$(cd "$d" && ./tools/build-release.sh $flag 2>&1) && status=0 || status=$?
  1190. if [ "$status" -eq 0 ]; then
  1191. bad "$name — build-release PASSED on corrupted input"
  1192. elif printf '%s' "$out" | grep -qF "$needle"; then
  1193. ok "$name"
  1194. else
  1195. bad "$name — failed, but not for the stated reason (wanted: $needle)"
  1196. printf '%s\n' "$out" | tail -3 | sed 's/^/ /'
  1197. fi
  1198. }
  1199. d=$(fresh_copy)
  1200. if (cd "$d" && ./tools/build-release.sh --check >/dev/null 2>&1); then
  1201. ok "an untouched copy builds both assets and round-trips"
  1202. else
  1203. bad "an untouched copy FAILS build-release — the cases below mean nothing"
  1204. (cd "$d" && ./tools/build-release.sh --check 2>&1) | tail -4 | sed 's/^/ /'
  1205. fi
  1206. # A reference file dropped from the index. This is the failure with no symptom: the skill
  1207. # still installs, still activates, and answers from whatever corpus it has left.
  1208. d=$(fresh_copy)
  1209. ( cd "$d" && git rm -q --cached skills/ru-text/references/ux-writing.md ) >/dev/null 2>&1
  1210. expect_build "a reference file missing from the asset is caught" "in the asset" "$d"
  1211. # The build must not run at all without the skill it is named after.
  1212. d=$(fresh_copy)
  1213. ( cd "$d" && git rm -q --cached skills/ru-text/SKILL.md ) >/dev/null 2>&1
  1214. expect_build "a staged tree with no ru-text/SKILL.md is caught" "no ru-text/SKILL.md" "$d"
  1215. # Without --check the tree must be clean: an artefact built from a dirty tree matches no
  1216. # commit, and the version inside it is then a claim about code that does not exist.
  1217. d=$(fresh_copy)
  1218. printf 'scratch\n' > "$d/skills/ru-text/references/scratch.md"
  1219. expect_build "a dirty tree refuses a real build" "working tree is dirty" "$d" build
  1220. printf 'selftest: gates.sh\n'
  1221. # gates.sh calls this file, so a case that ran it unmodified would re-enter the selftest
  1222. # forever. The copy's selftest is replaced by a stub whose exit code the case chooses:
  1223. # what is under test here is the ORCHESTRATION — that a red checker stops the run, that a
  1224. # green tree does not — never the checker being stubbed.
  1225. # The stub prints a summary line as well as choosing an exit code, because gates.sh now
  1226. # requires one: a run that printed no summary did not finish, whatever it exited with.
  1227. stub_selftest() {
  1228. printf '#!/bin/sh\nprintf "selftest: 1 passed, %s failed\\n"\nexit %s\n' "$2" "$2" \
  1229. > "$1/tools/selftest.sh"
  1230. chmod +x "$1/tools/selftest.sh"
  1231. }
  1232. d=$(fresh_copy); stub_selftest "$d" 0
  1233. if "$d/tools/gates.sh" >/dev/null 2>&1; then
  1234. ok "gates.sh passes on an untouched copy"
  1235. else
  1236. bad "gates.sh FAILS on an untouched copy — every case below means nothing"
  1237. "$d/tools/gates.sh" 2>&1 | sed 's/^/ /'
  1238. fi
  1239. d=$(fresh_copy); stub_selftest "$d" 1
  1240. if "$d/tools/gates.sh" >/dev/null 2>&1; then
  1241. bad "gates.sh passed although a checker exited non-zero"
  1242. else
  1243. ok "a red checker stops gates.sh"
  1244. fi
  1245. # A suite that DIED mid-run: status 0, no summary. Not hypothetical — an uninitialised
  1246. # counter aborted this very file under `set -eu`, and its EXIT trap turned the abort into
  1247. # a zero. gates.sh read it as a pass, and every gate below it ran on a lie.
  1248. d=$(fresh_copy)
  1249. printf '#!/bin/sh\nprintf " ok one case\\n"\nexit 0\n' > "$d/tools/selftest.sh"
  1250. chmod +x "$d/tools/selftest.sh"
  1251. if "$d/tools/gates.sh" >/dev/null 2>&1; then
  1252. bad "gates.sh passed although the selftest exited 0 without finishing"
  1253. else
  1254. ok "a selftest that exits 0 without a summary stops gates.sh"
  1255. fi
  1256. # The no-loss gate is the LAST step, so a script that quietly stopped earlier would still
  1257. # pass the case above. Losing a corpus line must reach it.
  1258. #
  1259. # The line is taken from typography.md, which has not changed since v1.10.1, and NOT from
  1260. # addenda.md. The gate compares against the pinned baseline, so it can only miss an atom
  1261. # the baseline HAS: trimming a line added after v1.10.1 is invisible to it by design, and
  1262. # this case silently stopped testing anything the day addenda.md grew a new last line.
  1263. #
  1264. # A named rule, not `sed '$d'`. The last LINE of a reference file is not necessarily the
  1265. # last ATOM of it — typography.md ends on blank lines, so deleting the last line deleted
  1266. # nothing the gate could miss, and the case passed the corpus as intact while asserting the
  1267. # opposite. R1 is the first typography rule and has been in the corpus since long before
  1268. # the pinned baseline.
  1269. d=$(fresh_copy); stub_selftest "$d" 0
  1270. sed '/^R1\. Основные кавычки/d' "$d/skills/ru-text/references/typography.md" > "$d/trimmed" \
  1271. && mv "$d/trimmed" "$d/skills/ru-text/references/typography.md"
  1272. grep -q '^R1\. Основные кавычки' "$d/skills/ru-text/references/typography.md" \
  1273. && bad "the fixture did not remove R1 — the case below proves nothing"
  1274. if "$d/tools/gates.sh" >/dev/null 2>&1; then
  1275. bad "gates.sh passed on a corpus that lost a line — it never reached the no-loss gate"
  1276. else
  1277. ok "a corpus that lost a line stops gates.sh"
  1278. fi
  1279. # gates.sh and the CI workflow are two copies of one sequence, kept in step by hand. Two
  1280. # copies drift; this is the case that says so out loud. Comments are stripped first, so
  1281. # naming a checker in prose does not count as running it.
  1282. CI=$ROOT/.github/workflows/gates.yml
  1283. # The character class covers what a checker may actually be named. It was `[a-z0-9-]+`,
  1284. # which cannot see `tools/check_new.sh`, `tools/checkNew.sh`, or anything in a subdirectory
  1285. # — three ways to add a checker to one file and not the other with this case still green.
  1286. checkers() { sed 's/#.*//' "$1" | grep -oE 'tools/[A-Za-z0-9._/-]+\.sh' | sort -u; }
  1287. if [ ! -f "$CI" ]; then
  1288. bad "the CI workflow is missing — gates.sh has nothing to be in step with"
  1289. elif [ "$(checkers "$ROOT/tools/gates.sh")" = "$(checkers "$CI")" ]; then
  1290. ok "gates.sh invokes exactly the checkers CI invokes"
  1291. else
  1292. bad "gates.sh and CI disagree about which checkers run"
  1293. printf ' gates.sh: %s\n' "$(checkers "$ROOT/tools/gates.sh" | tr '\n' ' ')"
  1294. printf ' CI: %s\n' "$(checkers "$CI" | tr '\n' ' ')"
  1295. fi
  1296. # Naming a checker is not running it. A checker whose failure is swallowed — `|| true`,
  1297. # or the line replaced by an `echo` that still mentions it — leaves the case above green,
  1298. # because that case compares NAMES. This one compares the shape of the invocation: every
  1299. # line in gates.sh that runs a checker must hand its failure to `fail`, and there must be
  1300. # as many such lines as there are checkers, so that deleting one is not a way to pass.
  1301. # `if ! tools/x.sh; then :; fi` runs a checker too, and the anchor used to miss it — a
  1302. # swallowed failure in that shape was invisible to both arms of this case.
  1303. guarded_invocations() { sed 's/#.*//' "$1" | grep -E '^[[:space:]]*(if[[:space:]]+!?[[:space:]]*)?tools/[A-Za-z0-9._/-]+\.sh' || true; }
  1304. inv=$(guarded_invocations "$ROOT/tools/gates.sh")
  1305. inv_n=$(printf '%s\n' "$inv" | grep -c . || true)
  1306. unguarded=$(printf '%s\n' "$inv" | grep -c -v '|| fail' || true)
  1307. [ -z "$inv" ] && inv_n=0 && unguarded=0
  1308. if [ "$inv_n" -ge 4 ] && [ "$unguarded" -eq 0 ]; then
  1309. ok "every checker gates.sh runs hands its failure to fail (${inv_n} invocations)"
  1310. else
  1311. bad "gates.sh: ${inv_n} checker invocations, ${unguarded} of them unguarded (want >=4 and 0)"
  1312. printf '%s\n' "$inv" | sed 's/^/ /'
  1313. fi
  1314. # The executable-and-parseable gate is the one step of gates.sh no name comparison can see:
  1315. # it is written as the glob `tools/*.sh`, which matches no checker path. It was removable
  1316. # with every case still green. Tested by behaviour rather than by grep — a checker that
  1317. # cannot be parsed, in a subdirectory, must stop the run.
  1318. d=$(fresh_copy); stub_selftest "$d" 0
  1319. mkdir -p "$d/tools/sub"
  1320. printf '#!/bin/sh\nif then fi\n' > "$d/tools/sub/broken.sh"; chmod +x "$d/tools/sub/broken.sh"
  1321. out=$("$d/tools/gates.sh" 2>&1) && st=0 || st=$?
  1322. if [ "$st" -eq 0 ]; then
  1323. bad "an unparseable checker did not stop gates.sh — the syntax gate is gone or shallow"
  1324. elif printf '%s' "$out" | grep -qF 'syntax error: tools/sub/broken.sh'; then
  1325. ok "an unparseable checker in a subdirectory stops gates.sh, and says which one"
  1326. else
  1327. bad "gates.sh failed, but not on the syntax gate — the case proves nothing"
  1328. printf '%s\n' "$out" | tail -3 | sed 's/^/ /'
  1329. fi
  1330. # The syntax gate must speak the runner's shell. /bin/sh is bash 3.2 on macOS and dash on
  1331. # the ubuntu runner, so a bashism passed locally and failed in CI — the divergence a local
  1332. # gate exists to catch first. Skipped, loudly, where dash is absent: a case that cannot run
  1333. # must not report as a case that passed.
  1334. if command -v dash >/dev/null 2>&1; then
  1335. d=$(fresh_copy); stub_selftest "$d" 0
  1336. printf '#!/bin/sh\narr=(a b)\necho "$arr"\n' > "$d/tools/bashism.sh"; chmod +x "$d/tools/bashism.sh"
  1337. if "$d/tools/gates.sh" >/dev/null 2>&1; then
  1338. bad "a bashism in a checker passed the syntax gate — sh -n instead of dash -n?"
  1339. else
  1340. ok "a bashism in a checker is caught locally, as it would be on the runner"
  1341. fi
  1342. else
  1343. note "dash absent — the bashism case did not run (the runner's /bin/sh is dash)"
  1344. fi
  1345. # Static, and said to be static: $ROOT must reach python through argv, never spliced into
  1346. # the source. A repository checked out into a directory whose name contains an apostrophe
  1347. # closes the string literal and runs what follows; the milder half is a false «the corpus
  1348. # is no longer NFC» about a file that is fine.
  1349. spliced=$(grep -cE "glob\.glob\('\\\$ROOT|open\('\\\$ROOT|'\\\$ROOT/" "$ROOT/tools/selftest.sh" || true)
  1350. viaargv=$(grep -cE "^(elif )?python3 - \"\\\$ROOT\"|^ *folded=\\\$\(python3 - \"\\\$ROOT\"" "$ROOT/tools/selftest.sh" || true)
  1351. if [ "$spliced" -eq 0 ] && [ "$viaargv" -ge 2 ]; then
  1352. ok "both python blocks take \$ROOT through argv, none splices it into the source"
  1353. else
  1354. bad "\$ROOT spliced into python source (${spliced} sites) or argv form lost (${viaargv} of 2)"
  1355. fi
  1356. # The parity case compares two sets built by ONE regex, so narrowing that regex blinds both
  1357. # sides at once and the case cannot notice. Pin its breadth directly, on the names that
  1358. # broke it: an underscore, a camel hump, a subdirectory.
  1359. probe=$(printf 'tools/check_new.sh\ntools/checkNew.sh\ntools/sub/deep.sh\n' \
  1360. | grep -cE 'tools/[A-Za-z0-9._/-]+\.sh' || true)
  1361. [ "$probe" -eq 3 ] && ok "the checker-name pattern covers _, camelCase and subdirectories" \
  1362. || bad "the checker-name pattern matched $probe of 3 — divergence would go unseen"
  1363. # CI can stop RUNNING a checker while still naming it, and the name comparison would stay
  1364. # green. Every checker named in the workflow must sit on a line that runs it.
  1365. if [ -f "$CI" ]; then
  1366. badline=$(sed 's/#.*//' "$CI" | grep -E 'tools/[A-Za-z0-9._/-]+\.sh' \
  1367. | grep -vE '^[[:space:]]*(run:[[:space:]]*)?(\$\()?(sha256sum|for|\[|tools/)' | grep -c . || true)
  1368. [ "$badline" -eq 0 ] && ok "every checker the CI workflow names is on a line that runs it" \
  1369. || bad "CI names $badline checker(s) outside a running line"
  1370. fi
  1371. # The baseline pin is written out twice for the same reason, and a stale copy is worse
  1372. # than none: the local gate would keep vouching for a baseline the repository no longer has.
  1373. #
  1374. # Comments are stripped from BOTH sides. Stripping only the local one meant a CI pin block
  1375. # commented out — the check gone, the text still there — compared equal and stayed green.
  1376. if [ -f "$CI" ]; then
  1377. hashes() { sed 's/#.*//' "$1" | grep -oE '[0-9a-f]{64}' | sort -u; }
  1378. pinpath() { sed 's/#.*//' "$1" | grep -oE 'tools/baseline/[A-Za-z0-9.-]+' | sort -u; }
  1379. pin_local=$(hashes "$ROOT/tools/gates.sh"); pin_ci=$(hashes "$CI")
  1380. path_local=$(pinpath "$ROOT/tools/gates.sh"); path_ci=$(pinpath "$CI")
  1381. if [ -n "$pin_local" ] && [ -n "$path_local" ] &&
  1382. [ "$pin_local" = "$pin_ci" ] && [ "$path_local" = "$path_ci" ]; then
  1383. ok "the baseline pin in gates.sh matches CI, file and hash"
  1384. else
  1385. bad "baseline pin differs: gates.sh $path_local $pin_local / CI $path_ci $pin_ci"
  1386. fi
  1387. fi
  1388. printf 'selftest: check-typography.sh\n'
  1389. # The checker shipped green over eight real defects, because both halves of its R30 pattern
  1390. # were narrower than the rule: the letter set held lowercase only, and the follower class
  1391. # demanded a Cyrillic letter or a digit next.
  1392. #
  1393. # The two cases below pin one half EACH, and their shapes are chosen for that and nothing else.
  1394. # The first pair written here failed this requirement — «В WSL-сессиях» and «В [README]» both
  1395. # combine a capital preposition with a non-Cyrillic follower, so either mutation killed both
  1396. # and neither hand was actually guarded. Verified by mutation: restoring the lowercase-only set
  1397. # must break the FIRST case only, and restoring the narrow follower class the SECOND only.
  1398. # capital + Cyrillic follower -> isolates the letter set
  1399. # lowercase + non-letter -> isolates the follower class
  1400. expect_typo() { # $1=case-name $2=needle $3=dir
  1401. name=$1; needle=$2; d=$3
  1402. out=$(cd "$d" && ./tools/check-typography.sh 2>&1) && st=0 || st=$?
  1403. if [ "$st" -eq 0 ]; then
  1404. bad "$name — check-typography PASSED on corrupted input"
  1405. elif printf '%s' "$out" | grep -qF "$needle"; then
  1406. ok "$name"
  1407. else
  1408. bad "$name — failed, but not for the stated reason (wanted: $needle)"
  1409. printf '%s\n' "$out" | sed 's/^/ /'
  1410. fi
  1411. }
  1412. # The Notion setup guide joined the checked list, and it is the only bilingual page there.
  1413. # Two cases, one per direction: a defect on its Russian half is caught, and correct English
  1414. # on its English half is not — «2,000+ linguistic atoms» is a comma between digit groups
  1415. # that R32/R53 forbids in Russian and English style requires.
  1416. d=$(fresh_copy)
  1417. python3 - "$d/notion/README.md" <<'PYEOF'
  1418. import io, sys
  1419. p = sys.argv[1]
  1420. s = io.open(p, encoding='utf-8').read()
  1421. old = 'Шаблон навыка' + chr(0xA0) + '— сжатая'
  1422. assert s.count(old) == 1, 'anchor moved; fix the fixture'
  1423. io.open(p, 'w', encoding='utf-8').write(s.replace(old, 'Шаблон навыка — сжатая'))
  1424. PYEOF
  1425. expect_typo "a defect on the Notion guide's Russian half is caught" "R16/R44" "$d"
  1426. # The tilde carve-out. The only tilde case plants into README.md — monolingual, and on a line
  1427. # carrying Cyrillic — a path the bilingual skip can never reach, so nothing distinguished
  1428. # «checked before the skip» from «checked after it». Here it sits on the English half.
  1429. d=$(fresh_copy)
  1430. python3 - "$d/notion/README.md" <<'PYEOF'
  1431. import io, sys
  1432. p = sys.argv[1]
  1433. s = io.open(p, encoding='utf-8').read()
  1434. anchor = '## Setup'
  1435. assert s.count(anchor) >= 1, 'anchor moved; fix the fixture'
  1436. io.open(p, 'w', encoding='utf-8').write(
  1437. s.replace(anchor, 'A placeholder that outlived a tool round-trip: 5~000 atoms.\n\n' + anchor, 1))
  1438. PYEOF
  1439. expect_typo "a stray tilde on the English half is still caught" "stray-tilde" "$d"
  1440. # The per-file conjunct. Drop `path in BILINGUAL` and the skip goes GLOBAL: every Cyrillic-free
  1441. # line of README.md and INSTALL.md silently loses R32/R53, R16/R44 and the ellipsis rule. The
  1442. # header states that contract in words — «on a monolingual Russian page a line without Cyrillic
  1443. # can still be a digit group that R32/R53 governs» — and a sentence is not a mechanism.
  1444. d=$(fresh_copy)
  1445. printf '\n| MCP | 2,000 | 5 000 |\n' >> "$d/README.md"
  1446. expect_typo "a digit group on a Cyrillic-free line of a monolingual page is still checked" \
  1447. "R32/R53" "$d"
  1448. # A tilde that is a home directory is followed by a slash, and the carve-out now runs on both
  1449. # halves of a bilingual page — so the one thing keeping `~/.agents/skills` out of the report is
  1450. # a single lookahead nothing exercised.
  1451. d=$(fresh_copy)
  1452. python3 - "$d/README.md" <<'PYEOF'
  1453. import io, sys
  1454. # Written by codepoint: the first draft of this fixture broke R30 twice on its own single-letter
  1455. # prepositions, so the case failed on the fixture rather than on the thing it tests.
  1456. nb = chr(0xA0)
  1457. line = '\nНавык лежит в' + nb + 'каталоге ~/.agents/skills и' + nb + 'читается оттуда.\n'
  1458. io.open(sys.argv[1], 'a', encoding='utf-8').write(line)
  1459. PYEOF
  1460. if (cd "$d" && ./tools/check-typography.sh >/dev/null 2>&1); then
  1461. ok "a tilde that opens a home directory is not reported as a mangled space"
  1462. else
  1463. bad "a home directory is reported as a stray tilde"
  1464. (cd "$d" && ./tools/check-typography.sh 2>&1) | sed 's/^/ /'
  1465. fi
  1466. # --print is the scope contract in machine-readable form, and nothing ran it. The bilingual
  1467. # list was added to it in the same session that found the file missing from the checked list.
  1468. d=$(fresh_copy)
  1469. out=$(cd "$d" && ./tools/check-typography.sh --print 2>&1) && status=0 || status=$?
  1470. if [ "$status" -ne 0 ]; then
  1471. bad "check-typography --print exits non-zero"
  1472. # INSTALL.md, not notion/README.md: the latter appears in BOTH blocks, so the bilingual
  1473. # list alone satisfied it and the checked-files half was held by nothing.
  1474. elif printf '%s' "$out" | grep -qF 'INSTALL.md' \
  1475. && printf '%s' "$out" | grep -qF 'bilingual'; then
  1476. ok "check-typography --print discloses the checked files and the bilingual ones"
  1477. else
  1478. bad "check-typography --print does not disclose the scope it advertises"
  1479. printf '%s\n' "$out" | sed 's/^/ /'
  1480. fi
  1481. d=$(fresh_copy)
  1482. python3 - "$d/notion/README.md" <<'PYEOF'
  1483. import io, sys
  1484. p = sys.argv[1]
  1485. s = io.open(p, encoding='utf-8').read()
  1486. anchor = '## Setup'
  1487. assert s.count(anchor) >= 1, 'anchor moved; fix the fixture'
  1488. io.open(p, 'w', encoding='utf-8').write(
  1489. s.replace(anchor, 'A set of 3,000+ atoms is described below - see the guide.\n\n' + anchor, 1))
  1490. PYEOF
  1491. if (cd "$d" && ./tools/check-typography.sh >/dev/null 2>&1); then
  1492. ok "correct English on the Notion guide's English half is not flagged"
  1493. else
  1494. bad "English prose on a bilingual page is measured by Russian rules"
  1495. (cd "$d" && ./tools/check-typography.sh 2>&1) | sed 's/^/ /'
  1496. fi
  1497. d=$(fresh_copy)
  1498. if (cd "$d" && ./tools/check-typography.sh >/dev/null 2>&1); then
  1499. ok "an untouched copy passes check-typography"
  1500. else
  1501. bad "an untouched copy FAILS check-typography — the cases below mean nothing"
  1502. (cd "$d" && ./tools/check-typography.sh 2>&1) | sed 's/^/ /'
  1503. fi
  1504. # A CAPITAL preposition, which the first pattern never tested — and which is where a Russian
  1505. # sentence most often starts one.
  1506. d=$(fresh_copy)
  1507. python3 - "$d/INSTALL.md" <<'PYEOF'
  1508. import io, sys
  1509. p = sys.argv[1]
  1510. s = io.open(p, encoding='utf-8').read()
  1511. io.open(p, 'w', encoding='utf-8').write(s.replace('В\u00a0приложении', 'В приложении', 1))
  1512. PYEOF
  1513. expect_typo "a capital single-letter preposition is caught" "single-letter «В»" "$d"
  1514. # A preposition followed by something that is not a Cyrillic letter — a markdown link. The
  1515. # first pattern required a letter or digit next and let every one of these through.
  1516. d=$(fresh_copy)
  1517. python3 - "$d/INSTALL.md" <<'PYEOF'
  1518. import io, sys
  1519. p = sys.argv[1]
  1520. s = io.open(p, encoding='utf-8').read()
  1521. io.open(p, 'w', encoding='utf-8').write(s.replace('и\u00a0**`.agents/skills/`**', 'и **`.agents/skills/`**', 1))
  1522. PYEOF
  1523. expect_typo "a preposition before a non-letter is caught" "single-letter «и»" "$d"
  1524. # The two defects that actually shipped, kept as regression cases.
  1525. d=$(fresh_copy)
  1526. python3 - "$d/README.md" <<'PYEOF'
  1527. import io, sys
  1528. p = sys.argv[1]
  1529. s = io.open(p, encoding='utf-8').read()
  1530. s = s.replace('машинного текста', 'машинного~текста', 1)
  1531. io.open(p, 'w', encoding='utf-8').write(s)
  1532. PYEOF
  1533. expect_typo "a literal tilde standing in for a non-breaking space is caught" "literal ~" "$d"
  1534. d=$(fresh_copy)
  1535. python3 - "$d/README.md" <<'PYEOF'
  1536. import io, sys
  1537. p = sys.argv[1]
  1538. s = io.open(p, encoding='utf-8').read()
  1539. io.open(p, 'w', encoding='utf-8').write(s.replace('\u00a0\u2014', ' \u2014', 1))
  1540. PYEOF
  1541. expect_typo "an ordinary space before an em dash is caught" "before an em dash" "$d"
  1542. # Digit grouping. This case exists because it ESCAPED: the checker was green over «более
  1543. # 2 000 атомов» set with an ordinary space, since nothing looked at digit groups at all, and
  1544. # a judge found it by reading the file rather than by running the gate.
  1545. d=$(fresh_copy)
  1546. python3 - "$d/README.md" <<'PY'
  1547. import io, sys
  1548. p = sys.argv[1]
  1549. s = io.open(p, encoding='utf-8').read()
  1550. io.open(p, 'w', encoding='utf-8').write(s.replace('2\u00a0000', '2 000', 1))
  1551. PY
  1552. expect_typo "an ordinary space between digit groups is caught" "between digit groups" "$d"
  1553. printf 'selftest: check-assets.sh\n'
  1554. # The checker was written the day the OpenAI portal refused our upload \u2014 \u00abImage must be
  1555. # square; provided image is 981x993\u00bb \u2014 on a file that had been that shape since it was drawn.
  1556. # Its three assertions are mutated one at a time below, because a fixture that breaks two at
  1557. # once proves neither.
  1558. expect_assets() { # $1=case-name $2=needle $3=dir
  1559. name=$1; needle=$2; d=$3
  1560. out=$(cd "$d" && ./tools/check-assets.sh 2>&1) && st=0 || st=$?
  1561. if [ "$st" -eq 0 ]; then
  1562. bad "$name \u2014 check-assets PASSED on corrupted input"
  1563. elif printf '%s' "$out" | grep -qF "$needle"; then
  1564. ok "$name"
  1565. else
  1566. bad "$name \u2014 failed, but not for the stated reason (wanted: $needle)"
  1567. printf '%s\n' "$out" | sed 's/^/ /'
  1568. fi
  1569. }
  1570. d=$(fresh_copy)
  1571. if (cd "$d" && ./tools/check-assets.sh >/dev/null 2>&1); then
  1572. ok "an untouched copy passes check-assets"
  1573. else
  1574. bad "an untouched copy FAILS check-assets \u2014 the cases below mean nothing"
  1575. (cd "$d" && ./tools/check-assets.sh 2>&1) | sed 's/^/ /'
  1576. fi
  1577. # 1. Not square. One pixel column is enough; the portal measures, it does not eyeball.
  1578. d=$(fresh_copy)
  1579. python3 - "$d/logo-round.png" <<'PY'
  1580. import struct, sys, zlib
  1581. # Rewrite the IHDR width, and its CRC with it, without decoding the image: this keeps the
  1582. # case about squareness rather than about whatever an encoder would change on a round-trip.
  1583. p = sys.argv[1]
  1584. b = bytearray(open(p, 'rb').read())
  1585. w, h = struct.unpack('>II', bytes(b[16:24]))
  1586. b[16:20] = struct.pack('>I', w - 1)
  1587. b[29:33] = struct.pack('>I', zlib.crc32(bytes(b[12:29])) & 0xffffffff)
  1588. open(p, 'wb').write(bytes(b))
  1589. PY
  1590. expect_assets "an image that is one pixel off square is caught" "not square" "$d"
  1591. # 2. A reference to a file that is not there. This is the silent one: awesome-codex-plugins
  1592. # fetches the icon, fails, and publishes the listing without it \u2014 no error anywhere.
  1593. d=$(fresh_copy)
  1594. mv "$d/assets/icon.png" "$d/assets/icon-renamed.png"
  1595. expect_assets "a manifest pointing at a file that is not there is caught" "missing file" "$d"
  1596. # 3. Over the 50 KB icon ceiling that awesome-codex-plugins enforces in its own CI.
  1597. d=$(fresh_copy)
  1598. cp "$d/logo-round.png" "$d/assets/icon.png"
  1599. expect_assets "an icon over the 50 KB ceiling is caught" "icon over" "$d"
  1600. # The base a relative path resolves from differs by vendor, and the first version of the
  1601. # checker assumed one convention for both \u2014 reporting Codex's images as missing while its
  1602. # own bundle resolved them fine. This pins that the Cursor manifest's `../` form is still
  1603. # understood: break the file it reaches, and the checker must say so.
  1604. d=$(fresh_copy)
  1605. python3 - "$d/logo-round.png" <<'PY'
  1606. import struct, sys, zlib
  1607. p = sys.argv[1]
  1608. b = bytearray(open(p, 'rb').read())
  1609. w, h = struct.unpack('>II', bytes(b[16:24]))
  1610. b[20:24] = struct.pack('>I', h - 1)
  1611. b[29:33] = struct.pack('>I', zlib.crc32(bytes(b[12:29])) & 0xffffffff)
  1612. open(p, 'wb').write(bytes(b))
  1613. PY
  1614. expect_assets "a path written relative to the manifest's own directory still resolves" \
  1615. ".cursor-plugin/plugin.json" "$d"
  1616. # Initials. Found by a judge reading the sources list after three green gates had run over
  1617. # it — the fourth rule this checker did not name. The pattern of the misses is worth stating:
  1618. # every one was a rule the corpus has and the checker did not, never a rule it got wrong.
  1619. d=$(fresh_copy)
  1620. python3 - "$d/README.md" <<'PYEOF'
  1621. import io, sys
  1622. p = sys.argv[1]
  1623. s = io.open(p, encoding='utf-8').read()
  1624. io.open(p, 'w', encoding='utf-8').write(s.replace('А.\u00a0Э.\u00a0Мильчин', 'А. Э. Мильчин', 1))
  1625. PYEOF
  1626. expect_typo "an ordinary space after an initial is caught" "after an initial" "$d"
  1627. printf 'selftest: measure-prose-shape.py\n'
  1628. # The instrument that will decide whether the flattening is real
  1629. # (docs/roadmap-v2.1-conservation.md). If it cannot tell a flat text from a varied one, the
  1630. # measurement it produces is worthless and every rule built on it is built on nothing.
  1631. #
  1632. # Two synthetic texts of the SAME word count, differing only in shape: one is eight
  1633. # eight-word declaratives, the other is the same content in sentences of 3 to 22 words with
  1634. # subordination. The instrument must separate them on the coefficient of variation, and it
  1635. # must NOT separate them on total words — a checker that merely counts words would pass a
  1636. # CV assertion by accident, so both directions are asserted.
  1637. d=$(mktemp -d "$TMPROOT/shape.XXXXXX")
  1638. cat > "$d/flat.md" <<'FLATEOF'
  1639. Система замедляется под нагрузкой. Очередь растёт линейно до предела. Дальше начинаются
  1640. отказы на каждом запросе. Мы сняли замеры на трёх стендах. Результат совпал во всех трёх
  1641. случаях. Порог держится около восьмисот запросов в секунду. Ниже порога задержка почти не
  1642. меняется. Выше порога задержка растёт очень быстро.
  1643. FLATEOF
  1644. cat > "$d/varied.md" <<'VARIEDEOF'
  1645. Система замедляется. Очередь растёт линейно до предела, за которым начинаются отказы, и
  1646. происходит это не постепенно, а сразу на всех запросах разом. Мы сняли замеры. Результат
  1647. совпал на трёх стендах, хотя стенды собирали разные люди и в разное время. Порог держится
  1648. около восьмисот запросов в секунду. Ниже него задержка почти не меняется, выше растёт так
  1649. быстро, что пользователь замечает это раньше любого монитора.
  1650. VARIEDEOF
  1651. flat_cv=$(python3 tools/measure-prose-shape.py "$d/flat.md" \
  1652. | awk '/^ длина предложения/ {print $5}')
  1653. var_cv=$(python3 tools/measure-prose-shape.py "$d/varied.md" \
  1654. | awk '/^ длина предложения/ {print $5}')
  1655. if [ -z "$flat_cv" ] || [ -z "$var_cv" ]; then
  1656. bad "measure-prose-shape printed no CV for sentence length"
  1657. elif awk -v a="$flat_cv" -v b="$var_cv" 'BEGIN{exit !(b > a * 1.5)}'; then
  1658. ok "a varied text measures a visibly higher CV than a flat one ($var_cv vs $flat_cv)"
  1659. else
  1660. bad "measure-prose-shape cannot separate flat from varied prose: CV $flat_cv vs $var_cv"
  1661. fi
  1662. # The two full-stop guards, mutated SEPARATELY, because a fixture that exercises both at
  1663. # once proves neither. The first version of this case failed exactly that test: it put «т. д.»
  1664. # before a comma and «т. е.» before a lowercase word, where the splitter would not have cut
  1665. # anyway — so it passed with the ABBREV list emptied, and guarded nothing. Verified by
  1666. # mutation: emptying ABBREV must break the FIRST case only, and removing the initials regex
  1667. # the SECOND only. Both need a full stop followed by space + CAPITAL, which is the one shape
  1668. # the splitter acts on.
  1669. cat > "$d/abbr.md" <<'ABBREOF'
  1670. Полный список расхождений см. Приложение 2 в конце документа.
  1671. ABBREOF
  1672. n=$(python3 tools/measure-prose-shape.py "$d/abbr.md" | awk '/^ слов / {print $4}')
  1673. if [ "$n" = "1" ]; then
  1674. ok "an abbreviation before a capital does not invent a sentence boundary"
  1675. else
  1676. bad "ABBREV guard failed: counted $n sentences where there is 1"
  1677. fi
  1678. cat > "$d/initials.md" <<'INITEOF'
  1679. Справочники Д. Э. Розенталя лежат на той же полке.
  1680. INITEOF
  1681. n=$(python3 tools/measure-prose-shape.py "$d/initials.md" | awk '/^ слов / {print $4}')
  1682. if [ "$n" = "1" ]; then
  1683. ok "initials do not invent a sentence boundary"
  1684. else
  1685. bad "initials guard failed: counted $n sentences where there is 1"
  1686. fi
  1687. printf 'selftest: build-og.sh\n'
  1688. # The social images are a generated artefact whose generator is committed, which is this
  1689. # project's own standard for anything generated. These cases guard the two claims that make
  1690. # the arrangement worth anything: that --check actually notices when the render stops
  1691. # matching the source, and that a missing input fails loudly rather than rendering a card
  1692. # with a hole in it.
  1693. #
  1694. # Skipped, not failed, where no browser exists: the ubuntu runner has no Chrome, and a green
  1695. # suite that reddens over a missing renderer teaches people to ignore it. The skip is
  1696. # counted and printed.
  1697. if ! (cd "$ROOT" && ./tools/build-og.sh --check >/dev/null 2>&1); then
  1698. skip "build-og cases — no renderer here, or the committed images already differ"
  1699. else
  1700. d=$(fresh_copy)
  1701. # fresh_copy stages but never commits, and --check reads the blob out of HEAD. Without a
  1702. # commit every case here would report MISSING instead of exercising the comparison.
  1703. ( cd "$d" && git -c user.email=t@t -c user.name=t commit -qm baseline ) >/dev/null 2>&1
  1704. # A two-pixel change to the accent rule. Small enough that only a real comparison finds it.
  1705. python3 - "$d/assets/og/og.html" <<'PYEOF'
  1706. import io, sys
  1707. p = sys.argv[1]
  1708. s = io.open(p, encoding='utf-8').read()
  1709. io.open(p, 'w', encoding='utf-8').write(
  1710. s.replace('width: 58px; height: 2px', 'width: 60px; height: 2px', 1))
  1711. PYEOF
  1712. out=$(cd "$d" && ./tools/build-og.sh --check 2>&1) && st=0 || st=$?
  1713. if [ "$st" -eq 0 ]; then
  1714. bad "build-og --check PASSED after the source changed"
  1715. elif printf '%s' "$out" | grep -q 'DIFFERS'; then
  1716. ok "build-og --check notices when the render stops matching its source"
  1717. else
  1718. bad "build-og --check failed, but not for the stated reason"
  1719. printf '%s\n' "$out" | sed 's/^/ /'
  1720. fi
  1721. d=$(fresh_copy)
  1722. mv "$d/assets/mark.png" "$d/assets/mark-hidden.png"
  1723. out=$(cd "$d" && ./tools/build-og.sh 2>&1) && st=0 || st=$?
  1724. if [ "$st" -eq 0 ]; then
  1725. bad "build-og rendered a card with its mark missing"
  1726. elif printf '%s' "$out" | grep -q 'assets/mark.png'; then
  1727. ok "a missing input is named, not silently drawn around"
  1728. else
  1729. bad "build-og failed on a missing mark, but did not name the file"
  1730. fi
  1731. fi
  1732. printf 'selftest: probe-install.sh\n'
  1733. # The probe judges what an agent did to a sandbox. These cases judge the probe, by building
  1734. # the three outcomes by hand — because the one thing a gate must never do is pass on an
  1735. # install that did not happen, and that is exactly what an «is there a SKILL.md anywhere»
  1736. # check would do.
  1737. probe_case() { # $1=case-name $2=want(PASS|FAIL) $3=needle $4=sandbox
  1738. name=$1; want=$2; needle=$3; sb=$4
  1739. out=$("$ROOT/tools/probe-install.sh" check "$sb" 'Codex CLI' 2>&1) && st=PASS || st=FAIL
  1740. if [ "$st" != "$want" ]; then
  1741. bad "$name — probe said $st, wanted $want"
  1742. printf '%s\n' "$out" | sed 's/^/ /'
  1743. elif [ -z "$needle" ] || printf '%s' "$out" | grep -qF "$needle"; then
  1744. ok "$name"
  1745. else
  1746. bad "$name — $st, but not for the stated reason (wanted: $needle)"
  1747. printf '%s\n' "$out" | sed 's/^/ /'
  1748. fi
  1749. }
  1750. PB=$(mktemp -d)
  1751. # Nobody ran the agent. An empty sandbox must never read as a clean install.
  1752. "$ROOT/tools/probe-install.sh" setup "$PB/empty" 'Codex CLI' >/dev/null 2>&1
  1753. probe_case "an empty sandbox is not a pass" FAIL "holds no SKILL.md" "$PB/empty"
  1754. # The documented user path. This is the only shape that may pass.
  1755. "$ROOT/tools/probe-install.sh" setup "$PB/good" 'Codex CLI' >/dev/null 2>&1
  1756. mkdir -p "$PB/good/home/.agents/skills"
  1757. cp -R "$ROOT/skills/ru-text" "$PB/good/home/.agents/skills/ru-text"
  1758. probe_case "an install at the documented path passes" PASS "documented path" "$PB/good"
  1759. # The failure this file was written from: a real agent installed Codex's copy into
  1760. # ~/.codex/skills on the strength of a December-2025 blog post. The path exists, the skill
  1761. # is intact, and Codex never looks there.
  1762. "$ROOT/tools/probe-install.sh" setup "$PB/stray" 'Codex CLI' >/dev/null 2>&1
  1763. mkdir -p "$PB/stray/home/.codex/skills"
  1764. cp -R "$ROOT/skills/ru-text" "$PB/stray/home/.codex/skills/ru-text"
  1765. probe_case "an install at an undocumented path is caught" FAIL "does not look" "$PB/stray"
  1766. # Right path, wrong corpus. An agent that fetched an old tag or a fork passes every path
  1767. # test above; only the bytes catch it.
  1768. "$ROOT/tools/probe-install.sh" setup "$PB/stale" 'Codex CLI' >/dev/null 2>&1
  1769. mkdir -p "$PB/stale/home/.agents/skills"
  1770. cp -R "$ROOT/skills/ru-text" "$PB/stale/home/.agents/skills/ru-text"
  1771. printf '\nA line no released ru-text ever carried.\n' >> "$PB/stale/home/.agents/skills/ru-text/SKILL.md"
  1772. probe_case "a stale or forked copy at the right path is caught" FAIL "differs from this checkout" "$PB/stale"
  1773. # Right path, right SKILL.md, half the corpus. The reference files are the product; a probe
  1774. # that stopped at SKILL.md would bless a skill with no rules in it.
  1775. "$ROOT/tools/probe-install.sh" setup "$PB/partial" 'Codex CLI' >/dev/null 2>&1
  1776. mkdir -p "$PB/partial/home/.agents/skills"
  1777. cp -R "$ROOT/skills/ru-text" "$PB/partial/home/.agents/skills/ru-text"
  1778. rm -f "$PB/partial/home/.agents/skills/ru-text/references/typography.md"
  1779. probe_case "a truncated corpus at the right path is caught" FAIL "truncated" "$PB/partial"
  1780. # A symlinked install. The first version of the probe called this «a different thing from an
  1781. # installed one» and would have failed it; a live run refuted that in one shot, with OpenAI's
  1782. # own page: «Codex supports symlinked skill folders and follows the symlink target». The agent
  1783. # had linked deliberately, so that a pull on the clone updates the install.
  1784. "$ROOT/tools/probe-install.sh" setup "$PB/link" 'Codex CLI' >/dev/null 2>&1
  1785. mkdir -p "$PB/link/home/src" "$PB/link/home/.agents/skills"
  1786. cp -R "$ROOT/skills/ru-text" "$PB/link/home/src/ru-text"
  1787. ln -s "$PB/link/home/src/ru-text" "$PB/link/home/.agents/skills/ru-text"
  1788. probe_case "a symlinked install at the documented path passes" PASS "documented path" "$PB/link"
  1789. # The clone an agent makes before linking or copying. It is an intermediate, not a rogue
  1790. # install, and the same live run had the probe report the source tree as four of them.
  1791. "$ROOT/tools/probe-install.sh" setup "$PB/clone" 'Codex CLI' >/dev/null 2>&1
  1792. mkdir -p "$PB/clone/home/src/ru-text/.claude-plugin" "$PB/clone/home/.agents/skills"
  1793. cp -R "$ROOT/skills" "$PB/clone/home/src/ru-text/skills"
  1794. # The manifest is what makes a tree this repository rather than any directory with a .git —
  1795. # see the decoy case below, which is why the marker had to become this specific.
  1796. cp "$ROOT/.claude-plugin/plugin.json" "$PB/clone/home/src/ru-text/.claude-plugin/plugin.json"
  1797. ( cd "$PB/clone/home/src/ru-text" && git init -q . ) >/dev/null 2>&1
  1798. cp -R "$ROOT/skills/ru-text" "$PB/clone/home/.agents/skills/ru-text"
  1799. probe_case "the source clone is not reported as a rogue install" PASS "no copy landed outside" "$PB/clone"
  1800. # The bypass a security review found and reproduced in one command: an empty `.git` beside a
  1801. # rogue install disarmed the clone exclusion, and the probe printed PASS over an install at
  1802. # the stale-blog path. A gate that a `mkdir` switches off is worse than no gate.
  1803. #
  1804. # The decoy is built exactly as the review built it, at ~/.codex/skills — which also pins the
  1805. # SECOND attempt at the fix. That one required the tree to hold `skills/ru-text/SKILL.md`, and
  1806. # `~/.codex/skills/ru-text` has that shape with no decoy at all, so any platform whose skills
  1807. # directory is named `skills` would have excused itself. Only the plugin manifest separates a
  1808. # checkout from an install.
  1809. "$ROOT/tools/probe-install.sh" setup "$PB/decoy" 'Codex CLI' >/dev/null 2>&1
  1810. mkdir -p "$PB/decoy/home/.agents/skills" "$PB/decoy/home/.codex/skills/.git"
  1811. cp -R "$ROOT/skills/ru-text" "$PB/decoy/home/.agents/skills/ru-text"
  1812. cp -R "$ROOT/skills/ru-text" "$PB/decoy/home/.codex/skills/ru-text"
  1813. mkdir -p "$PB/decoy/home/.codex/.git"
  1814. probe_case "a decoy .git does not excuse an install at an undocumented path" FAIL "does not look" "$PB/decoy"
  1815. # The repository's own test fixture lives at tools/testdata/corpus/SKILL.md, outside skills/.
  1816. # The first clone rule excused only files under the root's `skills/`, so a genuine clone was
  1817. # reported as a rogue install on the strength of a fixture. Everything under a verified root
  1818. # is source.
  1819. "$ROOT/tools/probe-install.sh" setup "$PB/fixture" 'Codex CLI' >/dev/null 2>&1
  1820. mkdir -p "$PB/fixture/home/src/ru-text/.claude-plugin" "$PB/fixture/home/.agents/skills"
  1821. cp -R "$ROOT/skills" "$PB/fixture/home/src/ru-text/skills"
  1822. cp -R "$ROOT/tools" "$PB/fixture/home/src/ru-text/tools"
  1823. cp "$ROOT/.claude-plugin/plugin.json" "$PB/fixture/home/src/ru-text/.claude-plugin/plugin.json"
  1824. ( cd "$PB/fixture/home/src/ru-text" && git init -q . ) >/dev/null 2>&1
  1825. cp -R "$ROOT/skills/ru-text" "$PB/fixture/home/.agents/skills/ru-text"
  1826. probe_case "a fixture outside skills/ does not make a clone look rogue" PASS "no copy landed outside" "$PB/fixture"
  1827. # Every platform named in the table is either given paths or declared to own its installer.
  1828. # A row typo silently produces a platform this probe can never judge.
  1829. missing=$(awk -F'\t' '!/^#/ && $1 != "platform" && NF > 1 { print $1 "\t" $3 }' "$ROOT/tools/install-paths.tsv" \
  1830. | awk -F'\t' '{ if ($2 == "-") own[$1]=1; else has[$1]=1 }
  1831. END { for (p in own) if (p in has) print p }')
  1832. if [ -z "$missing" ]; then
  1833. ok "no platform is both path-served and self-installing"
  1834. else
  1835. bad "a platform claims both a path and its own installer: $missing"
  1836. fi
  1837. rm -rf "$PB"
  1838. if [ "${skipped:-0}" -gt 0 ]; then
  1839. printf 'selftest: %d passed, %d failed, %d skipped\n' "$pass" "$fail" "$skipped"
  1840. else
  1841. printf 'selftest: %d passed, %d failed\n' "$pass" "$fail"
  1842. fi
  1843. finished=1
  1844. [ "$fail" -eq 0 ]

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.