Keep feature-gated Rust changes out of red-side tests #3181

Merged
merzleckeier merged 2 commits from upstream-pr/3181 into main 2026-12-02 21:03:19 +00:00
merzleckeier commented 2026-12-02 17:04:57 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-02T17:04:57Z.


Claimed in the coordination issue as TEST-RED-GREEN-CFG-TEST-GATING.

What and why

The red/green checker treated any occurrence of test inside all(...) as a test requirement. The shader crate uses all(windows, any(test, feature = "host")) for its host module, so this could copy a normal source change to the red side and exclude it from mutation checks.

Classify the operands of all and any at their own nesting level. One required operand is enough for all, while every alternative must require test for any. Quoted values and nested Rust block comments do not introduce operands.

Tested

  • Three new regression cases failed with the original implementation at 5b1fff821 and passed with the change. The hunk-level fixture retains the actual test helper and leaves the feature-gated code on its baseline value.
  • python -I tests/test_red_green.py on CachyOS: 39 passed, one platform-specific skip.
  • python -I scripts/check_no_game_data.py and git diff --check passed.

GPUs tested: n/a (synthetic Rust and Git fixtures).

AI-assisted: OpenAI Codex (GPT-6), with independent read-only review by GPT-6.2 Sol.

Checklist

  • Based on upstream main (5b1fff821).
  • One topic.
  • Synthetic fixtures only.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5611207754 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3181). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-02T17:04:57Z. --- Claimed in the coordination issue as [TEST-RED-GREEN-CFG-TEST-GATING](https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7352720178). ### What and why The red/green checker treated any occurrence of `test` inside `all(...)` as a test requirement. The shader crate uses `all(windows, any(test, feature = "host"))` for its host module, so this could copy a normal source change to the red side and exclude it from mutation checks. Classify the operands of `all` and `any` at their own nesting level. One required operand is enough for `all`, while every alternative must require `test` for `any`. Quoted values and nested Rust block comments do not introduce operands. ### Tested - Three new regression cases failed with the original implementation at `5b1fff821` and passed with the change. The hunk-level fixture retains the actual test helper and leaves the feature-gated code on its baseline value. - `python -I tests/test_red_green.py` on CachyOS: 39 passed, one platform-specific skip. - `python -I scripts/check_no_game_data.py` and `git diff --check` passed. GPUs tested: n/a (synthetic Rust and Git fixtures). AI-assisted: OpenAI Codex (GPT-6), with independent read-only review by GPT-6.2 Sol. ### Checklist - [x] Based on upstream `main` (`5b1fff821`). - [x] One topic. - [x] Synthetic fixtures only.
merzleckeier commented 2026-12-02 17:18:39 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-02T17:18:39Z.


Additional check on 9997ae42b: ran the complete tests/test_red_green.py suite with Windows CPython 3.12 and MinGit 2.56.1.windows.2 under Wine 11.22. All 40 tests passed, including the three new cfg cases and the Windows job-object test. The tests use synthetic repositories and stub tools. AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7353170348 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3181#issuecomment-7353170348). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-02T17:18:39Z. --- Additional check on `9997ae42b`: ran the complete `tests/test_red_green.py` suite with Windows CPython 3.12 and MinGit 2.56.1.windows.2 under Wine 11.22. All 40 tests passed, including the three new cfg cases and the Windows job-object test. The tests use synthetic repositories and stub tools. AI-assisted.
fiestorra commented 2026-12-02 17:19:04 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T17:19:04Z.


Verified here: it applies on the current main and its own suite passes - 40 tests, OK, in 79 s (they build throwaway repositories, so the time is the tests, not a hang).

merge base 3c106eb2f, head 9997ae42b
git apply on main   (10 files)
python -I tests/test_red_green.py    Ran 40 tests in 79.374s   OK

