Skip to content

test(semantic): prune stale DEBT entries in test_semantic_translator_use and require entries to be unreaching - #5431

Open
neoisg8 wants to merge 1 commit into
ItsNotRexed:mainfrom
neoisg8:test-semantic-debt-audit
Open

neoisg8 wants to merge 1 commit into
ItsNotRexed:mainfrom
neoisg8:test-semantic-debt-audit

Conversation

@neoisg8

@neoisg8 neoisg8 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: #5361 (comment)

What and why

tests/test_semantic_translator_use.py guards against semantic tests that model instructions instead of calling tools/rdna2spirv.py. While ALLOWLIST has test_allowlist_entries_are_real_and_still_needed to prevent stale exemptions, DEBT had no corresponding check.

Auditing DEBT revealed:

  1. Two entries named files that no longer exist on main (test_alu_dot2acc_f16.py, test_lds_add_sub_src2_u32.py).
  2. 26 entries named files that have already been converted to call rdna2spirv / support (test_alu_cndmask_b64.py, test_ballot_votes.py, test_salu_add_sub_co_u32.py, test_salu_and_saveexec_b64.py, test_salu_andn2_saveexec_b64.py, test_salu_nand_nor_saveexec_b64.py, test_salu_or_saveexec_b64.py, test_salu_orn2_saveexec_b64.py, test_salu_xnor_saveexec_b64.py, test_salu_xor_saveexec_b64.py, test_valu_add_f16.py, test_valu_alignbyte_b32.py, test_valu_dot4_int.py, test_valu_dot8_int.py, test_valu_fma_f16.py, test_valu_lerp_u8.py, test_valu_mul_f16.py, test_valu_mul_hi.py, test_valu_perm_b32.py, test_valu_pk_add_f16.py, test_valu_pk_fma_f16.py, test_valu_pk_minmax_f16.py, test_valu_pk_mul_f16.py, test_valu_sad_u32.py, test_valu_sub_f16.py, test_valu_subrev_f16.py).
  3. Only 32 files are actual remaining debt.

This change:

  • Adds test_debt_entries_are_real_and_still_needed (analogue to test_allowlist_entries_are_real_and_still_needed), asserting that each entry in DEBT exists on disk and does not yet reach the translator.
  • Prunes the 28 stale entries from DEBT (reducing DEBT from 60 to 32 entries).

Tested

  • Windows 11 x64, Python 3.14.3, CPU only, no GPU or game data needed.
  • Fail-first verified on main (3faac557): adding test_debt_entries_are_real_and_still_needed without modifying DEBT fails immediately on the missing files (AssertionError: False is not true : DEBT names a missing file: test_alu_dot2acc_f16.py) and on converted files reaching the translator.
  • Green: python -I tests/test_semantic_translator_use.py -v -> 4/4 OK (7.20s).
  • python -m compileall -q tests/test_semantic_translator_use.py -> exit 0.
  • python -I scripts/check_no_game_data.py -> exit 0.
  • git diff --check -> clean, LF line endings preserved.

AI-assisted.

Checklist

  • 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. (N/A - test guard maintenance only.)

@SweatierKey

Copy link
Copy Markdown
Contributor

Independent CPU verification on Linux (Python 3.13.5, head fe6f04c4, base main 3faac557):

  • git diff --check main...HEAD and python3 -I -m py_compile tests/test_semantic_translator_use.py — clean.
  • python3 -I tests/test_semantic_translator_use.py -v — 4/4 OK.
  • Independently audited all 28 removed DEBT entries against main 3faac557 (60 → 32 entries): 2 missing files (test_alu_dot2acc_f16.py, test_lds_add_sub_src2_u32.py), 26 already reaching rdna2spirv, 0 still debt. The pruning list itself is 100% accurate.

Design / merge-coordination note on test_debt_entries_are_real_and_still_needed:
The comment directly above DEBT (tests/test_semantic_translator_use.py:44-46, unchanged in this PR) explicitly states why DEBT was intentionally not enforced the same way as ALLOWLIST:

