Skip to content

find_hash_lookup: hash the Latin-1 bytes of a name, like the dictionary - #4882

Open
Ayinaki wants to merge 1 commit into
ItsNotRexed:mainfrom
Ayinaki:fix/find-hash-lookup-latin1
Open

Ayinaki wants to merge 1 commit into
ItsNotRexed:mainfrom
Ayinaki:fix/find-hash-lookup-latin1

Conversation

@Ayinaki

@Ayinaki Ayinaki commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as this item.

What and why

tools/find_hash_lookup.py carries its own copy of Jenkins one-at-a-time and encoded the lower-cased name as UTF-8:

for c in name.lower().encode("utf-8"):

Every dictionary in the pipeline and every other copy in tools/ hash the Latin-1 bytes — tools/hashdict.py does s.lower().encode("latin-1", "replace"), and its harvest() decodes the dictionary strings as Latin-1, so that is the only encoding a stored hash can belong to. For any name with a non-ASCII character the tool therefore produced a hash nothing stores, and the lookup it feeds silently found nothing: the tool's joaat("Radio_LosSantos_Café"), and with it parse_hash behind --hash, gave 974630864 where hashdict.joaat gives 811395798.

The fix is that one line, plus the docstring naming the bytes. The test part is separate: tests/test_joaat_agreement.py imports every joaat/joaat32 copy it finds in tools/, but its EXPECTED tuple — the guard that keeps the loop from becoming a test of nothing after a rename — did not name this tool, so the new copy was only caught because the enumeration happened to pick it up. It is named there now.

Tested

Windows 11 26200, Python 3.14.6, CPU only; no GPU, no game data.

command result
py -3 -m pytest tests/test_joaat_agreement.py -q with only the test half applied (98fa503f8 + new EXPECTED) 6 failed, 2 passed, 98 subtests passed — all six SUBFAILED(copy='find_hash_lookup', name=…)
same command with both halves 2 passed, 104 subtests passed
py -3 -m pytest tests/test_joaat_agreement.py tests/test_find_hash_lookup.py -q 6 passed, 104 subtests passed
py -3 -I tests/test_joaat_agreement.py Ran 2 tests, OK
py -3 -m compileall -q tools/find_hash_lookup.py tests/test_joaat_agreement.py exit 0
py -3 -I tools/find_hash_lookup.py --help usage printed, exit 0

Full-suite context on 98fa503f8, where the item was found:

  • py -3 -m pytest tests --ignore=tests/semantic -q → 9 failed, 7048 passed, 95 skipped, 8124 subtests passed. Six of the nine were this item; the other three are
    tests/test_rdna2_decode.py::test_parity_with_llvm_mc_on_shader_fixtures — on runtime/test/shaders/ps_sdwa_f16_const.asm the decode's encoding is f9a00a7ef2148500 where llvm-mc
    re-encodes its own disassembly as f9a00a7eff148500003c0000, so the f16 inline constant's literal is lost (from the SDWA inline-constant work, 998128ec / d78546fc), and
    tests/test_saves.py::AtomicPackTest::test_destination_symlinks_update_the_target_and_remain_links (its link reads back with a \?\ prefix, tests: test_saves compares a symlink with what it stored, so it passes on Windows #3983). Both are red on a pristine
    d974c88a worktree as well, so neither comes from this diff.
  • the check job's standard-library loop, with the workflow's own file selection (every tests/test_*.py outside tests/semantic that has __main__ and no pytest markers): 339 files run, 2 failed, and both are the two pre-existing ones above.
  • the no-game-data job's steps: the git ls-files binary-name filter finds nothing, python -I scripts/check_no_game_data.py exits 0.
  • py -3 -I -m unittest discover -s tests/semantic -q → Ran 6245 tests, FAILED (failures=3, errors=2), all in test_loop_ballot_barrier (tests: test_loop_ballot_barrier follows #2089's structured wave64 emulation (main red since 1cc7497b) #3995).

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), in the change or here. The test names are synthetic.
  • No translator rule is added, so docs/design.md is unchanged.

Depends on: nothing.

CI on eaaa51c3 is queued in the repository's backlog (2,500+ queued runs against 7 in progress, with main's own push runs queued too); the run links and the local equivalents are in the comment below.

The tool's joaat encoded the lower-cased name as UTF-8, so any name with a
non-ASCII character hashed to a value none of the dictionaries stores:
tests/test_joaat_agreement.py catches six of them (café, Café, Señor, Crème
Brûlée, ÉLÉGIE, Radio_LosSantos_Café) against hashdict.joaat. tools/hashdict.py
and every other copy in tools/ hash the Latin-1 bytes, which is also how
harvest() decodes the dictionary, so a name typed into --hash now agrees with
the dictionary lookup it feeds.

The tool also joins the test's EXPECTED tuple, so a rename cannot drop it from
the loop again.
@shdann

shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested eaaa51c3 on Windows 11 with CPython 3.14.7. All four tests in py -3.14 -I -B tests/test_find_hash_lookup.py pass.

