mods: hash a mod.json name as hashdict.joaat does (OLD-10050) #718

Open
github-bot wants to merge 1 commit from github-bot/gh-718 into main AGit
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 12:51 UTC · original
abnalstlll-byte:restore/old-10050-mods-joaat-latin1 → main · +63 −5 · 2 files · 1 commits · open

### Summary
Restores old upstream PR 10050 (OLD-10050, replaces draft #316) with original author attribution (@⁠Conrage) preserved.

gta6rt's mods::joaat previously hashed the UTF-8 bytes of a mod.json name and only lower-cased ASCII. Consequently, non-ASCII names in an archetype swap produced a hash that differed from tools/hashdict.py (enforced by tests/test_joaat_agreement.py), causing swaps to silently miss their target.

This change decodes the UTF-8, applies lowercase normalization across Latin-1 code points, and hashes the Latin-1 bytes with '?' fallback, aligning C++ constexpr mods::joaat with hashdict.joaat.

Verification

  • Added 12 compile-time static_asserts in runtime/test/mods_test.cpp covering accented Latin-1, ligatures, and CJK characters.
  • Clean-room check: python -I scripts/check_no_game_data.py clean (0 issues).
  • Zero external runtime dependencies.
  • AI-assisted (Claude Code).
**@⁠abnalstlll-byte** on GitHub · 2026-11-24 12:51 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/718) `abnalstlll-byte:restore/old-10050-mods-joaat-latin1` → `main` · +63 −5 · 2 files · 1 commits · open ### Summary Restores old upstream PR 10050 (OLD-10050, replaces draft #316) with original author attribution (@⁠Conrage) preserved. `gta6rt`'s `mods::joaat` previously hashed the UTF-8 bytes of a `mod.json` name and only lower-cased ASCII. Consequently, non-ASCII names in an archetype swap produced a hash that differed from `tools/hashdict.py` (enforced by `tests/test_joaat_agreement.py`), causing swaps to silently miss their target. This change decodes the UTF-8, applies lowercase normalization across Latin-1 code points, and hashes the Latin-1 bytes with '?' fallback, aligning C++ `constexpr mods::joaat` with `hashdict.joaat`. ### Verification - Added 12 compile-time `static_assert`s in `runtime/test/mods_test.cpp` covering accented Latin-1, ligatures, and CJK characters. - Clean-room check: `python -I scripts/check_no_game_data.py` clean (0 issues). - Zero external runtime dependencies. - AI-assisted (Claude Code).
gta6rt's mods::joaat hashed the UTF-8 bytes of a mod.json name and only
lower-cased ASCII, so "Café" or "ÉLÉGIE" in an archetype swap got a hash
that tools/hashdict.py (the rule the pipeline and test_joaat_agreement are
pinned to) never gives: the swap silently matches no model. It now decodes
the UTF-8, applies Python's str.lower() for every code point whose lower
case is in Latin-1 (checked over all of Unicode), and hashes the Latin-1
bytes with '?' for anything else, as hashdict.joaat does.

mods_test gets 12 static_asserts with hashdict.joaat's values; all 12 fail
on main and pass here (g++ 13 and clang, -std=c++20).

AI-assisted: yes
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:17:51 +00:00
Author
Owner

@⁠lixonik on GitHub · 2026-11-24 13:44 UTC · original · reviewed

Independent Windows/MSVC run from full Git worktrees at d6252ee8 and 51f31609. The PR's stock mods_test passed 48 checks. A separate synthetic driver compared C++ mods::joaat with Python tools/hashdict.py::joaat over all 1,112,064 Unicode scalar values encoded individually as UTF-8 and 10,002 additional strings, including seeded mixed strings.

The PR produced zero mismatches in both groups. The baseline produced 1,111,936 scalar mismatches and 9,792 additional-string mismatches. The differential check covers valid UTF-8. AI-assisted testing, synthetic strings only.

**@⁠lixonik** on GitHub · 2026-11-24 13:44 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/718#pullrequestreview-6040276296) · **reviewed** Independent Windows/MSVC run from full Git worktrees at `d6252ee8` and `51f31609`. The PR's stock `mods_test` passed 48 checks. A separate synthetic driver compared C++ `mods::joaat` with Python `tools/hashdict.py::joaat` over all 1,112,064 Unicode scalar values encoded individually as UTF-8 and 10,002 additional strings, including seeded mixed strings. The PR produced zero mismatches in both groups. The baseline produced 1,111,936 scalar mismatches and 9,792 additional-string mismatches. The differential check covers valid UTF-8. AI-assisted testing, synthetic strings only.
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-25 21:54 UTC · original

Rebased onto latest \main.
Verified \scripts/check_no_game_data.py\ (clean) on
untime/src/mods.h\ and
untime/test/mods_test.cpp, and \git diff --check.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠abnalstlll-byte** on GitHub · 2026-11-25 21:54 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/718#issuecomment-7175702500) Rebased onto latest \main\. Verified \scripts/check_no_game_data.py\ (clean) on \ untime/src/mods.h\ and \ untime/test/mods_test.cpp\, and \git diff --check\. AI-assisted (Claude Code, Claude Opus 5.5).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/718/head:github-bot/gh-718'
git switch 'github-bot/gh-718'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-718'
git switch 'github-bot/gh-718'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-718'
git switch 'github-bot/gh-718'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-718'
git switch 'main'
git merge --squash 'github-bot/gh-718'
git switch 'main'
git merge --ff-only 'github-bot/gh-718'
git switch 'main'
git merge 'github-bot/gh-718'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.