text_tables: read a directory source's subfolders in name order (TEXT-TABLES-WALK-ORDER) #2235

Merged
syfyra merged 1 commit from upstream-pr/2235 into main 2026-12-01 15:17:55 +00:00
syfyra commented 2026-11-26 09:47:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by syfyra on 2026-11-26T09:47:03Z.


Claimed in the coordination issue as: TEXT-TABLES-WALK-ORDER (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7188422465)

What and why

For a source that is a folder of whole resources, tools/text_tables.py blobs() sorted the files of each folder but walked the subfolders in the order os.walk lists them, which is the file system's: by name on NTFS, by hash on ext4. The dialogue table keeps the last text read for a label (docs/text.md, "Labels with two texts": a label can have two texts in one language), so the same folder gave a different text_en and a different --tables/--strings row order on Windows and on Linux. AGENTS.md asks for the same output for the same input on every platform.

The walk now sorts its subfolder list in place, so it descends in name order everywhere; the open #921 does the same in gamedata_xml. Carve folders (index.json) and .rpf sources are read in offset order and are not affected.

Tested

Windows 11, Python 3.14.7, synthetic resources only:

  • python -I tests/test_text_tables.py: the new TestDialogue.test_subfolders_are_read_in_name_order writes one table each into a/ and b/ with different text for one label and reads the folder with the real walk and with one that lists subfolders backwards (standing in for another file system). On main the backwards walk reads b first and the first table's text wins; with the fix both give the same order and text. 34 tests OK.
  • python -I tests/test_progress_dashboard.py OK; python -m compileall; scripts/check_no_game_data.py on both files.

GPUs tested: n/a (CPU-only tool)

AI-assisted: yes (Claude Code, Claude Opus 5.5)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • 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)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5507690561 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2235). Originally posted by [syfyra](https://github.com/syfyra) on 2026-11-26T09:47:03Z. --- Claimed in the coordination issue as: TEXT-TABLES-WALK-ORDER (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7188422465) ### What and why For a source that is a folder of whole resources, `tools/text_tables.py` `blobs()` sorted the files of each folder but walked the subfolders in the order `os.walk` lists them, which is the file system's: by name on NTFS, by hash on ext4. The dialogue table keeps the last text read for a label (docs/text.md, "Labels with two texts": a label can have two texts in one language), so the same folder gave a different `text_en` and a different `--tables`/`--strings` row order on Windows and on Linux. AGENTS.md asks for the same output for the same input on every platform. The walk now sorts its subfolder list in place, so it descends in name order everywhere; the open #921 does the same in `gamedata_xml`. Carve folders (`index.json`) and `.rpf` sources are read in offset order and are not affected. ### Tested Windows 11, Python 3.14.7, synthetic resources only: - `python -I tests/test_text_tables.py`: the new `TestDialogue.test_subfolders_are_read_in_name_order` writes one table each into `a/` and `b/` with different text for one label and reads the folder with the real walk and with one that lists subfolders backwards (standing in for another file system). On `main` the backwards walk reads `b` first and the first table's text wins; with the fix both give the same order and text. 34 tests OK. - `python -I tests/test_progress_dashboard.py` OK; `python -m compileall`; `scripts/check_no_game_data.py` on both files. GPUs tested: n/a (CPU-only tool) AI-assisted: yes (Claude Code, Claude Opus 5.5) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] 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) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
real-rusher commented 2026-11-26 10:06:12 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by real-rusher on 2026-11-26T10:06:12Z.


Verified on main a73a57e1 (Ubuntu 24.04 x86-64, Python 3.13, no GPU). Merges cleanly. With this PR, python -I tests/test_text_tables.py: 34 tests OK (1 skipped). The PR's test file against main's tools/text_tables.py: 1 failure, so the new test fails on main and passes with the fix. compileall clean.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7188910629 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2235#issuecomment-7188910629). Originally posted by [real-rusher](https://github.com/real-rusher) on 2026-11-26T10:06:12Z. --- Verified on main a73a57e1 (Ubuntu 24.04 x86-64, Python 3.13, no GPU). Merges cleanly. With this PR, python -I tests/test_text_tables.py: 34 tests OK (1 skipped). The PR's test file against main's tools/text_tables.py: 1 failure, so the new test fails on main and passes with the fix. compileall clean. AI-assisted: yes (Claude Code)
lixonik commented 2026-11-26 11:11:18 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-26T11:11:18Z.

Review: COMMENTED


Windows 11: 34/34 text-table tests passed, including deterministic folder traversal and duplicate resolution. No findings from these checks.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6073114880 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2235#pullrequestreview-6073114880). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-26T11:11:18Z. **Review:** COMMENTED --- Windows 11: 34/34 text-table tests passed, including deterministic folder traversal and duplicate resolution. No findings from these checks. AI-assisted.
aslan2142 commented 2026-12-01 12:01:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T12:01:51Z.

Review: COMMENTED


Draft review against current main: sorting dirs in os.walk in tools/text_tables.py:265 with tests in tests/test_text_tables.py looks clean and clean-room verified. Still Draft with no CI run yet — please mark Ready for Review so CI runs green.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6130872468 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2235#pullrequestreview-6130872468). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T12:01:51Z. **Review:** COMMENTED --- Draft review against current `main`: sorting `dirs` in `os.walk` in `tools/text_tables.py:265` with tests in `tests/test_text_tables.py` looks clean and clean-room verified. Still Draft with no CI run yet — please mark Ready for Review so CI runs green. *(AI-assisted review.)*
aslan2142 commented 2026-12-01 12:26:38 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T12:26:38Z.


Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review.

(AI-assisted triage.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7311139079 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2235#issuecomment-7311139079). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T12:26:38Z. --- Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review. *(AI-assisted triage.)*
aslan2142 commented 2026-12-01 13:04:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T13:04:03Z.

Review: APPROVED


Now ready for review and MERGEABLE. Clean-room verified: sorting dirs in tools/text_tables.py:265 ensures deterministic directory traversal order, with regression coverage in tests/test_text_tables.py (verified on Windows 11 and Linux).

Approving — ready to merge once CI runs green on current main.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6131795835 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2235#pullrequestreview-6131795835). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T13:04:03Z. **Review:** APPROVED --- Now ready for review and `MERGEABLE`. Clean-room verified: sorting `dirs` in `tools/text_tables.py:265` ensures deterministic directory traversal order, with regression coverage in `tests/test_text_tables.py` (verified on Windows 11 and Linux). Approving — ready to merge once CI runs green on current `main`. *(AI-assisted review.)*
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!2235
No description provided.