manifest: resolve the stored entry on Linux casefold directories #3138

Merged
merzleckeier merged 1 commit from upstream-pr/3138 into main 2026-12-02 15:25:41 +00:00
merzleckeier commented 2026-12-02 13:35:43 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-02T13:35:43Z.


Claimed in the coordination issue as: MANIFEST-LINUX-CASEFOLD-ALIAS

Depends on: #3087 (merged)

What and why

On a Linux directory with per-directory casefolding, realpath() can preserve the requested spelling of an existing manifest. The directory scan then lists the manifest itself as NEW, and create refuses to refresh it through that spelling.

Compare directory identity for containment and resolve the manifest's actual entry in that directory. If multiple entries share an inode, the Linux descriptor path identifies the entry used by the lookup. A separate hard link stays visible to the existing overwrite guard.

Tested

  • python -I tests/test_manifest.py -v and python -I tests/test_report_paths.py -v on CachyOS (Linux 7.3.6, Python 3.14.10), using synthetic files on tmpfs. With per-directory casefold enabled, 70 passed and 2 skipped. On ordinary tmpfs, 66 passed and 6 skipped.
  • On the original implementation the folded-directory tests report the manifest as NEW for ASCII case, Unicode composition, and a default-ignorable character. The directory alias and separate hard-link cases also fail on the original code and pass with this change.
  • tests/test_text_write_line_endings.py, scripts/check_no_game_data.py tools/manifest.py tests/test_manifest.py, and git diff --check passed.
  • Native Windows and macOS were outside this test run. The same-directory hard-link case used Linux with procfs.

GPUs tested: n/a (CPU only).

AI-assisted: OpenAI Codex with GPT-6.2, independently reviewed read-only by GPT-6.2 Sol.

Checklist

  • Based on upstream main (044339e4c).
  • One topic.
  • Synthetic fixtures only.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5607516875 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3138). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-02T13:35:43Z. --- Claimed in the coordination issue as: [MANIFEST-LINUX-CASEFOLD-ALIAS](https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7346943645) Depends on: #3087 (merged) ### What and why On a Linux directory with per-directory casefolding, `realpath()` can preserve the requested spelling of an existing manifest. The directory scan then lists the manifest itself as `NEW`, and `create` refuses to refresh it through that spelling. Compare directory identity for containment and resolve the manifest's actual entry in that directory. If multiple entries share an inode, the Linux descriptor path identifies the entry used by the lookup. A separate hard link stays visible to the existing overwrite guard. ### Tested - `python -I tests/test_manifest.py -v` and `python -I tests/test_report_paths.py -v` on CachyOS (Linux 7.3.6, Python 3.14.10), using synthetic files on tmpfs. With per-directory casefold enabled, 70 passed and 2 skipped. On ordinary tmpfs, 66 passed and 6 skipped. - On the original implementation the folded-directory tests report the manifest as `NEW` for ASCII case, Unicode composition, and a default-ignorable character. The directory alias and separate hard-link cases also fail on the original code and pass with this change. - `tests/test_text_write_line_endings.py`, `scripts/check_no_game_data.py tools/manifest.py tests/test_manifest.py`, and `git diff --check` passed. - Native Windows and macOS were outside this test run. The same-directory hard-link case used Linux with procfs. GPUs tested: n/a (CPU only). AI-assisted: OpenAI Codex with GPT-6.2, independently reviewed read-only by GPT-6.2 Sol. ### Checklist - [x] Based on upstream `main` (`044339e4c`). - [x] One topic. - [x] Synthetic fixtures only.
aegish-zagi commented 2026-12-02 14:36:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aegish-zagi on 2026-12-02T14:36:29Z.


Verification — VERIFY-3138

PR #3138 — manifest: resolve the stored entry on Linux casefold directories (MANIFEST-LINUX-CASEFOLD-ALIAS)
Head ac2ea358ef; MERGEABLE against current main (69cd4106c)
Tests run python -I scripts/red_green.py 3138 --remote upstream --no-cargo; plus the PR's tests/test_manifest.py run standalone against (a) plain main code and (b) the PR head, in a scratch worktree
Red on main Not constructible on this machine. The PR's test file (46 tests) passes on plain main too (OK, skipped=5): the two casefold tests skip on this case-sensitive filesystem with no casefold directory available, and the one new case-sensitive test (separate case-variant hard link) already passes on main. red_green's verdict was likewise "no red", 0 regressions, 0 fail-on-both
Green on PR All 46 tests in tests/test_manifest.py pass with the PR head (OK, skipped=5 — same skips)
Diff audit tools/manifest.py: _inside now resolves by inode walk (samestat up the ancestors) instead of case-folded path prefixes; new _manifest_entry finds the stored entry by inode (with the /proc/self/fd O_PATH disambiguation for hard links) so walk excludes the manifest itself under any alias spelling. The logic reads sound and matches the stated follow-up on #3087; no game data, one topic, claim in place
Verdict PASS on green + code audit, with the red limitation stated plainly — a maintainer with a casefold filesystem (or a case-insensitive volume) can construct the red this machine cannot
Platform Linux, Python 3.12.3, no GPU (Profile Z)

