Skip to content

find_hash_lookup: hash a name over the lower-cased Latin-1 bytes, as the other joaat copies do - #6254

Open
evilclanker9000 wants to merge 2 commits into
ItsNotRexed:mainfrom
evilclanker9000:deepseek/2-find-hash-lookup-joaat
Open

evilclanker9000 wants to merge 2 commits into
ItsNotRexed:mainfrom
evilclanker9000:deepseek/2-find-hash-lookup-joaat

Conversation

@evilclanker9000

Copy link
Copy Markdown
Contributor

tools/find_hash_lookup.py's joaat() hashed the lower-cased name's UTF-8 bytes. Every other copy of joaat in tools/ (hashdict, awc_names, audio_config, world_names, mission_tables, tex_headers, ...) hashes the lower-cased Latin-1 bytes, which is the rule tests/test_hashdict.py pins; a non-ASCII character is one byte there and two in UTF-8, so find_hash_lookup.py --hash café looked for a hash no name table holds. tests/test_joaat_agreement.py imports every joaat/joaat32 copy in tools/ and so reports the stale copy: the file was red on main.

The fix is the encoding line plus its docstring. Nothing else in the tool changes: parse_hash() still passes ASCII names (where both encodings agree) and 0x... values through unchanged.

The second commit lists find_hash_lookup in the test's EXPECTED modules, so a rename of that copy can no longer leave the test quietly comparing one copy less, and the docstring names the third copy that was on the UTF-8 form.

Test

python -I tests/test_joaat_agreement.py

Before (upstream/main, 561b65a83):

FAIL: test_every_copy_matches_the_pinned_dictionary (copy='find_hash_lookup', name='café')
...
FAILED (failures=6)

After:

Ran 2 tests in 0.179s
OK

The other tests this touches stay green:

python -I tests/test_find_hash_lookup.py
Ran 4 tests in 0.168s
OK

Synthetic names only, no game data. No GPU needed.

Notes

  • I fixed the tool rather than removing find_hash_lookup from the test: docs/modding.md promises the name is hashed "as the game does", and the module stays standard-library-only with its own copy, which is the pattern the test is built for.
  • Only names that contain a character outside ASCII change hash; every name used so far is ASCII, where Latin-1 and UTF-8 bytes are equal, so the ranked candidates for existing runs are unchanged.
  • Scope: tools/find_hash_lookup.py and its cross-tool test only; the --json/--out guards in that tool are a separate open pull request.

AI-assisted.

… bytes

The tool hashed the lower-cased name's UTF-8 bytes, so a name with a non-ASCII character got a hash no name table in the game or in this pipeline holds. Every other copy of joaat in tools/ (hashdict, awc_names, audio_config, ...) hashes the lower-cased Latin-1 bytes, which is the rule tests/test_hashdict.py pins.
…his pins

The test imported find_hash_lookup's joaat but never listed the module, so a rename of that copy would have left it testing one copy less; the docstring now names the third copy that was on the UTF-8 form and turned this suite red.
@shdann

shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 9ea16de on Windows, CPython 3.14.7, CPU only: pass for the name hash change.

  • py -3.14 -I tests/test_find_hash_lookup.py passed all 4 tests.
  • I compared the lookup hash with hashdict.joaat for 260 synthetic names. The inputs included each Latin-1 character, an empty name, two strings with characters outside Latin-1, and a 4096-character name. The head matched all 260. The merge base (561b65a) differed on 130. For example, the reference and the head return 0xeefbf723 for café. The base returns 0x9096adf2.
  • I also ran the agreement test with discovery limited to the seven modules in its EXPECTED list. It had six failed comparisons on the base and zero on the head. This check covers those seven modules only.

AI-assisted.

@aarushkha

Copy link
Copy Markdown

Tested 9ea16de merged onto main 86a7807dd on Windows 10 Pro 22H2 (19045), Python 3.14.3: pass.

  • python -I tests/test_joaat_agreement.py: Ran 2 tests in 2.141s OK (red on main)

#4753 and #4882 make the same find_hash_lookup.joaat change; all three pass here.

It merges cleanly together with #7092 #6049 #7120 #6513 #7242 #7209 #7214 #6957 #7309 #4771 #7029 #7094 #7129 #6508 #7152 #7174 #7032 onto main; with all of them applied, the only standalone test still red on Windows is test_first_look_paths (claimed by Racurs156). Summary in #7333.

No GPU or game files needed. AI-assisted (Claude Code); I read the diff before running it.

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

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

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

AI-assisted (Claude Code).

@skorex

skorex commented Nov 23, 2026

Copy link
Copy Markdown

Duplicate of #4882

#4882 makes the same change and was opened earlier. Topic: find_hash_lookup: hash the lower-cased Latin-1 bytes, like the other joaat copies.

Suggest closing this PR in favour of #4882, and porting anything this one adds that #4882 lacks there.

@ne1i

ne1i commented Nov 23, 2026

Copy link
Copy Markdown

Tested 9ea16dec 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, #4882 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.

6 participants