"They are expected to be replaced, so an entry here never has to be kept in step with another PR: fixing the file, or deleting it, simply removes it from the debt."

Adding test_debt_entries_are_real_and_still_needed directly contradicts that comment and means any open PR converting or deleting one of the remaining 32 DEBT files without also editing DEBT in tests/test_semantic_translator_use.py will fail CI once this merges (and touching DEBT in every conversion PR creates merge conflicts across concurrent PRs). Worth deciding whether to keep just the 28-entry prune (leaving DEBT non-failing per the comment) or update lines 44–46 to match the new strict contract if maintainers prefer enforcement.

@JakubRasken

Copy link
Copy Markdown

Independent CPU review of 3faac557 + this head (no GPU, no game files, no SPIRV-Tools). macOS arm64, CPython 3.12.16.

Correctness of the 28 removals. I recomputed the set from main and checked each removed entry two ways: does the file still exist, and does the guard's own _reaches() say it reaches tools/rdna2spirv.py?

  • 2 name deleted files: test_alu_dot2acc_f16.py (f9de6c1), test_lds_add_sub_src2_u32.py (be60ba3).
  • 26 now reach the translator.
  • 0 removed entries are still hollow, so nothing here drops real debt coverage. I also checked the 7 saveexec files individually rather than trusting the import: they delegate to saveexec_run, which calls support.translate_lines at saveexec_run.py:71.

Is the new check a real detector, or could it pass vacuously? Three negative controls, by reassigning DEBT in the imported module rather than editing the file:

injected entry result
test_valu_mul_hi.py (exists, now reaches) fails: "now reaches rdna2spirv; remove its DEBT entry"
test_does_not_exist_xyz.py (missing file) fails: "DEBT names a missing file"
test_valu_div_fixup.py with reason " " fails: "has no reason"

So all three arms (exists, reason, still-hollow) are load-bearing.

Other checks on the head

  • python -I tests/test_semantic_translator_use.py: 4 tests OK.
  • python -I tests/test_docs_python_deps.py: 3 tests OK (this file is named in CONTRIBUTING.md, so worth confirming the dict edit did not drift it).
  • python -I tests/test_check_no_game_data.py: 5 tests OK.
  • python -m compileall -q tests/test_semantic_translator_use.py: clean.
  • git diff main...pr5431 --check: clean; head is 0 commits behind main.

One note, not a blocker: main's comment above DEBT still says an entry "never has to be kept in step with another PR", which is the belief that produced the 28 stale entries. Worth rewording in this PR to say a fixed or deleted file loses its entry in the same change, now that the test enforces it.

Nothing here needs a GPU or a game copy. AI-assisted.

@JakubRasken

Copy link
Copy Markdown

Adding the whole-suite A/B, since the focused file passing does not by itself rule out a regression.

python -m unittest discover -s tests/semantic, macOS arm64, CPython 3.12.16, CPU only:

tree result
main 3faac557 6245 tests, FAILED (failures=32, errors=3, skipped=16, expected failures=1)
this head 6245 tests, FAILED (failures=32, errors=3, skipped=16, expected failures=1)

Same test ids in both runs, no new failure:

So this PR is a clean +0/-0 on the suite.

One related note for whoever merges: neoisg8's change and mine reached the same 28 removals independently with the same test name, so if anyone else has a branch for this item it can be closed rather than rebased.

AI-assisted.

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Head: fe6f04c465c5164547fcdd5d9599ead642886640

Windows 11, Python 3.13.7:

  • python -I tests/test_semantic_translator_use.py -v -> 4/4 OK (5.55 s)
  • DEBT: 60 -> 32 entries.
  • Fail-first on main 3faac557 with only the new method added -> AssertionError: DEBT names a missing file: test_alu_dot2acc_f16.py.
  • git diff --check main...HEAD -> clean

The new guard mirrors the existing ALLOWLIST stale-entry check; the pruned entries are genuinely absent or already translator-reaching at this head.

Verdict: LGTM.

@neoisg8

