Skip to content

fix(repl): check asks the plan judge and twelve forgeries fail - #326

Merged
the-homeless-god merged 5 commits into
devfrom
a/check-asks-the-plan-judge
Oct 8, 2026
Merged

the-homeless-god merged 5 commits into
devfrom
a/check-asks-the-plan-judge

Conversation

@the-homeless-god

Copy link
Copy Markdown
Member

Беда, проверенная мной лично

Один и тот же файл, двоичный ствола:

$ flang check flang/test/fixtures/plany/01-dvazhdy.flang
проверено — разбор, типы, завершаемость, ядро и примеры; замечаний нет        код 0

$ flang test  flang/test/fixtures/plany/01-dvazhdy.flang
FLANG_PLAN, строка 25: план «Работа» объявлен дважды

check говорит «замечаний нет» о программе, которую test отвергает названным отказом. И это хуже отсутствующего правила: поверхность plans уже стоит среди судимых, поэтому check не сказал ни «не судит вовсе», ни «сверено не до конца» — он утверждал, что сверил. Та же порода, что у процессов (задача 7101, заметка docs/zettel/a-rule-inside-the-binary-is-not-a-rule-the-binary-asks.md).

Правила СУЩЕСТВОВАЛИ в двоичном и ехали в семя — но flang check идёт не через «Проверить связанное», а повторяет её путь вызов за вызовом, и вызова планов в этом пути не было.

Починка

Тихий вызов судьи планов в repl_check_sources (flang/src/emit/c/flang_repl.c) рядом с вызовом процессов. Одна вставка закрывает пять команд: repl_check, check, proof, emit, package. Отказ FLANG_UNKNOWN_NAME глотается нарочно (старое семя функции не несёт), любой другой — беда вслух.

Чем доказано — прогоны

Собрал семя законным рецептом (шапка 9 строк + источник дословно) и двоичный: md5 817cbea2. На нём:

00-tselyj.flang                код 0      ← честный образец
01…12 (двенадцать подделок)    код 1      ← было код 0 у всех двенадцати
13-shag-dzhoker.flang          код 1      ← был код 1, остался

Сообщения совпадают с expected.tsv знак в знак («план «Работа» объявлен дважды», «не собран: в программе нет сумм «Отклик»», «состояние плана — неизвестный тип «Хода»» и так далее).

Отрицательный контроль на всём дереве: 278 программ с «план», два двоичных, check --быстро. Ответ сменили ровно 12 файлов — ни одна верная программа не задета. Один файл (flang/self/bootstrap/emit-from-source.flang) не ответил ни одному двоичному за 150 с — он не мерен, и зелёным не считается.

Проба в CI с подлогом (работа plany): шаг 1 сбивает ИМЯ судьи в тихом вызове — набор обязан дать «разошлось 12», код 1; шаг 2 начисто — «разошлось 0», код 0. Оба шага прогнаны дословно из YAML локально.

Что требуется после слияния — и чего НЕ требуется

Полная перепечатка не нужна: правка только в копируемой части. Приборы говорят это сами: --telo код 0 («тело семени сошлось, файлов 7»), seed-refresh код 0 («тронуты только копируемые файлы — быстрый пересев достаточен»), --bystro код 1 («flang_repl.c изменён после перепечатки»). Нужен быстрый пересев seed:refresh — минуты. Он нарочно не сделан в этой ветке: он перезаписывает scripts/seed-fingerprint, а сейчас идёт партия печати, и два отпечатка на одном файле дали бы конфликт.

Пока пересева нет, ярлык plan-rules:probe честно красен («проб 29, разошлось 12») — это правда о семени, которое судью планов ещё не спрашивает, а не поломка.

Перемеренные числа задач

Три числа в задачах 7706 и 8398 оказались устаревшими и исправлены: программ дерева с «план» 278 (а не 268), кодов 1 у нынешнего двоичного 18 (а не 3; 15 новых — FLANG_IMPORT_AMBIGUOUS в примерах, к планам отношения не имеет), и «перепечатка не нужна» верно о печатаемой части, но неверно об отпечатке.

Заслон перед пушем: 21 проверка из 21 зелены за 59 с.

