Reject unmatched --import/--dll selectors in import_fail_fast (FAIL-FAST-SELECTORS) #941

Merged
TheGeogeo merged 2 commits from upstream-pr/941 into main 2026-11-29 01:22:23 +00:00
TheGeogeo commented 2026-11-24 15:23:32 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-24T15:23:32Z.


Claimed in the coordination issue as: FAIL-FAST-SELECTORS (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135906432)

Depends on: #848 (merged). Its test test_cli_dll_all_json_matches_documented_invocation expected exit 0 for --dll other.dll --all --json on an image that does not import that DLL. This change refuses that selector with exit 2, so the second commit (0718a8a9, 9eea92ca before the rebase) updates that one expectation; the test's valid-selector checks are unchanged.

What and why

tools/import_fail_fast.py passed the raw --import / --dll values to fail_fast(). A selector that names nothing in the image printed 0 of 0 import(s) called directly and exited 0, and a typo beside a good selector was dropped without a word. Both read as "no call site stops the title".

tools/import_call_sites.py already handles this, and import_fail_fast.py already imports from it. This change reuses import_selector, dll_selector and unmatched_selectors the same way: a malformed selector is an argparse error (exit 2), and a well-formed selector that matches nothing prints no import matches --import ... / --dll ... to stderr and returns 2 before any output. fail_fast() itself is unchanged (it still returns {} for an absent DLL).

Command-line behaviour change: a malformed or unmatched --import / --dll now exits 2, with the error on stderr and nothing on stdout. Before, it exited 0 with the usual output.

Tested

Head 0718a8a9, rebased on main e18b59a5, same patch as 9eea92ca (git range-diff); it merges cleanly with main 747809e7. Windows 11, Python 3.12.4:

  • python -I -B tests/test_import_fail_fast.py: 14 OK; tests/test_import_call_sites.py: 21 OK. With these tests on the tool of main e48ff037, 4 of the 14 fail.
  • tests/test_docs_cli_flags.py, tests/test_text_write_line_endings.py, tests/test_ctest_registration.py, tests/test_ci_registration.py and tests/test_docs_links.py: OK.
  • tests/test_tool_stdout_encoding.py fails in test_every_main_block_reconfigures_stdout, as on main e18b59a5 alone (three tools this change does not touch).
  • compileall, git diff --check and python -I scripts/check_no_game_data.py on the two files: clean.

Earlier head, on main 66d4f5aa, which contains #848 (9eea92ca; the tool change is the same patch as 2054bc49), on Windows 11, Python 3.12.4: tests/test_import_fail_fast.py 14 OK (1 failure of 14 without the updated expectation), tests/test_import_call_sites.py 21 OK, tests/test_docs_links.py 16 OK; test_docs_cli_flags.py, test_tool_stdout_encoding.py and test_text_write_line_endings.py OK; git diff --check and the no-game-data check clean.

First run, before #848:

Run from the repository root on Windows:

  • python -I -B tests/test_import_fail_fast.py: 12 tests, OK (8 existing, 4 new: malformed selectors, absent selectors, a typo beside a good selector, valid selectors still exit 0).
  • The 3 new tests that check refusals fail against origin/main's tools/import_fail_fast.py (checked in a scratch copy with the new tests, confirmed the old tool file was the one loaded); the fourth (valid selectors) passes on both.
  • python -I -B tests/test_import_call_sites.py: 21 tests, OK.
  • python -m compileall -q tools/import_fail_fast.py tests/test_import_fail_fast.py: no output.
  • git diff --check: clean.
  • python -I scripts/check_no_game_data.py tools/import_fail_fast.py tests/test_import_fail_fast.py: exit 0.
  • Not run: the translator suite, runtime and GPU tests (unrelated).

