Skip to content

find_hash_lookup: hash --hash names as latin-1, like hashdict (test_joaat_agreement fails on main) - #4753

Open
tunczzz wants to merge 1 commit into
ItsNotRexed:mainfrom
tunczzz:test-joaat-find-hash
Open

tunczzz wants to merge 1 commit into
ItsNotRexed:mainfrom
tunczzz:test-joaat-find-hash

Conversation

@tunczzz

@tunczzz tunczzz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

tests/test_joaat_agreement.py fails on main (98fa503f) with 6 subtests. tools/find_hash_lookup.py, added in 3eb4410, has its own joaat over the UTF-8 bytes of the lower-cased name. The agreement test imports every string joaat in tools/ and compares it with tools/hashdict.py, which hashes latin-1 bytes ("é" is one byte, 0xE9, not the pair 0xC3 0xA9). So every name with a non-ASCII character hashed differently: café, Café, Señor, Crème Brûlée, ÉLÉGIE, Radio_LosSantos_Café.

Claimed on #4571 (comment).

  • tools/find_hash_lookup.py: encode("latin-1", "replace"), as hashdict.joaat does. ASCII names (player_story000_00, cs_mandy) hash exactly as before.
  • tests/test_joaat_agreement.py: find_hash_lookup added to EXPECTED, so a rename can't quietly drop it from the comparison.
  • tests/test_find_hash_lookup.py: joaat("Café") equals a hash computed by hand over 63 61 66 E9.
  • docs/modding.md: one line saying how a --hash name is hashed.