What it fixes, and why I care about this one: the checker used to treat any occurrence of test inside all(...) as a test requirement, and the shader crate uses feature-gated all(...) - which is exactly the shape that made two pull requests report red does not build to me earlier today (#3153 and #3150): the red side could not compile because the tests themselves used something the change adds. So this is a fix to the instrument, and the instrument was the thing making honest reports confusing.

And one check that looks alarming until it is read. I ran the patched checker against #3148 - which had given red then green here this afternoon - and it now says:

base origin/main 5b1fff821, head 3148 1f158fe57, merge base 1f158fe57
red: not constructible: the pull request changes no test
verdict: red not constructible

That is not your patch. #3148 was merged at 15:25, so the merge base is its own head and there is nothing to compare - and I confirmed it by running the unpatched checker against the same pull request, which says the same thing. Worth knowing, though: the message reads like a defect in the pull request being checked, and "already merged" would be a kinder thing for the tool to say.

What I could not test: the specific shape this is for - a real pull request whose tests sit behind all(feature, test). The unit tests cover the classification; a real one would be the confirmation, and the shader crate's own changes are the place to look for it.

AI-assisted: yes - DeepSeek v4.1 (flash).

Written with an AI assistant.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7353177410 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3181#issuecomment-7353177410). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-02T17:19:04Z. --- **Verified here: it applies on the current `main` and its own suite passes - 40 tests, OK, in 79 s** (they build throwaway repositories, so the time is the tests, not a hang). ``` merge base 3c106eb2f, head 9997ae42b git apply on main (10 files) python -I tests/test_red_green.py Ran 40 tests in 79.374s OK ``` **What it fixes, and why I care about this one**: **the checker used to treat any occurrence of `test` inside `all(...)` as a test requirement**, **and the shader crate uses feature-gated `all(...)`** - **which is exactly the shape that made two pull requests report `red does not build` to me earlier today** (#3153 and #3150): **the red side could not compile because the tests themselves used something the change adds.** **So this is a fix to the instrument, and the instrument was the thing making honest reports confusing.** **And one check that looks alarming until it is read.** I ran the patched checker against **#3148** - which had given `red then green` here this afternoon - and it now says: ``` base origin/main 5b1fff821, head 3148 1f158fe57, merge base 1f158fe57 red: not constructible: the pull request changes no test verdict: red not constructible ``` **That is not your patch.** `#3148` **was merged at 15:25**, so **the merge base is its own head and there is nothing to compare** - and I confirmed it by running the **unpatched** checker against the same pull request, which says the same thing. **Worth knowing, though: the message reads like a defect in the pull request being checked, and "already merged" would be a kinder thing for the tool to say.** **What I could not test**: **the specific shape this is for** - a real pull request whose tests sit behind `all(feature, test)`. **The unit tests cover the classification; a real one would be the confirmation**, and the shader crate's own changes are the place to look for it. **AI-assisted:** yes - DeepSeek v4.1 (flash). Written with an AI assistant.
merzleckeier commented 2026-12-02 17:22:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-02T17:22:14Z.


Thanks for the independent run. I compared the red-side test selection for #3150 (968b05d40) and #3153 (f854004db) with the checker from main (5b1fff821) and from this PR. For both, the selected files and Rust test hunks are byte-for-byte identical between the two checkers. These PRs illustrate a separate reason for red does not build: #3150's worker-count test calls the new store_workers helper and #3153's budget tests call the new room_for helper. A red-side test file can call a helper absent from its baseline even when the classifier selects it correctly. This PR's new regression instead covers eligibility for a hunk guarded by all(windows, any(test, feature = "host")). AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7353231917 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3181#issuecomment-7353231917). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-02T17:22:14Z. --- Thanks for the independent run. I compared the red-side test selection for #3150 (`968b05d40`) and #3153 (`f854004db`) with the checker from `main` (`5b1fff821`) and from this PR. For both, the selected files and Rust test hunks are byte-for-byte identical between the two checkers. These PRs illustrate a separate reason for `red does not build`: #3150's worker-count test calls the new `store_workers` helper and #3153's budget tests call the new `room_for` helper. A red-side test file can call a helper absent from its baseline even when the classifier selects it correctly. This PR's new regression instead covers eligibility for a hunk guarded by `all(windows, any(test, feature = "host"))`. AI-assisted.
MoonEyes commented 2026-12-02 18:01:46 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:01:46Z.


RUN (independent run on Windows, head 9997ae42b1568bffc594ceca4781515b2e1ce90d, merged into main 45dc41f95c1cd0dcc29c2c50582e0e9af8a77259 with git merge --no-ff)

The merge was clean. The PR touches only scripts/red_green.py and tests/test_red_green.py.

Green

  • python -I scripts/check_no_game_data.py scripts/red_green.py tests/test_red_green.py: clean.
  • The Hunks class (7 tests, including the 3 new ones): OK.
  • Full tests/test_red_green.py: 40 tests, 39 pass, 1 fail. The failure is a wall-clock assertion in the mutation-timeout test (assertLess(elapsed, 20), measured 25.97 s). The run took 448 s because an in-game run was using the machine, so I read it as load and not as a defect of the PR. That test does not touch is_test_cfg. I did not re-run it alone on a quiet machine.

Red

With scripts/red_green.py swapped back to main's version, all 3 new tests fail (7 failures counting subtests): the feature-gated hunk test, the grouping/literals cases (all(test, any(windows, not(test))), trailing-comma any, strings and raw strings holding ,test,, a comment holding ,test,) and the block-comment test. The file was restored afterwards.

Six hand-made mutations of the new classifier were each caught by the new tests: all using all(), any using any(), the nesting depth not tracked, raw-string tokens removed, nested-comment depth broken, and the empty any() guard removed.

Review

  • The claim matches: it is claimed in issues/2570 as TEST-RED-GREEN-CFG-TEST-GATING (claim and done comments by the author).
  • The logic reads correctly: a tokenizer skips strings, raw strings and nested block comments; all needs one operand that requires test, any needs every operand to, and not(...) never counts.
  • No open reviewer question. The comments are the author's Wine run (40 pass) and another contributor's run (40 pass). The author's reply says #3150 and #3153 fail red for a different reason (a helper missing on the baseline), so this PR does not change those results.
  • Minor, not blocking: an unterminated block comment or an unknown cfg form returns False, which is the safe side.

Not covered

  • No real PR whose tests sit behind all(feature, test) was run through the checker.
  • The one failing timing test was not re-run on an idle machine.
  • No cargo run (an in-game run was in progress).

Verdict

PASS

AI-assisted (Claude Code), models: Claude Opus 5.5 (checker), separate Claude Opus 5.5 judge.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7353874851 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3181#issuecomment-7353874851). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T18:01:46Z. --- RUN (independent run on Windows, head `9997ae42b1568bffc594ceca4781515b2e1ce90d`, merged into `main` `45dc41f95c1cd0dcc29c2c50582e0e9af8a77259` with `git merge --no-ff`) The merge was clean. The PR touches only `scripts/red_green.py` and `tests/test_red_green.py`. ### Green - `python -I scripts/check_no_game_data.py scripts/red_green.py tests/test_red_green.py`: clean. - The `Hunks` class (7 tests, including the 3 new ones): OK. - Full `tests/test_red_green.py`: 40 tests, 39 pass, 1 fail. The failure is a wall-clock assertion in the mutation-timeout test (`assertLess(elapsed, 20)`, measured 25.97 s). The run took 448 s because an in-game run was using the machine, so I read it as load and not as a defect of the PR. That test does not touch `is_test_cfg`. I did not re-run it alone on a quiet machine. ### Red With `scripts/red_green.py` swapped back to main's version, all 3 new tests fail (7 failures counting subtests): the feature-gated hunk test, the grouping/literals cases (`all(test, any(windows, not(test)))`, trailing-comma `any`, strings and raw strings holding `,test,`, a comment holding `,test,`) and the block-comment test. The file was restored afterwards. Six hand-made mutations of the new classifier were each caught by the new tests: `all` using `all()`, `any` using `any()`, the nesting depth not tracked, raw-string tokens removed, nested-comment depth broken, and the empty `any()` guard removed. ### Review - The claim matches: it is claimed in issues/2570 as TEST-RED-GREEN-CFG-TEST-GATING (claim and done comments by the author). - The logic reads correctly: a tokenizer skips strings, raw strings and nested block comments; `all` needs one operand that requires `test`, `any` needs every operand to, and `not(...)` never counts. - No open reviewer question. The comments are the author's Wine run (40 pass) and another contributor's run (40 pass). The author's reply says #3150 and #3153 fail red for a different reason (a helper missing on the baseline), so this PR does not change those results. - Minor, not blocking: an unterminated block comment or an unknown `cfg` form returns False, which is the safe side. ### Not covered - No real PR whose tests sit behind `all(feature, test)` was run through the checker. - The one failing timing test was not re-run on an idle machine. - No cargo run (an in-game run was in progress). ### Verdict PASS AI-assisted (Claude Code), models: Claude Opus 5.5 (checker), separate Claude Opus 5.5 judge.
MoonEyes commented 2026-12-02 18:01:52 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:01:52Z.


Verified (Linux, CPython 3.13.18): red then green, ready.

  • Head: 9997ae42b, merge base 5b1fff821, merged with --no-ff into current main 45dc41f95 (3 commits behind, merges clean).
  • python3 -I tests/test_red_green.py: 40 tests, OK (3 skipped, platform-specific).
  • python3 -I scripts/check_no_game_data.py scripts/red_green.py tests/test_red_green.py: exit 0.

Red/green (source revert): git checkout origin/main -- scripts/red_green.py, then ran the three new cases plus test_all_with_test_counts_and_test_files_are_whole: 7 failures (test_feature_gated_code_is_not_carried_into_red, five subtests of test_cfg_classification_respects_grouping_and_literals, test_cfg_block_comments_are_whitespace). The pre-existing case still passes on both sides. Restored the PR source: all green.

Extra probes of is_test_cfg on the merged tree (not in the PR's tests), all as expected:
test, any(test), all(test,), all( test , windows ), any(all(test)), all(windows, all(not(unix), test)) give True; not(test), all(not(test),windows), all(windows, any(test, feature = "host")) (the motivating shader-crate predicate), all(feature="a\"test", windows) give False.

Review notes (no defects):

  • cfg_requires_test reads all as "any operand requires test" and any as "every operand requires test", which is the right monotone reading. all(test, not(test)) now counts as test-only where it did not before, but that predicate never compiles, so nothing depends on it.
  • The raw-string token alternative is tried before \w+, but since the search walks left to right an identifier such as bar is consumed whole by \w+. A raw string can't start partway through a word.
  • An unterminated block comment returns False, which is the conservative choice: the code stays on the mutation side.

CI: no workflow runs on this head yet.

Verdict: ready.

AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.


Generated by Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7353876381 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3181#issuecomment-7353876381). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T18:01:52Z. --- **Verified (Linux, CPython 3.13.18): red then green, ready.** - Head: `9997ae42b`, merge base `5b1fff821`, merged with `--no-ff` into current `main` `45dc41f95` (3 commits behind, merges clean). - `python3 -I tests/test_red_green.py`: 40 tests, OK (3 skipped, platform-specific). - `python3 -I scripts/check_no_game_data.py scripts/red_green.py tests/test_red_green.py`: exit 0. **Red/green (source revert):** `git checkout origin/main -- scripts/red_green.py`, then ran the three new cases plus `test_all_with_test_counts_and_test_files_are_whole`: 7 failures (`test_feature_gated_code_is_not_carried_into_red`, five subtests of `test_cfg_classification_respects_grouping_and_literals`, `test_cfg_block_comments_are_whitespace`). The pre-existing case still passes on both sides. Restored the PR source: all green. **Extra probes of `is_test_cfg` on the merged tree** (not in the PR's tests), all as expected: `test`, `any(test)`, `all(test,)`, `all( test , windows )`, `any(all(test))`, `all(windows, all(not(unix), test))` give True; `not(test)`, `all(not(test),windows)`, `all(windows, any(test, feature = "host"))` (the motivating shader-crate predicate), `all(feature="a\"test", windows)` give False. **Review notes (no defects):** - `cfg_requires_test` reads `all` as "any operand requires test" and `any` as "every operand requires test", which is the right monotone reading. `all(test, not(test))` now counts as test-only where it did not before, but that predicate never compiles, so nothing depends on it. - The raw-string token alternative is tried before `\w+`, but since the search walks left to right an identifier such as `bar` is consumed whole by `\w+`. A raw string can't start partway through a word. - An unterminated block comment returns False, which is the conservative choice: the code stays on the mutation side. CI: no workflow runs on this head yet. Verdict: **ready**. AI-assisted verification: Claude Opus (Claude Code), separate agent per batch. --- _Generated by [Claude Code](https://claude.ai/code)_
MoonEyes commented 2026-12-02 19:27:55 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T19:27:55Z.


Re-verified on the current head (Linux, CPython 3.13.18): red then green, ready.

Head 1c62cfc62
Merge base b41763227 (= current main, 0 behind)
Since 9997ae42b one commit, 1c62cfc62 "Merge upstream main into the test-only cfg fix". The PR's own diff against its merge base (scripts/red_green.py +44/-3, tests/test_red_green.py +29) is byte-for-byte the one verified before.

Commands (merged --no-ff into main b41763227, detached):

  • python -I tests/test_red_green.py: Ran 40 tests, OK (skipped=3).
  • python -I scripts/check_no_game_data.py scripts/red_green.py tests/test_red_green.py: exit 0.
  • Full standalone suite, the CI selection piped into python -I scripts/run_standalone_tests.py -j 8: 660 files, 1 failed (tests/test_run_game_wine.py). Plain main b41763227 gives the same result: 660 files, 1 failed, the same file (test_a_fresh_cache_is_empty_in_an_accepted_run_folder, test_a_visible_run_against_stubs). That failure comes from the local environment, not this PR. No new failures.

Red (source revert): git checkout origin/main -- scripts/red_green.py, then python -I tests/test_red_green.py: FAILED (failures=7): test_feature_gated_code_is_not_carried_into_red, test_cfg_block_comments_are_whitespace, and five subtests of test_cfg_classification_respects_grouping_and_literals. Restored the PR source: 40 OK. Red then green.

Earlier review: no defects were raised on 9997ae42b, and the code is unchanged, so the notes there still hold.

CI on 1c62cfc62: change-scope, check, linux-python-and-viewer, no-game-data, semantic-tests all success.

Verdict: ready.

AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.


Generated by Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7356217185 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3181#issuecomment-7356217185). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T19:27:55Z. --- **Re-verified on the current head (Linux, CPython 3.13.18): red then green, ready.** | | | |---|---| | Head | `1c62cfc62` | | Merge base | `b41763227` (= current `main`, 0 behind) | | Since `9997ae42b` | one commit, `1c62cfc62` "Merge upstream main into the test-only cfg fix". The PR's own diff against its merge base (`scripts/red_green.py` +44/-3, `tests/test_red_green.py` +29) is byte-for-byte the one verified before. | **Commands (merged `--no-ff` into `main` `b41763227`, detached):** - `python -I tests/test_red_green.py`: Ran 40 tests, OK (skipped=3). - `python -I scripts/check_no_game_data.py scripts/red_green.py tests/test_red_green.py`: exit 0. - Full standalone suite, the CI selection piped into `python -I scripts/run_standalone_tests.py -j 8`: 660 files, 1 failed (`tests/test_run_game_wine.py`). Plain `main` `b41763227` gives the same result: 660 files, 1 failed, the same file (`test_a_fresh_cache_is_empty_in_an_accepted_run_folder`, `test_a_visible_run_against_stubs`). That failure comes from the local environment, not this PR. No new failures. **Red (source revert):** `git checkout origin/main -- scripts/red_green.py`, then `python -I tests/test_red_green.py`: FAILED (failures=7): `test_feature_gated_code_is_not_carried_into_red`, `test_cfg_block_comments_are_whitespace`, and five subtests of `test_cfg_classification_respects_grouping_and_literals`. Restored the PR source: 40 OK. **Red then green.** **Earlier review:** no defects were raised on `9997ae42b`, and the code is unchanged, so the notes there still hold. CI on `1c62cfc62`: `change-scope`, `check`, `linux-python-and-viewer`, `no-game-data`, `semantic-tests` all success. Verdict: **ready**. AI-assisted verification: Claude Opus (Claude Code), separate agent per batch. --- _Generated by [Claude Code](https://claude.ai/code)_
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!3181
No description provided.