GPUs tested: n/a

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (Not applicable: no translator rule.)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5475067914 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/941). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-24T15:23:32Z. --- Claimed in the coordination issue as: FAIL-FAST-SELECTORS (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135906432) Depends on: #848 (merged). Its test `test_cli_dll_all_json_matches_documented_invocation` expected exit 0 for `--dll other.dll --all --json` on an image that does not import that DLL. This change refuses that selector with exit 2, so the second commit (`0718a8a9`, `9eea92ca` before the rebase) updates that one expectation; the test's valid-selector checks are unchanged. ### What and why `tools/import_fail_fast.py` passed the raw `--import` / `--dll` values to `fail_fast()`. A selector that names nothing in the image printed `0 of 0 import(s) called directly` and exited 0, and a typo beside a good selector was dropped without a word. Both read as "no call site stops the title". `tools/import_call_sites.py` already handles this, and `import_fail_fast.py` already imports from it. This change reuses `import_selector`, `dll_selector` and `unmatched_selectors` the same way: a malformed selector is an argparse error (exit 2), and a well-formed selector that matches nothing prints `no import matches --import ...` / `--dll ...` to stderr and returns 2 before any output. `fail_fast()` itself is unchanged (it still returns `{}` for an absent DLL). Command-line behaviour change: a malformed or unmatched `--import` / `--dll` now exits 2, with the error on stderr and nothing on stdout. Before, it exited 0 with the usual output. ### Tested Head `0718a8a9`, rebased on `main` `e18b59a5`, same patch as `9eea92ca` (`git range-diff`); it merges cleanly with `main` `747809e7`. Windows 11, Python 3.12.4: - `python -I -B tests/test_import_fail_fast.py`: 14 OK; `tests/test_import_call_sites.py`: 21 OK. With these tests on the tool of `main` `e48ff037`, 4 of the 14 fail. - `tests/test_docs_cli_flags.py`, `tests/test_text_write_line_endings.py`, `tests/test_ctest_registration.py`, `tests/test_ci_registration.py` and `tests/test_docs_links.py`: OK. - `tests/test_tool_stdout_encoding.py` fails in `test_every_main_block_reconfigures_stdout`, as on `main` `e18b59a5` alone (three tools this change does not touch). - `compileall`, `git diff --check` and `python -I scripts/check_no_game_data.py` on the two files: clean. Earlier head, on `main` `66d4f5aa`, which contains #848 (`9eea92ca`; the tool change is the same patch as `2054bc49`), on Windows 11, Python 3.12.4: `tests/test_import_fail_fast.py` 14 OK (1 failure of 14 without the updated expectation), `tests/test_import_call_sites.py` 21 OK, `tests/test_docs_links.py` 16 OK; `test_docs_cli_flags.py`, `test_tool_stdout_encoding.py` and `test_text_write_line_endings.py` OK; `git diff --check` and the no-game-data check clean. First run, before #848: Run from the repository root on Windows: - `python -I -B tests/test_import_fail_fast.py`: 12 tests, OK (8 existing, 4 new: malformed selectors, absent selectors, a typo beside a good selector, valid selectors still exit 0). - The 3 new tests that check refusals fail against `origin/main`'s `tools/import_fail_fast.py` (checked in a scratch copy with the new tests, confirmed the old tool file was the one loaded); the fourth (valid selectors) passes on both. - `python -I -B tests/test_import_call_sites.py`: 21 tests, OK. - `python -m compileall -q tools/import_fail_fast.py tests/test_import_fail_fast.py`: no output. - `git diff --check`: clean. - `python -I scripts/check_no_game_data.py tools/import_fail_fast.py tests/test_import_fail_fast.py`: exit 0. - Not run: the translator suite, runtime and GPU tests (unrelated). GPUs tested: n/a AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (Not applicable: no translator rule.)
KernelSmoker commented 2026-11-24 15:26:22 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KernelSmoker on 2026-11-24T15:26:22Z.

Review: CHANGES_REQUESTED


Reviewed exact head 2054bc4920de49959f10dae7e197903daf58d886. I reproduced the disclosed integration failure: merging #848 (f0c8d747) into this PR is textually clean, but python3 -I tests/test_import_fail_fast.py -v then runs 14 tests and fails test_cli_dll_all_json_matches_documented_invocation: --dll other.dll --all --json returns exit 2 with no import matches --dll other.dll, while #848 asserts exit 0 and an empty imports object. This means the two open PRs cannot both merge unchanged. Please coordinate the intended empty-selector behavior with #848 and update the relevant test/docs or selector policy so the combined head passes. The isolated PR #941 tests may pass, but the combined change currently fails. No game data or GPU used.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6042170449 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/941#pullrequestreview-6042170449). Originally posted by [KernelSmoker](https://github.com/KernelSmoker) on 2026-11-24T15:26:22Z. **Review:** CHANGES_REQUESTED --- Reviewed exact head `2054bc4920de49959f10dae7e197903daf58d886`. I reproduced the disclosed integration failure: merging #848 (`f0c8d747`) into this PR is textually clean, but `python3 -I tests/test_import_fail_fast.py -v` then runs 14 tests and fails `test_cli_dll_all_json_matches_documented_invocation`: `--dll other.dll --all --json` returns exit 2 with `no import matches --dll other.dll`, while #848 asserts exit 0 and an empty imports object. This means the two open PRs cannot both merge unchanged. Please coordinate the intended empty-selector behavior with #848 and update the relevant test/docs or selector policy so the combined head passes. The isolated PR #941 tests may pass, but the combined change currently fails. No game data or GPU used.
TheGeogeo commented 2026-11-24 20:52:39 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-24T20:52:39Z.