Tested (WSL Ubuntu, Python venv, CPU only):

  • pytest tests/test_joaat_agreement.py tests/test_find_hash_lookup.py: 7 passed, 104 subtests. With main's tools/find_hash_lookup.py and these tests: 7 failed.
  • Full pytest tests --ignore=tests/semantic -n 2: 6987 passed, 157 skipped, 1 failed. The failure is test_rdna2_decode::test_parity_with_llvm_mc_on_shader_fixtures, which fails the same way on plain main (claimed by MichaelL401 on Coordinating who works on what (24) (moved to #4683) #4571).

No GPU needed. Runs on the PC with an RTX 5070 Ti, but nothing here touches it. Synthetic names only, no game files.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

tools/find_hash_lookup.py (3eb4410) carried its own joaat over the lower-cased UTF-8 bytes, so
tests/test_joaat_agreement.py failed on main for every non-ASCII name (6 subtests): "é" is one latin-1
byte (0xE9), the rule tools/hashdict.py and the other copies are pinned to, and two UTF-8 bytes.
Encode as hashdict does, list find_hash_lookup in the agreement test's EXPECTED copies, and add a
unit test with the hand-computed hash of "caf" + 0xE9. Synthetic names only.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@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.

Ran this at 5b4f86ede on Windows 11: pytest tests/test_find_hash_lookup.py tests/test_joaat_agreement.py -q -> 7 passed, 104 subtests passed; git diff --check clean.

--hash names are now hashed as latin-1 like hashdict, with a documented note, so the two tools agree on non-ASCII names; the JOAAT agreement test is updated for the case that failed on main. No blocking issue.

@kapitche

Copy link
Copy Markdown
Contributor

Tested 5b4f86e merged with main 98fa503 on Linux, Python 3.12.16: pass

  • tests/test_find_hash_lookup.py: 5 tests OK. tests/test_joaat_agreement.py: 2 tests OK. All 10 tests/test_docs_*.py OK.
  • Negative control: with tools/find_hash_lookup.py restored from main, the new test_joaat_hashes_latin_1_bytes_like_hashdict fails and test_joaat_agreement fails 6 subtests (copy='find_hash_lookup', the accented names); restored the PR file afterwards.
  • Checked the docs claim: tools/hashdict.py:35 uses s.lower().encode("latin-1", "replace"), the same call the PR now uses.
  • Linux only (the change is a fixed byte encoding, not platform dependent). No issues found.

@Atomic258

Copy link
Copy Markdown
Contributor

Independent verification at head 5b4f86ede3b14731d2df565e01d4f4c1ab4a81d6 on Windows 11, Python 3.15.2 (python -I, stdlib only).

  • python -I tests/test_joaat_agreement.py — 2 tests, OK (all copies incl. find_hash_lookup agree with hashdict.joaat)
  • python -I tests/test_find_hash_lookup.py — 5 tests, OK
  • git diff --check origin/main...HEAD — clean
  • Red control: git checkout origin/main -- tools/find_hash_lookup.py (PR tests kept) → test_every_copy_matches_the_pinned_dictionary fails in 6 subtests (find_hash_lookup hashes 'Radio_LosSantos_Café' differently from hashdict.joaat, UTF-8 vs latin-1) and test_joaat_hashes_latin_1_bytes_like_hashdict fails (2425794034 != 4009490211); restored → all green. Worktree left clean.

Confirms the reported main-branch failure and the latin-1 fix.

Overlap note vs #4752: not a competing fix — #4752 hardens rank/CLI edge cases in the same file and does not touch joaat; this PR only changes the joaat encoding plus test/docs. Both edit tools/find_hash_lookup.py and tests/test_find_hash_lookup.py, so the second to merge may need a small rebase, but the changes are orthogonal.

No issues found. AI-assisted (Devin).

@editrice

Copy link
Copy Markdown

Coordination overlap: #4773 makes the same tools/find_hash_lookup.py JOAAT UTF-8 → latin-1 change. Its claim on #4683 predates this PR's claim on #4571. This PR adds useful agreement coverage, a hand-computed regression, and a doc note. Could the authors coordinate to consolidate those additions into one PR before either merges? The fixes target the same defect and line; no game files are involved.

@tunczzz

tunczzz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @editrice. You're right: the claim for #4773 on #4683 came first. I missed it because I was still reading #4571 after the issue moved to #4683. Both PRs make the same one-line tools/find_hash_lookup.py change, so #4773 should go first.

This PR also adds find_hash_lookup to EXPECTED in tests/test_joaat_agreement.py (so a rename can't drop it from the comparison), a hand-computed latin-1 regression test in tests/test_find_hash_lookup.py, and a one-line note in docs/modding.md. Two ways to consolidate:

Either is fine with me. I'll follow whichever the maintainer or @lines9686-rgb prefers, and I won't touch #4773.

AI-assisted (Claude Code).

@memorypressure

Copy link
Copy Markdown

Verified against current main: first reproduced the failure — tests/test_joaat_agreement.py on plain main gives FAILED with exactly the six find_hash_lookup mismatches on accented names (re-confirmed here) — and with this PR merged that test and test_find_hash_lookup.py (including the new chr(0xE9) pin) pass, with the fix line matching tools/hashdict.py rule for rule. Coordination note, verified on the diffs: open #4882 carries the identical encode-line change plus the same EXPECTED edit; this PR is earlier and additionally pins the behaviour with its own unit test and the modding.md note, so this is the one to land. Checks pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

@B0D0PAD

B0D0PAD commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 5b4f86e 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 (5 tests, OK). On the parent 98fa503f the agreement test fails 6 subtests (find_hash_lookup hashes café, Café, Señor, Crème Brûlée, ÉLÉGIE and Radio_LosSantos_Café differently from hashdict.joaat), so the fix addresses the reported failure.

Code read: latin-1 with replace matches hashdict.joaat; adding find_hash_lookup to EXPECTED closes the rename hole; the hand-computed Café test and the docs/modding.md line are good additions. Compared with #4882, this is the more complete of the two open fixes for the same bug. LGTM.

@sovljanskii

Copy link
Copy Markdown
Contributor

Tested 5b4f86ed merged onto main 3faac557 (clean) on macOS, Apple M4, with Python 3.12.16 and 3.15.2 (-I): pass.

  • On main, tests/test_joaat_agreement.py fails 6 subtests under both versions.
  • On this branch, test_joaat_agreement, test_find_hash_lookup and test_hashdict are OK under both.

The tools/find_hash_lookup.py change is byte-for-byte the one in #4882, and both pass identically here. This PR adds the unit test and the docs line. AI-assisted.

@Atomic258

Copy link
Copy Markdown
Contributor

Tested 5b4f86e on Windows Server 2022, CPython 3.13.12: pass

  • python -I tests/test_find_hash_lookup.py -> Ran 5 tests, OK; python -I tests/test_joaat_agreement.py -> Ran 2 tests, OK
  • Negative control (tool file swapped to upstream/main): FAILED (failures=1)

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

@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 5b4f86ede3 OK OK (5 tests)
this PR merged onto main 3faac557b1 OK OK (5 tests), merges cleanly

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

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

@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 5b4f86ed (AI-assisted review, per AGENTS.md).

This is the most complete of the three open PRs for the same defect, and it verifies.

On unpatched 561b65a832, python -I tests/test_joaat_agreement.py is 6 failures, all find_hash_lookup, all non-ASCII names (café, ÉLÉGIE, Radio_LosSantos_Café, ...), each of the form 974630864 != 811395798. With this PR applied:

  • tests/test_joaat_agreement.py -> OK (6 failures gone)
  • tests/test_find_hash_lookup.py -> OK
  • python -m compileall -q tools -> clean

The added test is the right shape: pinning b"caf" + 0xE9 as the expected bytes pins the contract (é is one byte, 0xE9, per docs/audio_config.md), instead of comparing one copy of joaat with another copy, which would pass whatever either one does.

Overlap, for the coordinator, not a problem with this PR: #4882 is the identical one-liner with no byte pin, and #5913 carries the same one-liner inside a larger unrelated change. This one is the one I would take; if a different one lands, the byte-pinned test here is worth keeping.

One question: encode("latin-1", "replace") maps any character above U+00FF to ? (0x3F), so two different non-Latin-1 names can collide, and a name containing a literal ? collides with them. That matches hashdict.joaat exactly, so the copies stay in agreement — but if that is not already written down anywhere, one sentence in docs/audio_config.md next to the latin-1 rule would record it.

@best2135

Copy link
Copy Markdown

Tested 5b4f86e on Linux (kernel 7.2), Python 3.14.8, CPU only: pass

On main (26ecd9f) test_joaat_agreement fail; at this head and with this head merged onto 26ecd9f they pass.

python -I tests/test_joaat_agreement.py

Branch is 2,143 commits behind main but merges cleanly.

AI-assisted check (Claude Code); counts and pass/fail only, no game data.

@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 5b4f86ede merged onto main 6a4299563: merges clean.

  • python3 -I tests/test_joaat_agreement.py: Ran 2 tests in 0.132s OK (exit 0)
  • python3 -I tests/test_find_hash_lookup.py: Ran 6 tests in 0.124s OK (exit 0)

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

AI-assisted (Claude Code).

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.