awc_names: recognize BOM-prefixed and whitespace-prefixed word dictionaries #2449

Merged
leonida/mandy
kirigayakazima merged 1 commit from codex/awc-names-word-dictionary-detection into main 2026-11-28 15:14:30 +00:00

Pull request successfully merged and closed

kirigayakazima commented 2026-11-27 10:34:18 +00:00

Claimed in the coordination issue as: AWC-NAMES-WORD-DICTIONARY-DETECTION

What and why

An optional UTF-8 BOM could become part of the first plain-text word, cause a JSON file to fail parsing, or hide the opening brace of an extensionless hash dictionary. Skip a UTF-8 BOM in both input modes and detect the first non-whitespace character across read blocks. Explicit JSON inputs retain strict decoding. Tests cover a typed list, a plain word list and an extensionless hash dictionary with more than 8 KiB of leading whitespace.

Tested

Windows, Python 3.14.7. The regression reproduced on the parent and passed with the change.

  • python -I tests/test_awc_names.py
  • Changed-path no-game-data scan and git diff --check passed.

The integrated checkout passed 6,374 semantic tests across 500 files. CI's macOS job failed in the calibrated-texture replacement test, as it did on the unchanged main baseline.

GPUs tested: N/A (CPU-only synthetic tests).

AI-assisted: Yes.

Checklist

  • Based on current main and merges cleanly with the tested base.
  • One topic.
  • No game data, keys or decryption.
  • Translator contract table: N/A.
Claimed in the coordination issue as: [AWC-NAMES-WORD-DICTIONARY-DETECTION](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7215934316) ### What and why An optional UTF-8 BOM could become part of the first plain-text word, cause a JSON file to fail parsing, or hide the opening brace of an extensionless hash dictionary. Skip a UTF-8 BOM in both input modes and detect the first non-whitespace character across read blocks. Explicit JSON inputs retain strict decoding. Tests cover a typed list, a plain word list and an extensionless hash dictionary with more than 8 KiB of leading whitespace. ### Tested Windows, Python 3.14.7. The regression reproduced on the parent and passed with the change. - `python -I tests/test_awc_names.py` - Changed-path no-game-data scan and `git diff --check` passed. The integrated checkout passed 6,374 semantic tests across 500 files. CI's macOS job failed in the calibrated-texture replacement test, as it did on the [unchanged main baseline](https://github.com/ubiquitarianism/leonida/actions/runs/45977772928/job/140433726198). GPUs tested: N/A (CPU-only synthetic tests). AI-assisted: Yes. ### Checklist - [x] Based on current main and merges cleanly with the tested base. - [x] One topic. - [x] No game data, keys or decryption. - Translator contract table: N/A.
MSedgeMC reviewed 2026-11-27 15:04:07 +00:00
MSedgeMC left a comment
No description provided.
Verified on the PR branch: python3 -m unittest tests.test_awc_names -v -> 37 tests OK (1 skip), including the new BOM/whitespace-prefixed dictionary cases. Not approving yet: the branch is 606 commits behind current main and touches the same test file as PRs #2384/#2450, so a rebase is needed before reviewing the combined diff.
zmasi commented 2026-11-28 06:52:21 +00:00

#2449 | head 484d1e7179ee511bbfa98728c2e59a71514c54d1 (merged cleanly with main 09c153948) | python -I tests/test_awc_names.py | red on main: FAILED (failures=2, errors=1) (test_word_dictionary_preambles across words.json, UTF-8 BOM hashdict, and UTF-8 BOM words.txt) | green on PR+main: 37 tests OK (-k test_word_dictionary_preambles: 1 test OK) | Windows 11, Python 3.12.10 | AI-assisted: yes

Audited read_words in tools/awc_names.py (utf-8-sig decoding + chunked leading-whitespace scan for { before seek(0) plain-text fallback so .json word lists and BOM/whitespace-prefixed hash maps or word lists parse cleanly), and verified both PR + main (09c153948) and a combined main + #2450 + #2449 merge: git merge (ort) auto-merged tools/awc_names.py and tests/test_awc_names.py with zero conflicts (38 tests OK in tests/test_awc_names.py). Also passed tests/test_text_write_line_endings.py (3 OK), tests/test_runner_calls_all_tests.py (3 OK), and scripts/check_no_game_data.py.

#2449 | head 484d1e7179ee511bbfa98728c2e59a71514c54d1 (merged cleanly with main 09c153948) | `python -I tests/test_awc_names.py` | red on main: `FAILED (failures=2, errors=1)` (`test_word_dictionary_preambles` across `words.json`, UTF-8 BOM `hashdict`, and UTF-8 BOM `words.txt`) | green on PR+main: `37 tests OK` (`-k test_word_dictionary_preambles`: `1 test OK`) | Windows 11, Python 3.12.10 | AI-assisted: yes Audited `read_words` in `tools/awc_names.py` (`utf-8-sig` decoding + chunked leading-whitespace scan for `{` before `seek(0)` plain-text fallback so `.json` word lists and BOM/whitespace-prefixed hash maps or word lists parse cleanly), and verified both `PR + main` (`09c153948`) and a combined `main + #2450 + #2449` merge: `git merge` (`ort`) auto-merged `tools/awc_names.py` and `tests/test_awc_names.py` with zero conflicts (`38 tests OK` in `tests/test_awc_names.py`). Also passed `tests/test_text_write_line_endings.py` (`3 OK`), `tests/test_runner_calls_all_tests.py` (`3 OK`), and `scripts/check_no_game_data.py`.
MoonEyes commented 2026-11-28 15:14:26 +00:00

Red/green: classified READY by oreo-lot3 (red on main b1619e0a3, green on head merged with main); head 484d1e7179ee unchanged since 2026-11-27, before that run.
Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main d48a957bb in GitHub Actions: no new failure.
AI-assisted (Claude Code, Claude Opus 5.5)

Red/green: classified READY by oreo-lot3 (red on main b1619e0a3, green on head merged with main); head 484d1e7179ee unchanged since 2026-11-27, before that run. Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main d48a957bb in GitHub Actions: no new failure. AI-assisted (Claude Code, Claude Opus 5.5)
Sign in to join this conversation.
No description provided.