@the-homeless-god
the-homeless-god force-pushed the a/check-asks-the-plan-judge branch from 24f4b12 to 590743d Compare October 7, 2026 21:00
the-homeless-god and others added 5 commits October 8, 2026 13:43
The rules over the `plan` declaration ("Proverka planov" in
flang/self/io.flang) have been printed into the seed and are called from
"Proverit svyazannoe", but `flang check` does not take that road: it
repeats the sequence in `repl_check_sources`, and the plan call was
missing from it. A quiet call is now there, next to the one for
processes; one insertion covers five commands that share the road -- the
shell (`repl_check`), `check`, `proof`, `emit` and `package`.

Measured 4 October 2026, trunk 4d76abd, both binaries built in one
working copy, seed md5 63150ae8, patched md5 817cbea2:

  * fourteen samples flang/test/fixtures/plany, two judges of one
    binary: `check` accepted twelve forgeries with code 0 and the same
    first line as the whole sample 00; now it rejects all twelve with
    code 1 and a named FLANG_PLAN. `test` rejected all twelve before and
    after. Sample 00 stays code 0, sample 13 answers one type-check
    remark.
  * probe plan-rules-asked: 29 probes, 12 diverged, code 1 before; 29
    probes, 0 diverged, code 0 after.
  * negative control: 278 tree programs declaring `plan`, each run under
    `check --bystro` by both binaries. Code 4: 259 -> 247. Code 1:
    18 -> 30. One file (flang/self/bootstrap/emit-from-source.flang)
    answers neither binary within 150 s and is NOT measured. The
    difference between the binaries is exactly the twelve forgeries,
    4 -> 1 with FLANG_PLAN; no other file changed its answer.

The PROVERENO line of `--bystro` named processes and not plans while the
`plans` surface already stood among the judged keys, so neither "not
judged at all" nor "not checked to the end" was printed about plans --
the binary claimed it had checked. That line now names plans too.

The probe gets a CI job of its own rather than a step among the guards.
The fix lives in the tree shell, and bootstrap/flang is built from the
seed copy of that shell, so a probe on bootstrap/flang would measure the
seed, not the tree. The job therefore builds a second binary by the same
recipe that seed-runtime-is-source verifies -- seed header plus source
verbatim -- which reproduces md5 817cbea2 exactly and carries the seed's
own limit stamp, since bootstrap/flang_runtime.h is copied byte for byte
(FL_MAX_DEPTH 20000, FL_MAX_STEPS 4000000000000, not the runtime
defaults). Build cost measured here: 300 s at -j4 without -flto,
2.65 GiB peak, which does not fit the 20-minute guards job.

The job's first step is a forgery, because a probe that cannot redden is
indistinguishable from a fixed tree. It breaks the NAME in the quiet
call rather than deleting the call: repl_call then answers
FLANG_UNKNOWN_NAME, that one refusal is swallowed on purpose, and the
binary behaves exactly as it did before the fix -- so the suite reddens
on its own subject and not on a broken build. Measured: forged 29
probes, 12 diverged, code 1; honest 29 probes, 0 diverged, code 0. The
honest binary is a 6.5 s relink, since the expensive compiler_flang.o is
already there.

Reprinting the self-hosted part is NOT needed: bootstrap/compiler_flang.c
already carries the rules and their call. What IS needed is a fresh
fingerprint once the seed copy catches up, and `seed-refresh --plan
Check` says so itself: "only copied files touched -- a fast reseed is
enough".
The quiet call of the plan judge in repl_check_sources keeps its code
and loses the comment block, and the plan-rules-asked job in binary.yml
is rewritten without comments and with English shell variable names.
Tasks 7706 and 8398 are done by this branch and leave the tree.

Measured here: the probe plan-rules-asked on a binary built from the
seed header plus this source answers 29 probes, 0 apart, exit 0; with
the judge name forged it exits 1 on the twelve check rows; the seed
binary stays red until the shell is reseeded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PNHrA3rG7FTWhB11E7pjDQ
The plan judge call adds 17 lines to flang/src/emit/c/flang_repl.c, so
the two C line counts in docs/tree-inventory.md move with it. The CI
step names the probe file literally, so the run-verdict guard sees the
target by name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PNHrA3rG7FTWhB11E7pjDQ
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PNHrA3rG7FTWhB11E7pjDQ
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PNHrA3rG7FTWhB11E7pjDQ
@the-homeless-god
the-homeless-god force-pushed the a/check-asks-the-plan-judge branch from 590743d to 5b2c094 Compare October 8, 2026 14:09
@the-homeless-god
the-homeless-god merged commit f532c94 into dev Oct 8, 2026
36 checks passed
@the-homeless-god
the-homeless-god deleted the a/check-asks-the-plan-judge branch October 8, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant