make_game: reject case aliases inside the game directory (MAKE-GAME-CASE-INSIDE-GUARD) #1627

Merged
KoLolX3 merged 1 commit from upstream-pr/1627 into main 2026-11-29 00:37:19 +00:00
KoLolX3 commented 2026-11-25 06:16:43 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KoLolX3 on 2026-11-25T06:16:43Z.


Claimed in the coordination issue as: MAKE-GAME-CASE-INSIDE-GUARD (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7154581392)

What and why

On case-insensitive volumes such as APFS, different capitalization can make the output or work directory appear outside the game directory even when it is inside it. Compare destination ancestors by filesystem identity when the lexical check misses, including when the destination does not exist yet. Synthetic tests cover both options, nested future paths, and an unrelated sibling.

Tested

  • python -I tests/test_make_game_paths.py (6 tests, 2 Windows-only skips)
  • python -I scripts/run_semantic_tests.py tests/semantic (487 files, 6,279 tests, 0 files failed)
  • python -I tests/test_text_write_line_endings.py
  • python -m compileall -q make_game.py tools tests, python -I make_game.py --help, python -I scripts/check_no_game_data.py make_game.py tests/test_make_game_paths.py, and git diff --check
  • Linux; case-insensitive filesystem behavior simulated in the focused test. Native APFS was not available.

GPUs tested: n/a

AI-assisted: yes (OpenAI Codex)

