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

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

@⁠wetw0rks-c0ding on GitHub · 2026-11-24 21:34 UTC · original
wetw0rks-c0ding:restore/old-10050-mods-joaat-latin1 → main · +63 −5 · 2 files · 1 commits · open

Claimed in the coordination issue as: OLD-10050

What and why

mods::joaat hashed UTF-8 bytes and lower-cased only ASCII, so a mod.json name containing non-ASCII Latin-1 characters got a different hash from tools/hashdict.py and archetype swaps silently missed their target. It now decodes UTF-8, lower-cases across Latin-1 code points and hashes the Latin-1 bytes with a ? fallback, matching hashdict.joaat.

Tested

  • cmake -S runtime -B runtime/build && cmake --build runtime/build --parallel 6 && ctest --test-dir runtime/build -R mods --output-on-failure -> ctest 1/1 passed
  • python -I scripts/check_no_game_data.py runtime/src/mods.h runtime/test/mods_test.cpp -> clean
  • Environment: Linux (CachyOS), CPU-only tests, no GPU required

AI-assisted: Yes. This work was done with OpenCode agents.

**@⁠wetw0rks-c0ding** on GitHub · 2026-11-24 21:34 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1303) `wetw0rks-c0ding:restore/old-10050-mods-joaat-latin1` → `main` · +63 −5 · 2 files · 1 commits · open Claimed in the coordination issue as: OLD-10050 ### What and why `mods::joaat` hashed UTF-8 bytes and lower-cased only ASCII, so a `mod.json` name containing non-ASCII Latin-1 characters got a different hash from `tools/hashdict.py` and archetype swaps silently missed their target. It now decodes UTF-8, lower-cases across Latin-1 code points and hashes the Latin-1 bytes with a `?` fallback, matching `hashdict.joaat`. ### Tested - `cmake -S runtime -B runtime/build && cmake --build runtime/build --parallel 6 && ctest --test-dir runtime/build -R mods --output-on-failure` -> ctest 1/1 passed - `python -I scripts/check_no_game_data.py runtime/src/mods.h runtime/test/mods_test.cpp` -> clean - Environment: Linux (CachyOS), CPU-only tests, no GPU required AI-assisted: Yes. This work was done with OpenCode agents.
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:46:40 +00:00
Author
Owner

@⁠PierreEbele on GitHub · 2026-11-25 14:56 UTC · original

Reviewed ca898f0e6: ran tests/test_joaat_agreement.py (OK) and, via a Python port of the new joaat, checked all 12 static_assert constants against tools/hashdict.py (exact) and the algorithm over every Unicode code point (1,112,064 code points, 0 mismatches; the 60 fully-Latin-1 lowers are exactly the C++ branch set, U+0130 covered). Main's old hash disagrees on all 12 non-ASCII names, consistent with the PR. The C++ itself was not compiled here (no compiler on this arm64 host), so the g++13/clang claim rests on the author. AI-assisted review.

Recommendation: Merge

**@⁠PierreEbele** on GitHub · 2026-11-25 14:56 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1303#issuecomment-7166064451) Reviewed ca898f0e6: ran tests/test_joaat_agreement.py (OK) and, via a Python port of the new joaat, checked all 12 static_assert constants against tools/hashdict.py (exact) and the algorithm over every Unicode code point (1,112,064 code points, 0 mismatches; the 60 fully-Latin-1 lowers are exactly the C++ branch set, U+0130 covered). Main's old hash disagrees on all 12 non-ASCII names, consistent with the PR. The C++ itself was not compiled here (no compiler on this arm64 host), so the g++13/clang claim rests on the author. AI-assisted review. **Recommendation:** Merge
Author
Owner

@⁠wavehs on GitHub · 2026-11-26 18:48 UTC · original

This is the same change as #718 (abnalstlll-byte, opened 2026-11-24 12:51, ~8h43m earlier): the two diffs are byte-identical (only blob hashes differ), same runtime/src/mods.h + runtime/test/mods_test.cpp, and both claim OLD-10050. #718 also explicitly replaces draft #316.

I verified #718 on main f107ae044 (macOS, portable runtime subset): clean apply, mods_test builds, ctest -R '^mods$' passes. As a negative control, applying only its mods_test.cpp half against the unmodified mods.h fails to compile with 12 static_assert errors (Café, ÉLÉGIE, Crème Brûlée, the non-Latin-1 cases), so the test really pins the digest.

Nothing wrong with the content here; it is a duplicate reland. I would keep #718 (earlier, replaces the draft explicitly) and close this one; #316 can close once #718 lands.

AI-assisted (verification only).

**@⁠wavehs** on GitHub · 2026-11-26 18:48 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1303#issuecomment-7200865409) This is the same change as **#718** (abnalstlll-byte, opened 2026-11-24 12:51, ~8h43m earlier): the two diffs are byte-identical (only blob hashes differ), same `runtime/src/mods.h` + `runtime/test/mods_test.cpp`, and both claim OLD-10050. #718 also explicitly replaces draft #316. I verified #718 on `main` `f107ae044` (macOS, portable runtime subset): clean apply, `mods_test` builds, `ctest -R '^mods$'` passes. As a negative control, applying only its `mods_test.cpp` half against the unmodified `mods.h` fails to compile with 12 `static_assert` errors (Café, ÉLÉGIE, Crème Brûlée, the non-Latin-1 cases), so the test really pins the digest. Nothing wrong with the content here; it is a duplicate reland. I would keep #718 (earlier, replaces the draft explicitly) and close this one; #316 can close once #718 lands. AI-assisted (verification only).
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/1303/head:github-bot/gh-1303'
git switch 'github-bot/gh-1303'

Merge

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