mods: hash a mod.json name as hashdict.joaat does (lower-cased Latin-1, not UTF-8 bytes) #316

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

@⁠Andretuta on GitHub · 2026-11-24 03:07 UTC · original
ubiquitarianism:old-pr/10050 → main · +63 −5 · 2 files · 1 commits · draft

Carried over from old PR 10050 by Conrage in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/10050, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
Conrage: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Claimed in the coordination issue as: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7117095716

What and why

runtime/src/mods.h's joaat() hashed the UTF-8 bytes of a mod.json name and lower-cased only ASCII. Every other copy of joaat is pinned to tools/hashdict.py (s.lower().encode("latin-1", "replace"), enforced by tests/test_joaat_agreement.py), so a non-ASCII name in an archetype swap ("from": "Café") got a hash nothing else in the pipeline produces and the swap silently matched no model. #10002 left this open ("leonida_mods hashes UTF-8 bytes like runtime/src/mods.h, so both sides change together"); #9902 changes tools/leonida_mods.py, this changes the runtime so gta6rt and the mod manager agree again.

joaat() now decodes the UTF-8, applies Python's str.lower() for every code point whose lower case lands in Latin-1 (A-Z, U+00C0-U+00DE but U+00D7, plus U+0178, U+1E9E, U+212A, U+212B and U+0130 -> "i" + an unencodable dot; the list was checked against str.lower() over all of Unicode), and hashes the Latin-1 byte, ? for anything else, as hashdict.joaat does. Malformed UTF-8 hashes as ? per bad byte. ASCII names hash exactly as before (the existing model-id asserts are unchanged). Still constexpr.

Tested

  • mods_test gets 12 static_asserts whose values come from hashdict.joaat (accented Latin-1, ×, Ÿ, ẞ, Kelvin/Angstrom signs, İ, CJK). On main 12 of them fail to compile; with this change mods_test: 48 checks, 0 failures with g++ 13 and clang (-std=c++20 -Wall -Wextra -Wconversion -Wsign-conversion, no warnings from mods.h), Linux x86-64. No GPU involved. Not built with MSVC here.
  • The portable Linux runtime ctest set (22 tests) still passes.

AI-assisted: yes

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, no translator change)
**@⁠Andretuta** on GitHub · 2026-11-24 03:07 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/316) `ubiquitarianism:old-pr/10050` → `main` · +63 −5 · 2 files · 1 commits · draft > Carried over from **old PR 10050** by `Conrage` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/10050`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `Conrage`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): <!-- claude-projects-attribution: {"github_login":"Conrage"} --> Claimed in the coordination issue as: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7117095716 ### What and why `runtime/src/mods.h`'s `joaat()` hashed the **UTF-8 bytes** of a mod.json name and lower-cased only ASCII. Every other copy of joaat is pinned to `tools/hashdict.py` (`s.lower().encode("latin-1", "replace")`, enforced by `tests/test_joaat_agreement.py`), so a non-ASCII name in an archetype swap (`"from": "Café"`) got a hash nothing else in the pipeline produces and the swap silently matched no model. `#10002` left this open ("leonida_mods hashes UTF-8 bytes like runtime/src/mods.h, so both sides change together"); `#9902` changes `tools/leonida_mods.py`, this changes the runtime so gta6rt and the mod manager agree again. `joaat()` now decodes the UTF-8, applies Python's `str.lower()` for every code point whose lower case lands in Latin-1 (A-Z, U+00C0-U+00DE but U+00D7, plus U+0178, U+1E9E, U+212A, U+212B and U+0130 -> "i" + an unencodable dot; the list was checked against `str.lower()` over all of Unicode), and hashes the Latin-1 byte, `?` for anything else, as `hashdict.joaat` does. Malformed UTF-8 hashes as `?` per bad byte. ASCII names hash exactly as before (the existing model-id asserts are unchanged). Still `constexpr`. ### Tested - `mods_test` gets 12 `static_assert`s whose values come from `hashdict.joaat` (accented Latin-1, ×, Ÿ, ẞ, Kelvin/Angstrom signs, İ, CJK). On main 12 of them fail to compile; with this change `mods_test: 48 checks, 0 failures` with g++ 13 and clang (`-std=c++20 -Wall -Wextra -Wconversion -Wsign-conversion`, no warnings from mods.h), Linux x86-64. No GPU involved. Not built with MSVC here. - The portable Linux runtime ctest set (22 tests) still passes. AI-assisted: yes ### Checklist - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a, no translator change)
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 08:53:07 +00:00
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/316/head:github-bot/gh-316'
git switch 'github-bot/gh-316'

Merge

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