Repair zero-byte DDS files on TTPF export resume #451

Merged
EdenBendheim merged 1 commit from upstream-pr/451 into main 2026-11-29 18:27:26 +00:00
EdenBendheim commented 2026-11-24 05:40:08 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by EdenBendheim on 2026-11-24T05:40:08Z.


Claim: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7123161839

What changed

  • make_game.py (ttpf_manifest): Require every listed DDS output to be a non-empty regular file (st_size > 0) before accepting a pool manifest on resume, preserving the single-pass os.scandir() fast path (with os.stat() fallback only for case-only spelling misses) and keeping File: null unsupported rows valid.
  • tools/rpf9dump/Program.cs (HasNonemptyDds): Treat zero-byte DDS outputs as incomplete on resume (following symlink targets and handling inaccessible/non-regular paths safely) so the existing atomic writer regenerates broken files while leaving valid sibling DDS files untouched.
  • Tests (tests/test_ttpf_export_resume.py, tests/test_make_game_dry_run.py): Synthetic tests verifying byte-for-byte repair, untouched sibling bytes/mtime, preserved skipped rows, symlink handling, os.scandir() fast path, and fallback error rejection (with LF line endings pinned).

Scope is intentionally limited to listed, extractable DDS outputs (unlisted files in the pool folder are never deleted).

Testing & Disclosure

  • AI-assisted: Implemented with Codex (gpt-6.2-sol) and reviewed with Codex (gpt-6.2-astra).
  • Environment: macOS 27.3, Apple M1 Max (CPU-only, synthetic fixtures, zero game data).
  • Verified on ubiquitarianism/leonida main (8f481cf16): dotnet build -c Release (0 warnings, 0 errors), test_ttpf_export_resume.py (6/6), test_make_game_dry_run.py (25/25), check_no_game_data.py, LF check — all passed.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5466779279 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/451). Originally posted by [EdenBendheim](https://github.com/EdenBendheim) on 2026-11-24T05:40:08Z. --- Claim: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7123161839 ### What changed - **`make_game.py` (`ttpf_manifest`)**: Require every listed DDS output to be a non-empty regular file (`st_size > 0`) before accepting a pool manifest on resume, preserving the single-pass `os.scandir()` fast path (with `os.stat()` fallback only for case-only spelling misses) and keeping `File: null` unsupported rows valid. - **`tools/rpf9dump/Program.cs` (`HasNonemptyDds`)**: Treat zero-byte DDS outputs as incomplete on resume (following symlink targets and handling inaccessible/non-regular paths safely) so the existing atomic writer regenerates broken files while leaving valid sibling DDS files untouched. - **Tests (`tests/test_ttpf_export_resume.py`, `tests/test_make_game_dry_run.py`)**: Synthetic tests verifying byte-for-byte repair, untouched sibling bytes/mtime, preserved skipped rows, symlink handling, `os.scandir()` fast path, and fallback error rejection (with LF line endings pinned). Scope is intentionally limited to listed, extractable DDS outputs (unlisted files in the pool folder are never deleted). ### Testing & Disclosure - **AI-assisted:** Implemented with Codex (`gpt-6.2-sol`) and reviewed with Codex (`gpt-6.2-astra`). - **Environment:** macOS 27.3, Apple M1 Max (CPU-only, synthetic fixtures, zero game data). - **Verified on `ubiquitarianism/leonida` `main` (`8f481cf16`):** `dotnet build -c Release` (0 warnings, 0 errors), `test_ttpf_export_resume.py` (6/6), `test_make_game_dry_run.py` (25/25), `check_no_game_data.py`, LF check — all passed.
kirigayakazima commented 2026-11-24 11:07:55 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-24T11:07:55Z.


Verified PR #451 on Windows 11 x64 at commit 031bab29f8905a5c6eba0c306f5e328e23b54e54 (synthetic fixtures only, zero game data):

Environment

  • OS: Windows 11 x64 (NTFS with symlinks enabled)
  • Toolchain: .NET 8.0.401, Python 3.14.7
  • Merge check against current upstream/main (21625bca): clean auto-merge (exit 0, 0 conflicts)

Checks run

  • dotnet build tools/rpf9dump/rpf9dump.csproj -c Release — 0 warnings, 0 errors
  • dotnet run --project tests/Rpf9DumpDiagnostics/Rpf9DumpDiagnostics.csproj -c Release — 6/6 suites passed
  • python -I tests/test_ttpf_export_resume.py -v (with RPF9DUMP_DLL set) — 6/6 OK (test_resume_repairs_empty_dds_and_keeps_siblings and test_resume_checks_dds_symlink_targets both ran and passed on Windows NTFS symlinks without skipping)
  • python -I tests/test_make_game_dry_run.py — 25/25 OK
  • python -I tests/test_ci_registration.py — 15/15 OK
  • python -I tests/test_text_write_line_endings.py — 3/3 OK
  • python -I scripts/check_no_game_data.py — exit 0
  • python -I tests/test_rpf9dump_exit_codes.py (with RPF9DUMP_DLL) — 6/8 passed; the 2 failures (test_failed_texture_write_exits_nonzero_and_withholds_manifest, test_failed_xma_write_exits_nonzero_and_rerun_completes) are pre-existing on unmodified upstream/main (21625bca, fixed separately in #655) and unrelated to this PR.
  • Ad-hoc Windows check of make_game.ttpf_manifest on NTFS symlinks: verified DirEntry.stat() returns target S_ISREG=True and target size (5 bytes), accepts uppercase alias LINK.DDS on NTFS, and returns None for a zero-byte symlink target and a broken symlink.

Looks good on Windows 11.

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7129696856 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/451#issuecomment-7129696856). Originally posted by [kirigayakazima](https://github.com/kirigayakazima) on 2026-11-24T11:07:55Z. --- Verified PR #451 on **Windows 11 x64** at commit `031bab29f8905a5c6eba0c306f5e328e23b54e54` (synthetic fixtures only, zero game data): ### Environment - OS: Windows 11 x64 (NTFS with symlinks enabled) - Toolchain: `.NET 8.0.401`, `Python 3.14.7` - Merge check against current `upstream/main` (`21625bca`): clean auto-merge (`exit 0`, 0 conflicts) ### Checks run - `dotnet build tools/rpf9dump/rpf9dump.csproj -c Release` — **0 warnings, 0 errors** - `dotnet run --project tests/Rpf9DumpDiagnostics/Rpf9DumpDiagnostics.csproj -c Release` — **6/6** suites passed - `python -I tests/test_ttpf_export_resume.py -v` (with `RPF9DUMP_DLL` set) — **6/6 OK** (`test_resume_repairs_empty_dds_and_keeps_siblings` and `test_resume_checks_dds_symlink_targets` both ran and passed on Windows NTFS symlinks without skipping) - `python -I tests/test_make_game_dry_run.py` — **25/25 OK** - `python -I tests/test_ci_registration.py` — **15/15 OK** - `python -I tests/test_text_write_line_endings.py` — **3/3 OK** - `python -I scripts/check_no_game_data.py` — **exit 0** - `python -I tests/test_rpf9dump_exit_codes.py` (with `RPF9DUMP_DLL`) — 6/8 passed; the 2 failures (`test_failed_texture_write_exits_nonzero_and_withholds_manifest`, `test_failed_xma_write_exits_nonzero_and_rerun_completes`) are pre-existing on unmodified `upstream/main` (`21625bca`, fixed separately in #655) and unrelated to this PR. - Ad-hoc Windows check of `make_game.ttpf_manifest` on NTFS symlinks: verified `DirEntry.stat()` returns target `S_ISREG=True` and target size (`5` bytes), accepts uppercase alias `LINK.DDS` on NTFS, and returns `None` for a zero-byte symlink target and a broken symlink. Looks good on Windows 11. AI-assisted: yes
OreoFR commented 2026-11-29 01:40:24 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T01:40:24Z.


Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, .NET SDK 11.0.100, main 53b77df14 : red = main / green = main + this PR

  • Method: red = main's code and main's rpf9dump (git submodule update --init, dotnet build tools/rpf9dump/rpf9dump.csproj -c Release, RPF9DUMP_DLL set to that build) with the test file as merged; green = main + git merge --no-ff of this PR (clean), rpf9dump built from the merged tree.
  • Note: this branch is behind main, so its own copy of the test file is older than main's. Running that stale copy on main gives extra failures unrelated to this PR (main already changed those tests), so red uses the merged test file to isolate the tests this PR adds.

python -I tests/test_make_game_dry_run.py:

  • Red: 25 run, 2 failures:
    • test_texture_pools_resume_only_when_their_listed_dds_files_are_nonempty (case "listed DDS is empty"): no re-export call.
    • test_ttpf_manifest_requires_nonempty_listed_dds_files: main's ttpf_manifest accepts a manifest listing a 0-byte DDS.
  • Green: 25 run, OK, 0 skips.

python -I tests/test_ttpf_export_resume.py:

  • Red: 6 run, 2 failures:
    • test_resume_repairs_empty_dds_and_keeps_siblings: main's rpf9dump skips the 0-byte DDS on resume, so it stays empty.
    • test_resume_checks_dds_symlink_targets: main trusts a symlink to an empty target.
  • Green: 6 run, OK, 0 skips (the symlink test runs on macOS).

MEASURED: the 4 failing tests alone, 3 runs each side: red 3/3 fail, green 3/3 pass.

Verdict: READY.

AI-assisted: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248938998 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/451#issuecomment-7248938998). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T01:40:24Z. --- Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, .NET SDK 11.0.100, main 53b77df14 : red = main / green = main + this PR - Method: red = main's code and main's rpf9dump (`git submodule update --init`, `dotnet build tools/rpf9dump/rpf9dump.csproj -c Release`, `RPF9DUMP_DLL` set to that build) with the test file as merged; green = main + `git merge --no-ff` of this PR (clean), rpf9dump built from the merged tree. - Note: this branch is behind main, so its own copy of the test file is older than main's. Running that stale copy on main gives extra failures unrelated to this PR (main already changed those tests), so red uses the merged test file to isolate the tests this PR adds. `python -I tests/test_make_game_dry_run.py`: - Red: 25 run, 2 failures: - `test_texture_pools_resume_only_when_their_listed_dds_files_are_nonempty` (case "listed DDS is empty"): no re-export call. - `test_ttpf_manifest_requires_nonempty_listed_dds_files`: main's `ttpf_manifest` accepts a manifest listing a 0-byte DDS. - Green: 25 run, OK, 0 skips. `python -I tests/test_ttpf_export_resume.py`: - Red: 6 run, 2 failures: - `test_resume_repairs_empty_dds_and_keeps_siblings`: main's rpf9dump skips the 0-byte DDS on resume, so it stays empty. - `test_resume_checks_dds_symlink_targets`: main trusts a symlink to an empty target. - Green: 6 run, OK, 0 skips (the symlink test runs on macOS). MEASURED: the 4 failing tests alone, 3 runs each side: red 3/3 fail, green 3/3 pass. **Verdict: READY.** AI-assisted: Claude Code (Claude Opus 5.5).
zmasi commented 2026-11-29 01:49:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-29T01:49:42Z.


#451 | head 031bab29f8 (merged cleanly onto origin/main 59e65849b0) | Windows 11 (10.0.26200.9974), .NET SDK 8.0.428, Python 3.12.10 | AI-assisted: yes

Independent Verification (Windows 11 + NTFS + .NET 8.0)

  • Diff & safety audit: Inspected 100% of the diff across make_game.py (ttpf_manifest requiring stat.S_ISREG(output.st_mode) and output.st_size > 0 via Windows DirEntry.stat() with case-insensitive os.stat fallback), tools/rpf9dump/Program.cs (HasNonemptyDds), tests/test_make_game_dry_run.py, and tests/test_ttpf_export_resume.py. python -I scripts/check_no_game_data.py make_game.py tests/test_make_game_dry_run.py tests/test_ttpf_export_resume.py tools/rpf9dump/Program.cs passed (rc=0).
  • Red -> Green on Windows 11 + NTFS:
    • Red (origin/main 59e65849b0): make_game.ttpf_manifest(pool_dir) accepted a pool containing a 0-byte empty.dds alongside a valid sibling DDS instead of returning None.
    • Green (#451 + origin/main):
      • make_game.ttpf_manifest(pool_dir) returned None when empty.dds was 0 bytes.
      • python -I tests/test_make_game_dry_run.py -> 25/25 passed (OK, 2.122s, including test_texture_pools_resume_only_when_their_listed_dds_files_are_nonempty and test_ttpf_manifest_requires_nonempty_listed_dds_files).
      • Compiled and ran the exact HasNonemptyDds(string path) C# helper from tools/rpf9dump/Program.cs under .NET 8.0.428 (dotnet run -c Release) on Windows 11 NTFS -> rejected missing files, 0-byte files, and directories while accepting non-empty regular .dds files (rc=0; tests/test_ttpf_export_resume.py skipped 6/6 cleanly without the third_party/rpf9-explorer submodule).
<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7249039410 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/451#issuecomment-7249039410). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-29T01:49:42Z. --- #451 | head 031bab29f8905a5c6eba0c306f5e328e23b54e54 (merged cleanly onto origin/main 59e65849b0) | Windows 11 (10.0.26200.9974), .NET SDK 8.0.428, Python 3.12.10 | AI-assisted: yes ### Independent Verification (Windows 11 + NTFS + .NET 8.0) - **Diff & safety audit**: Inspected 100% of the diff across `make_game.py` (`ttpf_manifest` requiring `stat.S_ISREG(output.st_mode)` and `output.st_size > 0` via Windows `DirEntry.stat()` with case-insensitive `os.stat` fallback), `tools/rpf9dump/Program.cs` (`HasNonemptyDds`), `tests/test_make_game_dry_run.py`, and `tests/test_ttpf_export_resume.py`. `python -I scripts/check_no_game_data.py make_game.py tests/test_make_game_dry_run.py tests/test_ttpf_export_resume.py tools/rpf9dump/Program.cs` passed (`rc=0`). - **Red -> Green on Windows 11 + NTFS**: - **Red (`origin/main` `59e65849b0`)**: `make_game.ttpf_manifest(pool_dir)` accepted a pool containing a `0`-byte `empty.dds` alongside a valid sibling DDS instead of returning `None`. - **Green (`#451 + origin/main`)**: - `make_game.ttpf_manifest(pool_dir)` returned `None` when `empty.dds` was `0` bytes. - `python -I tests/test_make_game_dry_run.py` -> `25/25` passed (`OK`, `2.122s`, including `test_texture_pools_resume_only_when_their_listed_dds_files_are_nonempty` and `test_ttpf_manifest_requires_nonempty_listed_dds_files`). - Compiled and ran the exact `HasNonemptyDds(string path)` C# helper from `tools/rpf9dump/Program.cs` under `.NET 8.0.428` (`dotnet run -c Release`) on Windows 11 NTFS -> rejected missing files, `0`-byte files, and directories while accepting non-empty regular `.dds` files (`rc=0`; `tests/test_ttpf_export_resume.py` skipped `6/6` cleanly without the `third_party/rpf9-explorer` submodule).
DadaCap commented 2026-11-29 18:27:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-29T18:27:28Z.


Thank you! Merged into main with a merge commit. It was verified ready on its current head (031bab29f) by OreoFR's Mac agent (macOS) and MoonEyes' agent; see the verification comment above. (AI-assisted, posted for DadaCap.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7260497858 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/451#issuecomment-7260497858). Originally posted by [DadaCap](https://github.com/DadaCap) on 2026-11-29T18:27:28Z. --- Thank you! Merged into `main` with a merge commit. It was verified ready on its current head (031bab29f) by OreoFR's Mac agent (macOS) and MoonEyes' agent; see the verification comment above. (AI-assisted, posted for DadaCap.)
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!451
No description provided.