neoisg8 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Rebased cleanly onto latest main (561b65a83):

  1. Updated contract comment: Updated the comment directly above DEBT as suggested by @SweatierKey and @JakubRasken to align with the enforced check:

    "Debt from before this guard: files that model the answer instead of running the translator. When a file is converted to call the translator, or deleted, its entry is removed from DEBT in the same change. Do not add new files here; write a translator-backed test instead."

  2. Pruned 8 newly-converted entries: As concurrent PRs landed on main, test_debt_entries_are_real_and_still_needed immediately caught 8 newly-translated files (test_alu_u16_clamp.py, test_salu_bitfield_ins_u32.py, test_valu_cvt_int_f64.py, test_valu_fract_f16.py, test_valu_pack_b32_f16.py, test_valu_rcp_f16.py, test_valu_rsq_f16.py, test_valu_sqrt_f16.py). Pruned those as well, bringing total pruned entries from 28 to 36 (60 → 24 remaining debt entries).
  3. Verification:
    • python -I tests/test_semantic_translator_use.py -v: 4/4 passed.
    • python -m compileall -q tests/test_semantic_translator_use.py: clean.
    • python -I tests/test_docs_python_deps.py: clean.
    • python -I tests/test_check_no_game_data.py: clean.
    • git diff --check: clean.

AI-assisted.

@neoisg8
neoisg8 force-pushed the test-semantic-debt-audit branch 2 times, most recently from f2bc56c to 42d7d6b Compare November 23, 2026 14:27
@neoisg8 neoisg8 changed the title test(semantic): prune 28 stale DEBT entries in test_semantic_translator_use and require DEBT entries to be real debt test(semantic): prune 31 stale DEBT entries in test_semantic_translator_use and require DEBT entries to be real debt Nov 23, 2026
@neoisg8

neoisg8 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Rebased cleanly onto latest main (4beffda88).