#848 is on main now, so this branch is rebased on 66d4f5aa and the conflict from the review is resolved in 9eea92ca.

  • The selector policy stays: a selector that matches nothing is refused with exit 2, as in import_call_sites.py.
  • test_cli_dll_all_json_matches_documented_invocation now expects that refusal for --dll other.dll --all --json. Its valid-selector checks are unchanged, and docs/exe_fail_fast.md only documents a selector that matches.
  • On Windows 11, Python 3.12.4: tests/test_import_fail_fast.py has 1 failure of 14 without this commit and 14 OK with it. tests/test_import_call_sites.py 21 OK, tests/test_docs_links.py 16 OK, test_docs_cli_flags.py OK, data guard and git diff --check clean.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7144175655 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/941#issuecomment-7144175655). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-24T20:52:39Z. --- #848 is on `main` now, so this branch is rebased on `66d4f5aa` and the conflict from the [review](https://github.com/ubiquitarianism/leonida/pull/941#pullrequestreview-6042170449) is resolved in `9eea92ca`. - The selector policy stays: a selector that matches nothing is refused with exit 2, as in `import_call_sites.py`. - `test_cli_dll_all_json_matches_documented_invocation` now expects that refusal for `--dll other.dll --all --json`. Its valid-selector checks are unchanged, and `docs/exe_fail_fast.md` only documents a selector that matches. - On Windows 11, Python 3.12.4: `tests/test_import_fail_fast.py` has 1 failure of 14 without this commit and 14 OK with it. `tests/test_import_call_sites.py` 21 OK, `tests/test_docs_links.py` 16 OK, `test_docs_cli_flags.py` OK, data guard and `git diff --check` clean. AI-assisted: yes (Claude Code).
TheGeogeo commented 2026-11-25 19:50:15 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-25T19:50:15Z.


Rebased from 9eea92ca to 0718a8a9 on main e18b59a5, same patch (git range-diff): the two commits are unchanged. The old base was why test_ctest_registration.py failed in this pull request's CI (vk_host_region_import_test.cpp:341); it passes on the new base.

Windows 11, Python 3.12.4: test_import_fail_fast.py 14, test_import_call_sites.py 21, test_ctest_registration.py 5, test_ci_registration.py 16 and test_docs_links.py 16 pass, test_docs_cli_flags.py and test_text_write_line_endings.py too. test_tool_stdout_encoding.py fails on main alone as well (three tools this change does not touch), so the stdlib jobs may stay red for that. The changes requested in the 2026-11-24 review on 2054bc49 were already addressed in 9eea92ca (now 0718a8a9).

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7172829363 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/941#issuecomment-7172829363). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-25T19:50:15Z. --- Rebased from `9eea92ca` to `0718a8a9` on `main` `e18b59a5`, same patch (`git range-diff`): the two commits are unchanged. The old base was why `test_ctest_registration.py` failed in this pull request's CI (`vk_host_region_import_test.cpp:341`); it passes on the new base. Windows 11, Python 3.12.4: `test_import_fail_fast.py` 14, `test_import_call_sites.py` 21, `test_ctest_registration.py` 5, `test_ci_registration.py` 16 and `test_docs_links.py` 16 pass, `test_docs_cli_flags.py` and `test_text_write_line_endings.py` too. `test_tool_stdout_encoding.py` fails on `main` alone as well (three tools this change does not touch), so the stdlib jobs may stay red for that. The changes requested in the 2026-11-24 review on `2054bc49` were already addressed in `9eea92ca` (now `0718a8a9`). AI-assisted: yes (Claude Code)
OreoFR commented 2026-11-27 19:42:33 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-27T19:42:33Z.


Merge test and review, taken from the pool PRs MoonEyes had not checked yet. Main ec91d695c merged without conflict; the PR's test files run with the pins of tests/requirements.txt on Windows 11, Python 3.12 (venv). AI-assisted (Claude Code, Claude Opus 5.5).

  • Tests: with the PR 14 passed; against main: 4 failed (the CLI selector cases). The fix is shown.
  • Nit: the title reads as test-only, but the CLI changes: a malformed or unmatched --import/--dll now exits 2 with no output instead of 0. Worth a line in the description.
<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7226793188 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/941#issuecomment-7226793188). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-27T19:42:33Z. --- Merge test and review, taken from the pool PRs MoonEyes had not checked yet. Main ec91d695c merged without conflict; the PR's test files run with the pins of `tests/requirements.txt` on Windows 11, Python 3.12 (venv). AI-assisted (Claude Code, Claude Opus 5.5). - **Tests:** with the PR 14 passed; against main: 4 failed (the CLI selector cases). The fix is shown. - Nit: the title reads as test-only, but the CLI changes: a malformed or unmatched `--import`/`--dll` now exits 2 with no output instead of 0. Worth a line in the description.
TheGeogeo commented 2026-11-28 15:53:22 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-28T15:53:22Z.