I checked parse_hash against hashdict.joaat for 258 synthetic names. Each name starts with review_. The suffix is one character from U+0000 through U+00FF, U+2603, or U+1F600. The head gives zero mismatches. Merge base 98fa503f gives 130. This covers every Latin-1 byte and two characters that need the replacement rule.

Both agreement tests also pass with discovery restricted to the seven modules in EXPECTED. This was a CPU-only check.

AI-assisted.

@tupacfan04

Copy link
Copy Markdown
Contributor

APPROVE. pytest tests/test_joaat_agreement.py tests/test_find_hash_lookup.py -q gives 6 passed / 104 subtests, compileall clean, and the -I unittest path also passes. Negative control on main fails 6 subcases (find_hash_lookup 974630864 vs 811395798), and the PR matches hashdict. The latin-1 with "replace" is identical to hashdict.py:35, and the case-sensitive joaat_cs copies are correctly excluded. Merge clean.

No issues. AI-assisted review, no game files, no GPU.

@Ayinaki

Ayinaki commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Check status on eaaa51c3 (as of 06:35 UTC): both check runs are still queued, and the repository has 2,500+ queued runs against 7 in progress — main's own push runs are queued too (45121388400 at d974c88a, 45121253526 at 902358c8), so this is the backlog and not this PR. Run links: CI / change-scope, No Game Data.

While they wait, I ran the job steps locally on this head:

  • check job's standard-library loop (same file selection as the workflow: tests/ without tests/semantic, skipping files with pytest markers and files without __main__): 339 files run, 2 failed. Both reproduce on a pristine d974c88a worktree and neither is in this diff:
    • tests/test_rdna2_decode.py::test_parity_with_llvm_mc_on_shader_fixtures, on runtime/test/shaders/ps_sdwa_f16_const.asm: our decode's encoding is f9a00a7ef2148500, llvm-mc re-encodes its own disassembly as f9a00a7eff148500003c0000 — the f16 inline constant's literal is lost. Introduced by the SDWA inline-constant work (998128ec, d78546fc), not by a hash function.
    • tests/test_saves.py — the Windows os.readlink \?\ prefix, tests: test_saves compares a symlink with what it stored, so it passes on Windows #3983 (Ran 61 tests, failures=2 on main too).
  • no-game-data job's two steps: the git ls-files binary-name filter finds nothing, python -I scripts/check_no_game_data.py exits 0.
  • The files this PR touches: python -I tests/test_joaat_agreement.py → Ran 2 tests, OK; python -m pytest tests/test_joaat_agreement.py tests/test_find_hash_lookup.py -q → 6 passed, 104 subtests passed.

I will post the verdicts once the runs actually conclude.

@Ayinaki

Ayinaki commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Runs: https://github.com/ItsNotRexed/Leonida/actions/runs/45121456066 (CI) and https://github.com/ItsNotRexed/Leonida/actions/runs/45121455957 (No Game Data).

One more observation after another 20 minutes of polling: this head's runs have not been picked up, but runs created later have been — 45124157061 (CI) and 45124156773 (Runtime) were created at 06:26:54 on another branch and concluded at 06:27:49/06:27:50, while these three from 05:45 and 06:02 are still queued, with 2,500 runs queued and 9–12 in progress. So the queue is serving newer runs ahead of these older ones rather than working through the backlog. If a maintainer clicks Re-run on the run below, or lets one of the two approval-gated runs through, that should give this head its verdict; I will keep polling and post the result either way.

@kapitche

Copy link
Copy Markdown
Contributor

Tested eaaa51c merged with main 3faac55 on Linux (WSL2), CPython 3.12.16, CPU only: pass

  • tests/test_joaat_agreement.py: 2 run, 2 passed. tests/test_find_hash_lookup.py: 4 run, 4 passed. tests/test_hashdict.py: 33 run, 33 passed.
  • Negative control: tools/find_hash_lookup.py restored from main, tests/test_joaat_agreement.py: 2 run, 6 subtest failures (find_hash_lookup hashes 'Radio_LosSantos_Café' differently from hashdict.joaat). tests/test_find_hash_lookup.py passes on main too (4/4), so it does not cover the Latin-1 change; only the agreement test does.
  • By hand: find_hash_lookup.joaat equals hashdict.joaat for 'café', 'Ünï', 'plain', a CJK name and a name with a euro sign (the last two go through the replace path).

@memorypressure

Copy link
Copy Markdown

