test: pin the hex redaction outside operand positions in a refusal reason #1986

Merged
ChazY11 merged 1 commit from upstream-pr/1993 into main 2026-11-24 22:49:38 +00:00
ChazY11 commented 2026-11-24 22:44:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T22:44:08Z.


What

normalize_refusal in tools/startup/gfx2hlsl.py redacts a bare 0x… literal with the generic rule at line 2130:

reason = re.sub(r'(?<!\w)[+-]?0x[0-9a-f]+\b', 'N', reason, flags=re.IGNORECASE)

The operand-position rule that follows (2132–2133) only covers labelled positions such as offset 0x10 or dmask:0xf, so a literal
in free text is covered only by the generic line. The check added by #1978 never feeds such a reason, so removing that line leaves
the suite green:

# tools/startup/gfx2hlsl.py: delete the line above
out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_refusals_check.py    # exit 0 before this change

Change

Two rows in the existing table in check_normalization(), one for a literal in prose and one for a NaN pattern:

('word_0xdeadbeef', 'word_N'),
# A bare literal outside an operand position: the operand rule above does not reach it.
('v_mov_b32 with literal 0x3f800000', 'v_mov_b32 with literal N'),
('unexpected value 0x7fc00000 in source', 'unexpected value N in source')):

tests/startup_gfx2hlsl_refusals_check.py only. No production change, no new file, no CMake change.

Why it matters

Two properties of a census key are at stake, and both are stated in that function's own comment:

  • a report that people paste into an issue should not carry input-derived values, and a literal like 0x7fc00000 is exactly that;
  • two refusals that differ only in a literal must collapse to one site, or the count is inflated — the overcount this diagnostic
    exists to reduce.

Tested

out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_refusals_check.py    # exit 0
out/pe-env/Scripts/python.exe -B tests/startup_translator_check.py           # exit 0

Fail-first, with the redaction line removed and restored:

normalization of v_mov_b32 with literal N: MISMATCH
normalization of unexpected value N in source: MISMATCH
exit 1

and with the line back, exit 0.

Notes

  • AI-assisted.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6592899311 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1993). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T22:44:08Z. --- ## What `normalize_refusal` in `tools/startup/gfx2hlsl.py` redacts a bare `0x…` literal with the generic rule at line 2130: ```python reason = re.sub(r'(?<!\w)[+-]?0x[0-9a-f]+\b', 'N', reason, flags=re.IGNORECASE) ``` The operand-position rule that follows (2132–2133) only covers labelled positions such as `offset 0x10` or `dmask:0xf`, so a literal in free text is covered *only* by the generic line. The check added by #1978 never feeds such a reason, so removing that line leaves the suite green: ```powershell # tools/startup/gfx2hlsl.py: delete the line above out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_refusals_check.py # exit 0 before this change ``` ## Change Two rows in the existing table in `check_normalization()`, one for a literal in prose and one for a NaN pattern: ```python ('word_0xdeadbeef', 'word_N'), # A bare literal outside an operand position: the operand rule above does not reach it. ('v_mov_b32 with literal 0x3f800000', 'v_mov_b32 with literal N'), ('unexpected value 0x7fc00000 in source', 'unexpected value N in source')): ``` `tests/startup_gfx2hlsl_refusals_check.py` only. No production change, no new file, no CMake change. ## Why it matters Two properties of a census key are at stake, and both are stated in that function's own comment: - a report that people paste into an issue should not carry input-derived values, and a literal like `0x7fc00000` is exactly that; - two refusals that differ only in a literal must collapse to one site, or the count is inflated — the overcount this diagnostic exists to reduce. ## Tested ```powershell out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_refusals_check.py # exit 0 out/pe-env/Scripts/python.exe -B tests/startup_translator_check.py # exit 0 ``` **Fail-first**, with the redaction line removed and restored: ```text normalization of v_mov_b32 with literal N: MISMATCH normalization of unexpected value N in source: MISMATCH exit 1 ``` and with the line back, `exit 0`. ## Notes - AI-assisted.
upstream-sync closed this pull request 2026-11-24 23:03:29 +00:00
tedin7 commented 2026-11-24 23:03:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T22:51:22Z.

Review: COMMENTED


Review of head 46303c0a114be4fa6de3598fc923eea5b71c7062.

Change: adds two normalization cases to tests/startup_gfx2hlsl_refusals_check.py (bare hex literal outside an operand position, redacted to N). Test-only, one file, no CMake change, no new dependency. Clean-room: only synthetic strings.

Commands executed locally:

  • git merge-tree --write-tree --name-only origin/main HEAD: clean, no conflicts
  • python3 tests/startup_gfx2hlsl_refusals_check.py: PASS (both new cases ok)
  • python3 tests/docs_links_check.py: PASS (18 files, 388 links)
  • python3 tests/bidi_controls_check.py: PASS (1382 files)
  • git diff --check origin/main...HEAD: clean
  • Win2025 (Build 26100, MSVC 14.44, WARP), full build: Debug --preset dev ctest ^startup_gfx2hlsl_refusals$ 1/1 passed; Release /O2 1/1 passed
  • CI: Windows, Linux Python checks, gfx1013 fixtures all pass

Mutation check (in tools/startup/gfx2hlsl.py, reverted afterwards):

  • Disabling the bare-hex rule in normalize_refusal (0x[0-9a-f]+ -> 0xZ[0-9a-f]+): KILLED. Both new cases report MISMATCH.
  • Dropping the (?<!\w) lookbehind: survives. Not covered by this PR's cases; not a blocker.

P1: 0. P2: 0.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6048643486 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1993#pullrequestreview-6048643486). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T22:51:22Z. **Review:** COMMENTED --- Review of head `46303c0a114be4fa6de3598fc923eea5b71c7062`. Change: adds two normalization cases to `tests/startup_gfx2hlsl_refusals_check.py` (bare hex literal outside an operand position, redacted to `N`). Test-only, one file, no CMake change, no new dependency. Clean-room: only synthetic strings. Commands executed locally: - `git merge-tree --write-tree --name-only origin/main HEAD`: clean, no conflicts - `python3 tests/startup_gfx2hlsl_refusals_check.py`: PASS (both new cases ok) - `python3 tests/docs_links_check.py`: PASS (18 files, 388 links) - `python3 tests/bidi_controls_check.py`: PASS (1382 files) - `git diff --check origin/main...HEAD`: clean - Win2025 (Build 26100, MSVC 14.44, WARP), full build: Debug `--preset dev` ctest `^startup_gfx2hlsl_refusals$` 1/1 passed; Release `/O2` 1/1 passed - CI: Windows, Linux Python checks, gfx1013 fixtures all pass Mutation check (in `tools/startup/gfx2hlsl.py`, reverted afterwards): - Disabling the bare-hex rule in `normalize_refusal` (`0x[0-9a-f]+` -> `0xZ[0-9a-f]+`): KILLED. Both new cases report MISMATCH. - Dropping the `(?<!\w)` lookbehind: survives. Not covered by this PR's cases; not a blocker. P1: 0. P2: 0. AI-assisted; commands listed were executed locally.
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
R0Y00/Xbox2Windows!1986
No description provided.