No code change. I checked head 0718a8a9a again against the current main.

  • The 2026-11-24 change request was about the conflict with #848. #848 is on main, and 9eea92ca (now 0718a8a9) resolved it. A selector that matches nothing is refused with exit 2, the same as in import_call_sites.py. test_cli_dll_all_json_matches_documented_invocation expects that refusal for --dll other.dll --all --json, and docs/exe_fail_fast.md documents only a selector that matches.
  • @OreoFR's note: the description now says that a malformed or unmatched --import / --dll exits 2, with the error on stderr and nothing on stdout. Before, it exited 0 with the usual output.

Windows 11, Python 3.12.4:

  • PR head: python -I tests/test_import_fail_fast.py gave 14 OK.
  • Trial merge with main c1ecf04ed (clean, tools/import_fail_fast.py merged automatically):
    • test_import_fail_fast.py 14 OK
    • test_import_call_sites.py 26 OK
    • test_docs_links.py 17 OK
    • test_docs_cli_flags.py 4 OK

@KernelSmoker, could you take another look?

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7241813539 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/941#issuecomment-7241813539). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-28T15:53:22Z. --- No code change. I checked head `0718a8a9a` again against the current `main`. - The 2026-11-24 change request was about the conflict with #848. #848 is on `main`, and `9eea92ca` (now `0718a8a9`) resolved it. A selector that matches nothing is refused with exit 2, the same as in `import_call_sites.py`. `test_cli_dll_all_json_matches_documented_invocation` expects that refusal for `--dll other.dll --all --json`, and `docs/exe_fail_fast.md` documents only a selector that matches. - @OreoFR's note: the description now says that a malformed or unmatched `--import` / `--dll` exits 2, with the error on stderr and nothing on stdout. Before, it exited 0 with the usual output. Windows 11, Python 3.12.4: - PR head: `python -I tests/test_import_fail_fast.py` gave 14 OK. - Trial merge with `main` `c1ecf04ed` (clean, `tools/import_fail_fast.py` merged automatically): - `test_import_fail_fast.py` 14 OK - `test_import_call_sites.py` 26 OK - `test_docs_links.py` 17 OK - `test_docs_cli_flags.py` 4 OK @KernelSmoker, could you take another look? AI-assisted: yes
OreoFR commented 2026-11-29 00:27:04 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T00:27:04Z.


Verified by OreoFR

  • Base: main 48bae6cad + PR head 0718a8a9a (merge git merge --no-ff, clean)
  • Test: python -I tests/test_import_fail_fast.py
  • Red on main (main + the PR's test file): 4 failed of 14 (the CLI selector cases: malformed selector, typo beside a good selector, selector the image does not have, --dll all --json)
  • Green with the PR: 14 OK
  • Verdict: READY (still holds on today's main)
  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248120963 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/941#issuecomment-7248120963). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T00:27:04Z. --- **Verified by OreoFR** - Base: main `48bae6cad` + PR head `0718a8a9a` (merge `git merge --no-ff`, clean) - Test: `python -I tests/test_import_fail_fast.py` - Red on main (main + the PR's test file): 4 failed of 14 (the CLI selector cases: malformed selector, typo beside a good selector, selector the image does not have, `--dll all --json`) - Green with the PR: 14 OK - Verdict: **READY** (still holds on today's main) - Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 AI-assisted (Claude Code, Claude Opus 5.5).
MoonEyes commented 2026-11-29 01:22:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T01:22:25Z.


Merged after OreoFR's red/green check (check) (RTX 4070 Laptop, driver 621.40, Windows 11) and a local re-check here. Merged after local re-verification: this PR merged onto main 0a325350e without conflict, and its test file(s) (tests/test_import_fail_fast.py) pass there. Earlier today the same tests failed on main without the PR (red/green) and a bundle with other open PRs showed no new failures. check_no_game_data.py is clean. Windows 11, Python 3.14; no GPU needed for these tests.

AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248739721 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/941#issuecomment-7248739721). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T01:22:25Z. --- Merged after **OreoFR**'s red/green check ([check](https://github.com/ProjectLeonida/mandy/pull/941#issuecomment-7248120963)) (RTX 4070 Laptop, driver 621.40, Windows 11) and a local re-check here. Merged after local re-verification: this PR merged onto `main` 0a325350e without conflict, and its test file(s) (`tests/test_import_fail_fast.py`) pass there. Earlier today the same tests failed on `main` without the PR (red/green) and a bundle with other open PRs showed no new failures. `check_no_game_data.py` is clean. Windows 11, Python 3.14; no GPU needed for these tests. _AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes._
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!941
No description provided.