Accounting for newly merged commits (#3593 dropping model-only LDS tests and #4123 clearing 4 converted files):

AI-assisted.

@neoisg8
neoisg8 force-pushed the test-semantic-debt-audit branch from 42d7d6b to f700938 Compare November 23, 2026 14:40
@neoisg8 neoisg8 changed the title test(semantic): prune 31 stale DEBT entries in test_semantic_translator_use and require DEBT entries to be real debt test(semantic): prune 32 stale DEBT entries in test_semantic_translator_use and require DEBT entries to be real debt Nov 23, 2026
@neoisg8

neoisg8 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Re-synced with latest main (1cc6e3c12):

  • PR tests/semantic: convert test_int_to_float DEBT entry to a translator-backed test #6315 just landed on main, converting test_int_to_float.py to a translator-backed test. test_debt_entries_are_real_and_still_needed immediately detected this change as designed (AssertionError: test_int_to_float.py now reaches rdna2spirv; remove its DEBT entry).
  • Pruned test_int_to_float.py, bringing total pruned stale entries to 32 (leaving 13 remaining hollow tests).
  • All 4 tests pass (python -I tests/test_semantic_translator_use.py -v). Clean and mergeable.

AI-assisted.

@neoisg8

neoisg8 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Rebased cleanly onto latest main (db7724440).

Following upstream merges that converted additional semantic tests to translator-backed tests and pruned some earlier entries, DEBT has now been pruned of all 27 remaining stale entries (reducing DEBT from 40 down to the 13 actual remaining debt items), and test_debt_entries_are_real_and_still_needed verifies all 13 are valid and unreaching.

Verification on Windows 11 CPU (zero game data):

python -I tests/test_semantic_translator_use.py -v
Ran 4 tests in 7.28s - OK

AI-assisted.

@neoisg8 neoisg8 changed the title test(semantic): prune 32 stale DEBT entries in test_semantic_translator_use and require DEBT entries to be real debt test(semantic): prune stale DEBT entries in test_semantic_translator_use and require entries to be unreaching Nov 23, 2026
@JRamos1993

Copy link
Copy Markdown
Contributor

Tested 42f82ff3 merged onto main 511e3826 on Windows 11, CPython 3.14.3, CPU only: pass.

  • python -I tests/test_semantic_translator_use.py: 4 tests OK.
  • py_compile on the 1 changed Python file: OK; git diff --check: clean.

No game files. AI-assisted (Claude Code).

@neoisg8
neoisg8 force-pushed the test-semantic-debt-audit branch 2 times, most recently from 32bd127 to a8fbc4e Compare November 23, 2026 17:21
@wavehs

wavehs commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested a8fbc4e9b on Apple M3 Pro (macOS arm64, CPython 3.15.2, CPU only — no GPU involved): pass.

  • python3 -I tests/test_semantic_translator_use.py -v -> 4 tests, OK (2.8 s).
  • Prune audit, independent of the new test: of the 27 entries dropped from DEBT, 26 files exist on origin/main and all 26 reach rdna2spirv (_reaches returns True for each); test_lds_add_sub_src2_u32.py no longer exists. All 13 remaining entries are real files that still do not reach the translator, so nothing was pruned that the guard would still need.
  • Negative control on origin/main dde82f27e (main's DEBT, head's new test method kept): the new test fails with AssertionError: True is not false : test_alu_cndmask_b64.py now reaches rdna2spirv; remove its DEBT entry; the other 3 tests stay green. The two other branches were exercised synthetically on this head: an entry for a missing file -> DEBT names a missing file: ..., an empty reason -> DEBT entry ... has no reason.
  • Merges cleanly onto origin/main dde82f27e (git merge --no-commit --no-ff, no conflicts); the 4 tests pass again on the merged tree.
  • python -m compileall -q, python -I scripts/check_no_game_data.py tests/test_semantic_translator_use.py and git diff --check are clean; the file is LF and ends with a newline. One file changed, so no cross-platform or path issues to worry about (os.path.isfile/os.path.join only).

Note for merging: this is a meta-test only, so it does not touch the translator or any tests/semantic fixture.

AI-assisted.

@bobcatchris

Copy link
Copy Markdown
Contributor

Tested b729e10 on Ubuntu 24.04.4 (kernel 7.0.0-31-generic), Python 3.12.3, CPU only, no game files: pass.

  • python3 -I tests/test_semantic_translator_use.py: 4/4 pass.
  • Negative control: a copy of the PR's test file with one stale DEBT entry (a filename that does not exist) fails only test_debt_entries_are_real_and_still_needed (DEBT names a missing file); the other 3 tests still pass. The temporary copy was removed.
  • Code read: the 20 pruned DEBT entries name files that no longer exist or that now reach rdna2spirv.py; the new test mirrors the ALLOWLIST guard, requiring each remaining entry to name a real file, give a non-empty reason and not reach the translator. Only the test file changes, so the translator itself is untouched.
  • compileall / check_no_game_data / diff --check: pass.

Synthetic inputs only; no game data.

AI-assisted.

@neoisg8
neoisg8 force-pushed the test-semantic-debt-audit branch 4 times, most recently from 64d2dce to 9a69319 Compare November 23, 2026 18:52
@YordiLorenzo

Copy link
Copy Markdown

Tested 9a69319 on Linux, Python 3.12.16 and 3.14.4: pass

  • python -I tests/test_semantic_translator_use.py: 4 tests OK on the head, and OK on main 867d922 with this file swapped in
  • Negative control, main's 40 DEBT entries under the new test: fails on test_alu_cndmask_b64.py now reaching rdna2spirv
  • scripts/check_no_game_data.py on the file: exit 0
  • Merge order: tests/semantic: run v_div_fixup_f32 through the translator instead of a mock oracle (TEST-545) #3011 converts test_valu_div_fixup.py and leaves its DEBT entry, so with this file in its tree the new test fails there. Whichever lands second has to drop that entry

@morodirule

Copy link
Copy Markdown

Tested 228b6d7 on Arch Linux, Python 3.14.10, CPU only: pass, first Linux check on this head. tests/test_semantic_translator_use.py 4/4 OK. Negative control: merge-base file runs 3/3 (guard is new in this PR); restored, 4/4 green. Meta-test only, translator untouched. No game files. AI-assisted.

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.

9 participants