Verified on current main (3faac55, merges cleanly): at main, python -I tests/test_joaat_agreement.py fails with exactly six mismatches, all find_hash_lookup on accented names (re-confirmed both sides here); with this PR it passes, and test_find_hash_lookup.py passes too. The new latin-1 with replace encoding line is character-identical to the pinned reference hashdict.joaat (tools/hashdict.py:35), so all copies now agree including non-Latin-1 names folding to ?. Adding find_hash_lookup to EXPECTED stops the rename-blindness. This is precisely the fix for the red agreement test the board thread has been tracking (#4421) — with this merged, main goes green on that suite. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

@memorypressure

Copy link
Copy Markdown

Follow-up to the verification above: an earlier open PR, #4753, applies the identical encode-line change plus the same EXPECTED edit (verified by diffing both), and additionally ships a dedicated unit test and a docs note. Since it landed first, it is likely the one maintainers will merge — flagging so nobody duplicates work; if #4753 does land, this PR could be closed with a pointer, or kept as the leaner variant if its author prefers. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

@B0D0PAD

B0D0PAD commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested eaaa51c on Windows 11, Python 3.14.6: python -I tests/test_joaat_agreement.py (2 tests, OK) and python -I tests/test_find_hash_lookup.py (4 tests, OK). The parent fails the 6 non-ASCII subtests, so the fix works.

Code read: latin-1 matches hashdict.joaat, and EXPECTED now names the module. #4753 covers the same bug with an added hand-computed Café test and a docs/modding.md line, so that one is the more complete of the two; no issue with this diff.

@sovljanskii

Copy link
Copy Markdown
Contributor

Tested eaaa51c3 merged onto main 3faac557 (clean) on macOS, Apple M4, with Python 3.12.16 and 3.15.2 (-I): pass. main fails 6 test_joaat_agreement subtests under both versions. Here test_joaat_agreement, test_find_hash_lookup and test_hashdict are OK. The result is identical to #4753, which has the same encode change. AI-assisted.

@leozinhoszg

Copy link
Copy Markdown
Contributor

Tested on Windows, where test_joaat_agreement fails on main.

Windows 11 Pro (26200), CPython 3.14.7, python -I <test>. %TEMP% here is an 8.3 short path (C:\Users\XXXXXX~1\...), which is what trips the main-branch failures below.

Tree tests/test_joaat_agreement.py tests/test_find_hash_lookup.py
main 3faac557b1 FAILED (failures=6): find_hash_lookup hashes café / Café differently from hashdict.joaat OK (4 tests)
this PR head eaaa51c39d OK OK (4 tests)
this PR merged onto main 3faac557b1 OK OK (4 tests), merges cleanly

#4753 makes the same find_hash_lookup.joaat change (latin-1) and passes the same way here; it also adds a test_find_hash_lookup case and a docs/modding.md note.

AI-assisted (Claude Code); I read the diffs and ran the tests myself on the machine above.

@Atomic258

Copy link
Copy Markdown
Contributor

Tested eaaa51c on Windows Server 2022, CPython 3.13.12: pass

  • python -I tests/test_joaat_agreement.py -> OK

git diff --check clean; python -m compileall -q exit 0. No game files, no GPU. AI-assisted (Devin).

@thiefyzheng thiefyzheng left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code read + local run at eaaa51c3 (AI-assisted review, per AGENTS.md).

Applies at 561b65a832 and fixes the defect: tests/test_joaat_agreement.py goes from 6 failures to OK, tests/test_find_hash_lookup.py OK, compileall clean. The EXPECTED tuple addition is worth having on its own — it is what keeps the loop from silently becoming a test of nothing if the function is renamed.

Two others fix the same line: #4753 (same one-liner plus a test that pins é = 0xE9) and #5913 (inside a larger unrelated change). Any one of them clears it; only #4753 leaves a regression pin behind, so I would take that one — this one is equally correct if the maintainer prefers the minimal diff, and its EXPECTED change should ride along either way.

@illusionart453-max

Copy link
Copy Markdown

Independent native Windows/Python 3.15 verification at eaaa51c: python -I tests/test_joaat_agreement.py passes 2/2; python -I tests/test_find_hash_lookup.py passes 4/4 in an isolated worktree. Main 8575d36 standalone audit reproduces the hash agreement failure. This checks the published head, whose test suite predates newer main additions. #4734 changes the same tool for report-input alias protection, so keep both behaviors when integrating. Synthetic CPU inputs only, no GPU/game files. AI-assisted (Codex).

@Daazd

Daazd commented Nov 23, 2026

Copy link
Copy Markdown

Independent check (Linux, Python 3.12.3, Node 24.13, CPU only, no game files): head eaaa51c39 merged onto main 6a4299563: merges clean.

  • python3 -I tests/test_joaat_agreement.py: Ran 2 tests in 0.137s OK (exit 0)

Fixes test_joaat_agreement (red on main: find_hash_lookup hashes café differently). #4753, #6254 and #7425 also fix it; all four pass.

AI-assisted (Claude Code).

@ne1i

ne1i commented Nov 23, 2026

Copy link
Copy Markdown

Tested eaaa51c3 on Linux, CPython 3.14, CPU only, synthetic inputs, merged onto main dde82f27: pass

  • python -I tests/test_joaat_agreement.py: 2 tests OK (red on main: 6 failures).
  • With only tools/find_hash_lookup.py reverted to main: 6 failures again.
  • compileall and scripts/check_no_game_data.py on the changed files: clean.

#4753, #6254 and #7820 make the same encoding change and also turn this file green; #4753 additionally adds a direct unit test.

Independent check (not the author). Run by an AI agent (DeepSeek V4.1 Flash) and re-run by the orchestrating session (Claude Code) before posting; claimed in #8047.

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.