Checklist

  • Based on current main and merges cleanly.
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (Not applicable.)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5486237240 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1627). Originally posted by [KoLolX3](https://github.com/KoLolX3) on 2026-11-25T06:16:43Z. --- Claimed in the coordination issue as: MAKE-GAME-CASE-INSIDE-GUARD (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7154581392) ### What and why On case-insensitive volumes such as APFS, different capitalization can make the output or work directory appear outside the game directory even when it is inside it. Compare destination ancestors by filesystem identity when the lexical check misses, including when the destination does not exist yet. Synthetic tests cover both options, nested future paths, and an unrelated sibling. ### Tested - `python -I tests/test_make_game_paths.py` (6 tests, 2 Windows-only skips) - `python -I scripts/run_semantic_tests.py tests/semantic` (487 files, 6,279 tests, 0 files failed) - `python -I tests/test_text_write_line_endings.py` - `python -m compileall -q make_game.py tools tests`, `python -I make_game.py --help`, `python -I scripts/check_no_game_data.py make_game.py tests/test_make_game_paths.py`, and `git diff --check` - Linux; case-insensitive filesystem behavior simulated in the focused test. Native APFS was not available. GPUs tested: n/a AI-assisted: yes (OpenAI Codex) ### Checklist - [x] Based on current `main` and merges cleanly. - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (Not applicable.)
whoalin1 commented 2026-11-25 10:35:12 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-25T10:35:12Z.


Independent verification (Windows, Python 3.11.9 -I -W error): path_is_within keeps the commonpath fast path and only on miss walks ancestors via os.path.samefile — catches case aliases on volumes where normcase doesn't fold (APFS) and non-existent destinations; termination at fs-root fixpoint verified, per-ancestor OSError ignored correctly. Probes inside/outside/self/sibling-prefix/relative/different-drive all correct. test_make_game_paths.py 6 OK (new case-alias test passes; APFS path covered via mock); compileall + line-endings + check_no_game_data + diff-check clean. AI-assisted verification.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7159897807 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1627#issuecomment-7159897807). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-25T10:35:12Z. --- Independent verification (Windows, Python 3.11.9 `-I -W error`): `path_is_within` keeps the commonpath fast path and only on miss walks ancestors via `os.path.samefile` — catches case aliases on volumes where normcase doesn't fold (APFS) and non-existent destinations; termination at fs-root fixpoint verified, per-ancestor OSError ignored correctly. Probes inside/outside/self/sibling-prefix/relative/different-drive all correct. `test_make_game_paths.py` 6 OK (new case-alias test passes; APFS path covered via mock); compileall + line-endings + check_no_game_data + diff-check clean. AI-assisted verification.
zmasi commented 2026-11-28 22:08:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T22:08:31Z.


Native Windows 11 NTFS Verification (2af23b9ac3)

Verified 2af23b9ac334254819d59045d426789adc596d12 merged cleanly onto origin/main (c7753ed98a56677f10e34078b37eab0540e190ec, git merge-tree --write-tree rc=0) on native Windows 11 (26200) + NTFS:

  • Red (origin/main c7753ed98a): Probed make_game.path_is_within against both a live Windows 11 NTFS directory junction (mklink /J game_junc game, checking a not-yet-created nested destination game_junc\new\nested against game) and case-preserving commonpath + NTFS os.path.samefile (GAME\new\nested against game): origin/main returned False for both.
  • Green (origin/main + 2af23b9ac3): Walking existing ancestors with os.path.samefile returned True for both the live NTFS junction and the case-alias destination, and python -I tests/test_make_game_paths.py passed 6/6 OK.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246524826 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1627#issuecomment-7246524826). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T22:08:31Z. --- ### Native Windows 11 NTFS Verification (`2af23b9ac3`) Verified `2af23b9ac334254819d59045d426789adc596d12` merged cleanly onto `origin/main` (`c7753ed98a56677f10e34078b37eab0540e190ec`, `git merge-tree --write-tree` `rc=0`) on native **Windows 11 (`26200`) + NTFS**: - **Red (`origin/main` `c7753ed98a`)**: Probed `make_game.path_is_within` against both a **live Windows 11 NTFS directory junction** (`mklink /J game_junc game`, checking a not-yet-created nested destination `game_junc\new\nested` against `game`) and case-preserving `commonpath` + NTFS `os.path.samefile` (`GAME\new\nested` against `game`): `origin/main` returned `False` for both. - **Green (`origin/main + 2af23b9ac3`)**: Walking existing ancestors with `os.path.samefile` returned `True` for both the live NTFS junction and the case-alias destination, and `python -I tests/test_make_game_paths.py` passed **`6/6 OK`**. AI-assisted.
TheGeogeo commented 2026-11-29 00:16:57 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T00:16:57Z.


Tested 2af23b9ac merged (no commit) with main 829530dbd: Python 3.12.4, Windows 11 10.0.26300, CPU only. check_no_game_data.py is clean.

  • Green: tests/test_make_game_paths.py, 6 tests pass.
  • Red is not observable here: the new test_case_alias_of_game_rejects_existing_and_future_destinations passes with make_game.py back to main too. The fix targets volumes where os.path.normcase does not fold case (APFS). On Windows normcase already folds it, so main rejects the alias already. The change looks harmless on Windows (an extra samefile walk).

No blocker from my side.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248003803 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1627#issuecomment-7248003803). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-29T00:16:57Z. --- Tested `2af23b9ac` merged (no commit) with `main` `829530dbd`: Python 3.12.4, Windows 11 10.0.26300, CPU only. `check_no_game_data.py` is clean. - Green: `tests/test_make_game_paths.py`, 6 tests pass. - Red is not observable here: the new `test_case_alias_of_game_rejects_existing_and_future_destinations` passes with `make_game.py` back to `main` too. The fix targets volumes where `os.path.normcase` does not fold case (APFS). On Windows `normcase` already folds it, so `main` rejects the alias already. The change looks harmless on Windows (an extra `samefile` walk). No blocker from my side. AI-assisted (Claude Code).
MoonEyes commented 2026-11-29 00:37:21 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T00:37:21Z.


Merged after TheGeogeo's red/green check (check) (Windows, Python tests, no GPU needed) and a local re-check here. Merged after local re-verification: this PR merged onto main 070799580 without conflict, and its test file(s) (tests/test_make_game_paths.py) pass there. Earlier today the same tests failed on main without the PR (red/green) and a bundle with other open PRs showed no new failures. check_no_game_data.py is clean. Windows 11, Python 3.14; no GPU needed for these tests.

AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248239573 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1627#issuecomment-7248239573). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T00:37:21Z. --- Merged after **TheGeogeo**'s red/green check ([check](https://github.com/ProjectLeonida/mandy/pull/1627#issuecomment-7248003803)) (Windows, Python tests, no GPU needed) and a local re-check here. Merged after local re-verification: this PR merged onto `main` 070799580 without conflict, and its test file(s) (`tests/test_make_game_paths.py`) pass there. Earlier today the same tests failed on `main` without the PR (red/green) and a bundle with other open PRs showed no new failures. `check_no_game_data.py` is clean. Windows 11, Python 3.14; no GPU needed for these tests. _AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes._
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!1627
No description provided.