Skip to content

Commit 2b39d14

Browse files
committed
Sync TON mutation docs and remove legacy data
1 parent 1e4aabb commit 2b39d14

15 files changed

Lines changed: 223 additions & 277 deletions

examples/foo.fc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
This file intentionally exercises a broad slice of func.rules.
77
The code is small enough to compile quickly, but rich enough to
88
generate mutants for operator swaps, stdlib helper swaps, method
9-
specifiers, send/reserve modes, and muton-style statement rewrites.
9+
specifiers, send/reserve modes, and statement rewrites.
1010

1111
THROW_IF
1212
THROW_UNLESS
@@ -54,7 +54,7 @@ cell make_sample_cell() inline_ref {
5454
.end_cell();
5555
}
5656

57-
int muton_ops(int a, int b) impure {
57+
int coverage_ops(int a, int b) impure {
5858
int cond = a != b;
5959
int count = 2;
6060
int steps = 0;
@@ -223,7 +223,7 @@ int muton_ops(int a, int b) impure {
223223
() main() impure {
224224
cell sample = make_sample_cell();
225225
int score = inline_sum(2, 3) + ref_sum(9, 4) + noisy_method() + default_method();
226-
int changed = muton_ops(score, 6);
226+
int changed = coverage_ops(score, 6);
227227
stdlib_ops(sample);
228228
throw_unless(33, changed != 0);
229229
throw_if(34, changed == 0);

examples/foo.tolk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ get fun currentCounter(): int {
148148
return 0;
149149
}
150150

151-
fun mutonOps(flag: bool): int {
151+
fun coverageOps(flag: bool): int {
152152
var a = 10;
153153
var b = 6;
154154
var steps = 0;

examples/tolk-bench

Lines changed: 0 additions & 1 deletion
This file was deleted.

temp docs/FORK.md

Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# UniversalMutator + TON (Tact / FunC / Tolk)
22

3-
Это форк `universalmutator`, в который добавлена поддержка трех TON-языков:
3+
This is a fork of `universalmutator` with support for three TON languages:
44

5-
- `tact` для файлов `.tact`
6-
- `func` для файлов `.fc` и `.func`
7-
- `tolk` для файлов `.tolk`
5+
- `tact` for `.tact` files
6+
- `func` for `.fc` and `.func` files
7+
- `tolk` for `.tolk` files
88

9-
## Как запускать именно этот форк
9+
## How to run this fork
1010

11-
У пакета уже есть `console_scripts` в `setup.py`. После установки форка доступны такие команды:
11+
The package already defines `console_scripts` in `setup.py`. After installing the fork, these commands are available:
1212

1313
- `mutate`
1414
- `analyze_mutants`
@@ -18,9 +18,9 @@
1818
- `prune_mutants`
1919
- `intersect_mutants`
2020

21-
### Вариант 1: editable install для разработки
21+
### Option 1: editable install for development
2222

23-
Это лучший режим, если ты активно правишь код форка.
23+
This is the best setup if you actively modify the fork itself.
2424

2525
PowerShell:
2626

@@ -32,21 +32,21 @@ python -m pip install -e . --no-build-isolation
3232
mutate --help
3333
```
3434

35-
Что это дает:
35+
What this gives you:
3636

37-
- CLI появляется сразу
38-
- используются текущие файлы из репозитория
39-
- после правок не нужно пересобирать wheel
37+
- the CLI is available immediately
38+
- the current repository files are used directly
39+
- no wheel rebuild is needed after code changes
4040

41-
Если CLI не нужен, можно запускать напрямую модуль:
41+
If you do not need the CLI, you can run the module directly:
4242

4343
```sh
4444
python -m universalmutator.genmutants --help
4545
```
4646

47-
### Вариант 2: собрать wheel и поставить свою версию как обычный пакет
47+
### Option 2: build a wheel and install it as a regular package
4848

49-
Это режим для полноценного локального CLI-пакета.
49+
This is the setup for a full local CLI package.
5050

5151
PowerShell:
5252

@@ -59,13 +59,13 @@ python -m pip install --force-reinstall dist\*.whl
5959
mutate --help
6060
```
6161

62-
Если `python -m build` пишет `No module named build`, сначала поставь:
62+
If `python -m build` prints `No module named build`, install it first:
6363

6464
```sh
6565
python -m pip install build
6666
```
6767

68-
Для этого форка wheel локально собирается командой:
68+
For this fork, the wheel is built locally with:
6969

7070
```sh
7171
python -m build --wheel --no-isolation
@@ -85,10 +85,9 @@ python -m universalmutator.genmutants \
8585
--comby \
8686
--noCheck \
8787
> examples/func2_all/check.out 2>&1
88-
8988
```
9089

91-
## Установка компиляторов TON
90+
## Installing TON compilers
9291

9392
### Tact
9493

@@ -111,26 +110,26 @@ npm i -g @ton-community/func-js
111110
func-js -h
112111
```
113112

114-
## Генерация мутантов
113+
## Mutant generation
115114

116-
Смысл такой:
115+
The basic model is:
117116

118-
- `mutate` генерирует мутантов
119-
- для каждого мутанта для `tact` / `tolk` / `func` compile-check запускается автоматически через language handler
120-
- если команда возвращает `0`, мутант считается `VALID`
121-
- `--cmd` нужен только если хочется принудительно переопределить команду проверки
122-
- `--cmd` имеет приоритет над встроенными TON handler-ами и подходит для нестандартного компилятора, обёртки или локального скрипта
123-
- В regex-режиме многострочные блок-комментарии `/* ... */`, `{- ... -}` и пустые строки глобально пропускаются для всех языков
117+
- `mutate` generates mutants
118+
- for each mutant in `tact` / `tolk` / `func`, compile-check runs automatically through the language handler
119+
- if the command returns `0`, the mutant is considered `VALID`
120+
- `--cmd` is only needed if you want to force a custom validation command
121+
- `--cmd` has priority over the built-in TON handlers and is useful for a custom compiler, wrapper, or local script
122+
- in regex mode, multiline block comments `/* ... */`, `{- ... -}`, and empty lines are globally skipped for all languages
124123

125-
## Изменения ядра (mutator.py)
124+
## Core changes (`mutator.py`)
126125

127-
- В regex-режиме мутатор пропускает пустые строки и блок-комментарии `/* ... */` и `{- ... -}` для всех языков, чтобы не мутировать комментарии и не раздувать шум.
128-
- Для FunC добавлен быстрый фильтр в regex-режиме: если строка содержит `store_uint` или `store_int` и выражение с длинной суммой чисел (5+ числовых литералов), то числовые мутации из `universal.rules` вида `(\D)(\d+)(\D)` пропускаются. Это ускоряет генерацию и уменьшает пачку `INVALID` на выражениях длины битов. Фильтр включается только при наличии `func.rules` и не влияет на другие языки или `--comby`.
126+
- In regex mode, the mutator skips empty lines and block comments `/* ... */` and `{- ... -}` for all languages, to avoid mutating comments and inflating noise.
127+
- For FunC, a fast regex-mode filter was added: if a line contains `store_uint` or `store_int` and also contains a long numeric sum expression (5+ numeric literals), numeric mutations from `universal.rules` of the form `(\D)(\d+)(\D)` are skipped. This speeds up generation and reduces the number of `INVALID` mutants on bit-width expressions. The filter is enabled only when `func.rules` is active and does not affect other languages or `--comby`.
129128

130-
### Изменения генератора (genmutants.py)
129+
### Generator changes (`genmutants.py`)
131130

132-
- При `--swap` строки для перестановки теперь исключают пустые строки и строки-комментарии (`//`, `;;`, `#`), а также строки внутри блок-комментариев `/* ... */` и `{- ... -}`. Это делает свапы более осмысленными и уменьшает число мусорных `INVALID`.
133-
- Также `--swap` не переставляет одинаковые строки (включая случаи, когда совпадает содержимое после `strip()`), чтобы не генерировать бессмысленные мутанты вроде перестановки `}` с `}`.
131+
- With `--swap`, lines considered for swapping now exclude empty lines, comment lines (`//`, `;;`, `#`), and lines inside block comments `/* ... */` and `{- ... -}`. This makes swaps more meaningful and reduces noisy `INVALID` mutants.
132+
- `--swap` also avoids swapping identical lines, including cases where `strip()` produces the same content, so it does not generate pointless mutants such as swapping `}` with `}`.
134133

135134
### 2026-04-28 update: mutator/comby sync
136135

@@ -142,69 +141,69 @@ func-js -h
142141
- `universalmutator/mutator.py`: import of `Comby` is now lazy and happens only inside `mutants_comby()`. This removes the top-level hard dependency during module import, but does not replace the external `comby` binary requirement for actual `--comby` runs.
143142
- `universalmutator/genmutants.py`: TON extensions `.tact`, `.fc`, `.func`, `.tolk` are mapped to Comby matcher `.generic` in `--comby` mode. Comby does not support TON-specific matcher names directly, so this avoids failures like `The matcher ".fc" is not supported`. Other languages keep their previous matcher behavior.
144143

145-
## Команды
144+
## Commands
146145

147146
### `mutate`
148147

149-
Генерирует мутантов и кладёт их в `--mutantDir`. При необходимости можно добавить `--cmd` или `--noFastCheck`.
148+
Generates mutants and writes them to `--mutantDir`. Add `--cmd` or `--noFastCheck` if needed.
150149

151150
```sh
152151
mutate examples/tolk-bench/contracts_Tolk/01_jetton/jetton-wallet-contract.tolk --mutantDir tmp/tolk-jetton-wallet-mutants
153152
```
154153

155154
### `analyze_mutants`
156155

157-
Прогоняет тесты на каждом мутанте. Создаёт `killed.txt` и `notkilled.txt` в текущей директории.
156+
Runs tests against each mutant. Creates `killed.txt` and `notkilled.txt` in the current directory.
158157

159158
```sh
160159
analyze_mutants examples/tolk-bench/contracts_Tolk/01_jetton/jetton-wallet-contract.tolk "cd /d examples\tolk-bench && npx jest --runInBand tests/01_jetton/JettonWallet.spec.ts" --mutantDir tmp/tolk-jetton-wallet-mutants --timeout 180
161160
```
162161

163-
Полезные флаги: `--show`, `--verbose`, `--resume`, `--noShuffle`, `--numMutants N`, `--prefix name`.
162+
Useful flags: `--show`, `--verbose`, `--resume`, `--noShuffle`, `--numMutants N`, `--prefix name`.
164163

165164
### `check_covered`
166165

167-
Фильтрует мутантов по покрытым строкам. Формат `coverfile` — список номеров строк (по одному номеру на строку). Для TSTL-отчётов есть `--tstl`.
166+
Filters mutants by covered lines. `coverfile` is a list of line numbers, one per line. For TSTL coverage reports, use `--tstl`.
168167

169168
```sh
170169
check_covered examples/tolk-bench/contracts_Tolk/01_jetton/jetton-wallet-contract.tolk tmp/covered_lines.txt tmp/covered_mutants.txt --mutantDir tmp/tolk-jetton-wallet-mutants
171170
```
172171

173172
### `prioritize_mutants`
174173

175-
Ранжирует список мутантов по структурной дистанции. На вход принимает файл со списком имён мутантов.
174+
Ranks a mutant list by structural distance. Input is a file containing mutant names.
176175

177176
```sh
178177
prioritize_mutants tmp/covered_mutants.txt tmp/prioritized.txt --mutantDir tmp/tolk-jetton-wallet-mutants --sourceDir examples/tolk-bench/contracts_Tolk/01_jetton
179178
```
180179

181180
### `show_mutants`
182181

183-
Показывает диффы для мутантов из списка.
182+
Shows diffs for mutants from a list.
184183

185184
```sh
186185
show_mutants tmp/prioritized.txt --mutantDir tmp/tolk-jetton-wallet-mutants --sourceDir examples/tolk-bench/contracts_Tolk/01_jetton
187186
```
188187

189-
Флаг `--concise` делает вывод компактным.
188+
The `--concise` flag makes the output more compact.
190189

191190
### `prune_mutants`
192191

193-
Фильтрует список мутантов по правилам из конфигурации. Формат правил — строки вида `field: value`, доступны `orig`, `mutant`, `change`, `source`, `line` и их варианты с `!` или `_RE`.
192+
Filters a mutant list using a configuration file. Rule format is `field: value`; supported fields include `orig`, `mutant`, `change`, `source`, `line`, and their `!` / `_RE` variants.
194193

195194
```sh
196195
prune_mutants tmp/prioritized.txt tmp/pruned.txt tmp/prune.cfg --mutantDir tmp/tolk-jetton-wallet-mutants --sourceDir examples/tolk-bench/contracts_Tolk/01_jetton
197196
```
198197

199198
### `intersect_mutants`
200199

201-
Берёт пересечение двух списков мутантов.
200+
Takes the intersection of two mutant lists.
202201

203202
```sh
204203
intersect_mutants tmp/covered_mutants.txt tmp/prioritized.txt tmp/intersection.txt
205204
```
206205

207-
Для smoke-теста можно пересекать любые два существующих списка, например:
206+
For a smoke test, you can intersect any two existing lists, for example:
208207

209208
```sh
210209
intersect_mutants tmp/all_mutants.txt tmp/prioritized.txt tmp/intersection.txt

0 commit comments

Comments
 (0)