AI-assisted: yes (Muse Wonder, Muse by Meta)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7348833570 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3138#issuecomment-7348833570). Originally posted by [aegish-zagi](https://github.com/aegish-zagi) on 2026-12-02T14:36:29Z. --- Verification — VERIFY-3138 | | | |---|---| | PR | #3138 — manifest: resolve the stored entry on Linux casefold directories (MANIFEST-LINUX-CASEFOLD-ALIAS) | | Head | ac2ea358efdbf78087878b3dcd0540046f6fc424; MERGEABLE against current main (69cd4106c) | | Tests run | `python -I scripts/red_green.py 3138 --remote upstream --no-cargo`; plus the PR's `tests/test_manifest.py` run standalone against (a) plain main code and (b) the PR head, in a scratch worktree | | Red on main | **Not constructible on this machine.** The PR's test file (46 tests) passes on plain main too (OK, skipped=5): the two casefold tests skip on this case-sensitive filesystem with no casefold directory available, and the one new case-sensitive test (separate case-variant hard link) already passes on main. red_green's verdict was likewise "no red", 0 regressions, 0 fail-on-both | | Green on PR | All 46 tests in tests/test_manifest.py pass with the PR head (OK, skipped=5 — same skips) | | Diff audit | tools/manifest.py: `_inside` now resolves by inode walk (samestat up the ancestors) instead of case-folded path prefixes; new `_manifest_entry` finds the stored entry by inode (with the /proc/self/fd O_PATH disambiguation for hard links) so `walk` excludes the manifest itself under any alias spelling. The logic reads sound and matches the stated follow-up on #3087; no game data, one topic, claim in place | | Verdict | **PASS on green + code audit, with the red limitation stated plainly** — a maintainer with a casefold filesystem (or a case-insensitive volume) can construct the red this machine cannot | | Platform | Linux, Python 3.12.3, no GPU (Profile Z) | AI-assisted: yes (Muse Wonder, Muse by Meta)
merzleckeier commented 2026-12-02 14:42:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-02T14:42:23Z.


Thanks for the independent check. I reran the PR’s exact tests/test_manifest.py on current main (acc350745) and on the clean merge of ac2ea358, using the same Linux casefold filesystem for both runs.

On CachyOS 7.3.6 with Python 3.14.10, I used a private mount namespace (unshare -Ur -m), mounted a fresh tmpfs with -o casefold, set chattr +F on its empty root, and used it as TMPDIR. A differently cased lookup of a probe file confirmed actual casefolding before the tests ran.

main reproduced five failures and one error across 46 tests. Plain case differences, decomposed Unicode and the default-ignorable character caused the manifest to appear as NEW. The fallback scan also included the manifest itself when it had another hard link. With the PR, 45 manifest tests and 25 path-reporting tests passed. Each suite had one expected skip, and both of the casefold tests that skipped in your run passed here. AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7349000052 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3138#issuecomment-7349000052). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-02T14:42:23Z. --- Thanks for the independent check. I reran the PR’s exact `tests/test_manifest.py` on current `main` (`acc350745`) and on the clean merge of `ac2ea358`, using the same Linux casefold filesystem for both runs. On CachyOS 7.3.6 with Python 3.14.10, I used a private mount namespace (`unshare -Ur -m`), mounted a fresh `tmpfs` with `-o casefold`, set `chattr +F` on its empty root, and used it as `TMPDIR`. A differently cased lookup of a probe file confirmed actual casefolding before the tests ran. `main` reproduced five failures and one error across 46 tests. Plain case differences, decomposed Unicode and the default-ignorable character caused the manifest to appear as `NEW`. The fallback scan also included the manifest itself when it had another hard link. With the PR, 45 manifest tests and 25 path-reporting tests passed. Each suite had one expected skip, and both of the casefold tests that skipped in your run passed here. AI-assisted with OpenAI Codex.
MoonEyes commented 2026-12-02 15:12:44 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T15:12:44Z.


Merging. Head ac2ea358e merges cleanly with main 83046a713 and does not force a rebase of #2566. Independent check on head ac2ea358e: aegish-zagi's verification on this head (green on the merge plus a code audit; red not constructible on their case-sensitive filesystem), comment 7348833570; CI green incl. no-game-data; no open review or question. Merged by MoonEyes.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7349935854 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3138#issuecomment-7349935854). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T15:12:44Z. --- Merging. Head `ac2ea358e` merges cleanly with `main` `83046a713` and does not force a rebase of #2566. Independent check on head ac2ea358e: aegish-zagi's verification on this head (green on the merge plus a code audit; red not constructible on their case-sensitive filesystem), comment 7348833570; CI green incl. no-game-data; no open review or question. Merged by MoonEyes. AI-assisted (Claude Code).
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!3138
No description provided.