awc_shorts: refuse a catalog that would overwrite an input bank (carry of #934) #3078

Merged
MoonEyes merged 3 commits from upstream-pr/3078 into main 2026-12-02 10:40:12 +00:00
MoonEyes commented 2026-12-02 09:50:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T09:50:13Z.


Claimed in the coordination issue as: DRAFT-196 (the claim of the original author, fin-github, in #14)

What and why

Carry of #934 (fin-github, itself a cherry-pick of draft #196 by neoisg8), unchanged since 24 November after two rebase requests. This branch is main plus the head of #934 (the author's commit is kept), the test conflict resolved by keeping main's tests and the pull request's tests, and one commit of mine.

tools/awc_shorts.py writes its catalog to <out>/shorts.csv. Without a guard, an input bank named shorts.csv in the output folder was overwritten, and a bank that exports to <out>/shorts.csv collided with the catalog after clips were already written. #934 refuses both with exit code 2. My commit follows PierreEbele's review note: the second check ran after os.makedirs, so a refused run left an empty output folder; both checks now run before it, and a test checks that the folder is not created.

Tested

Windows 11, no GPU, no game files, on main a917c54d6 plus this branch:

  • python -I tests/test_awc_shorts.py: 21 tests OK (1 skipped).
  • Red: with main's tools/awc_shorts.py, the three new tests fail.
  • python -I scripts/check_no_game_data.py on both changed files: clean.
  • Not run: the full suite, CI.

GPUs tested: n/a (unit tests only)

AI-assisted: yes. Models: Claude Opus 5.5 in Claude Code (carry, conflict resolution, fix, tests); separate read-only reviewer agent: Claude Opus 5.5.

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 (CONTRIBUTING.md).
  • A new translator rule is in the contract table of docs/design.md. (n/a: tool guard and tests only)

Supersedes #934 once merged; the original stays open until a maintainer decides.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5603967811 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3078). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T09:50:13Z. --- Claimed in the coordination issue as: DRAFT-196 (the claim of the original author, fin-github, in #14) ### What and why Carry of #934 (fin-github, itself a cherry-pick of draft #196 by neoisg8), unchanged since 24 November after two rebase requests. This branch is `main` plus the head of #934 (the author's commit is kept), the test conflict resolved by keeping `main`'s tests and the pull request's tests, and one commit of mine. `tools/awc_shorts.py` writes its catalog to `<out>/shorts.csv`. Without a guard, an input bank named `shorts.csv` in the output folder was overwritten, and a bank that exports to `<out>/shorts.csv` collided with the catalog after clips were already written. #934 refuses both with exit code 2. My commit follows PierreEbele's review note: the second check ran after `os.makedirs`, so a refused run left an empty output folder; both checks now run before it, and a test checks that the folder is not created. ### Tested Windows 11, no GPU, no game files, on `main` `a917c54d6` plus this branch: - `python -I tests/test_awc_shorts.py`: 21 tests OK (1 skipped). - Red: with `main`'s `tools/awc_shorts.py`, the three new tests fail. - `python -I scripts/check_no_game_data.py` on both changed files: clean. - Not run: the full suite, CI. GPUs tested: n/a (unit tests only) AI-assisted: yes. Models: Claude Opus 5.5 in Claude Code (carry, conflict resolution, fix, tests); separate read-only reviewer agent: Claude Opus 5.5. ### 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 (CONTRIBUTING.md). - [ ] A new translator rule is in the contract table of `docs/design.md`. (n/a: tool guard and tests only) Supersedes #934 once merged; the original stays open until a maintainer decides. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
enlight3d commented 2026-12-02 10:17:33 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-12-02T10:17:33Z.


RUN (independent run on Windows, #3078 head 2948cf3e4, merged locally into main a917c54d6 with git merge --no-ff, no conflicts. CI on the head: change-scope, check, linux-python-and-viewer, no-game-data and semantic-tests all pass.)

  • History: #934's head dc4c32ac9, by its original author, is an ancestor of the head through the merge 92c713e76. The carrier adds one commit on top.
  • python -I tests/test_awc_shorts.py -v: main 18 tests OK (1 skipped); merge 21 tests OK (1 skipped, "input volume does not support case-distinct files").
  • python -m pytest tests/test_awc_shorts.py tests/test_csv_line_endings.py tests/test_pool_workers.py -q (the files that name awc_shorts): main 31 passed / 1 skipped; merge 34 passed / 1 skipped.
  • Red: main's tools/awc_shorts.py with this pull request's test file gives 21 tests and 3 failures. The input-bank case exits 0, and the two export-folder cases exit 1, where 2 is wanted.
  • Native probe on NTFS, through the CLI, with a few bytes of junk as the bank:
    • Bank <out>/shorts.csv: main exits 0 and the input file now holds the catalog header (bank,stream,duration_s,...), so the input is lost. The merge exits 2 with "catalog would overwrite the input bank" and leaves the input unchanged.
    • Bank <out>/Shorts.CSV, a case variant on a case-insensitive volume: main overwrites it the same way. The merge refuses it, because same_report_path compares the paths.
    • Bank src/shorts.csv.awc with out/ as the output: main creates out/shorts.csv as the bank's export folder, then cannot write the catalog over it (Permission denied, exit 1), and leaves out/ behind. The merge exits 2 before out/ exists.
  • Mutations of the merge's tools/awc_shorts.py, each run with the whole test file and restored afterwards (git status clean):
    • Input-bank check removed: killed.
    • Export-folder check removed: killed (2 tests).
    • Both checks moved after os.makedirs, as in #934 before the follow-up commit: killed by test_catalog_collision_refusal_creates_no_output_folder.
    • Exit code 1 in place of 2: killed.
    • same_report_path replaced by == on the joined paths: survives the test file, because the tests spell both paths the same way. The case-variant probe above catches it: the mutated tool overwrites Shorts.CSV and exits 0. A case-variant test, skipped on a case-sensitive volume like the existing one, would pin it.

Not covered here: Linux and macOS, and a real AWC bank. The input was synthetic junk, and the guard runs before any bank is read.

Verdict: PASS. The guard stops a real loss of input on Windows that main has (exit 0 with the input overwritten), the three new tests are red on main and green on the merge, and the refusal leaves nothing behind. Only the case-insensitive comparison is not pinned by a test.

Machine: Windows 11 Pro 26300 (NTFS), i9-13900K, 64 GB, CPython 3.13.12 (CI uses 3.12); unit tests and synthetic inputs only, no GPU or game files used.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7342252079 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3078#issuecomment-7342252079). Originally posted by [enlight3d](https://github.com/enlight3d) on 2026-12-02T10:17:33Z. --- RUN (independent run on Windows, #3078 head 2948cf3e4, merged locally into `main` a917c54d6 with `git merge --no-ff`, no conflicts. CI on the head: change-scope, check, linux-python-and-viewer, no-game-data and semantic-tests all pass.) - History: #934's head dc4c32ac9, by its original author, is an ancestor of the head through the merge 92c713e76. The carrier adds one commit on top. - `python -I tests/test_awc_shorts.py -v`: main 18 tests OK (1 skipped); merge 21 tests OK (1 skipped, "input volume does not support case-distinct files"). - `python -m pytest tests/test_awc_shorts.py tests/test_csv_line_endings.py tests/test_pool_workers.py -q` (the files that name `awc_shorts`): main 31 passed / 1 skipped; merge 34 passed / 1 skipped. - Red: `main`'s `tools/awc_shorts.py` with this pull request's test file gives 21 tests and 3 failures. The input-bank case exits 0, and the two export-folder cases exit 1, where 2 is wanted. - Native probe on NTFS, through the CLI, with a few bytes of junk as the bank: - Bank `<out>/shorts.csv`: `main` exits 0 and the input file now holds the catalog header (`bank,stream,duration_s,...`), so the input is lost. The merge exits 2 with "catalog would overwrite the input bank" and leaves the input unchanged. - Bank `<out>/Shorts.CSV`, a case variant on a case-insensitive volume: `main` overwrites it the same way. The merge refuses it, because `same_report_path` compares the paths. - Bank `src/shorts.csv.awc` with `out/` as the output: `main` creates `out/shorts.csv` as the bank's export folder, then cannot write the catalog over it (Permission denied, exit 1), and leaves `out/` behind. The merge exits 2 before `out/` exists. - Mutations of the merge's `tools/awc_shorts.py`, each run with the whole test file and restored afterwards (`git status` clean): - Input-bank check removed: killed. - Export-folder check removed: killed (2 tests). - Both checks moved after `os.makedirs`, as in #934 before the follow-up commit: killed by `test_catalog_collision_refusal_creates_no_output_folder`. - Exit code 1 in place of 2: killed. - `same_report_path` replaced by `==` on the joined paths: survives the test file, because the tests spell both paths the same way. The case-variant probe above catches it: the mutated tool overwrites `Shorts.CSV` and exits 0. A case-variant test, skipped on a case-sensitive volume like the existing one, would pin it. Not covered here: Linux and macOS, and a real AWC bank. The input was synthetic junk, and the guard runs before any bank is read. Verdict: PASS. The guard stops a real loss of input on Windows that `main` has (exit 0 with the input overwritten), the three new tests are red on `main` and green on the merge, and the refusal leaves nothing behind. Only the case-insensitive comparison is not pinned by a test. Machine: Windows 11 Pro 26300 (NTFS), i9-13900K, 64 GB, CPython 3.13.12 (CI uses 3.12); unit tests and synthetic inputs only, no GPU or game files used.
MoonEyes commented 2026-12-02 10:26:46 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T10:26:46Z.


Merging. Head 2948cf3e4 merges cleanly with main 80910637f and does not force a rebase of #2566. Independent check on head 2948cf3e4: enlight3d's red/green on main + PR (3 failures on main, 21 green, comment 7342252079); neoisg8's commit from #934 is an ancestor of the head; CI 5/5 green incl. no-game-data; no open review or question; item DRAFT-196 claimed in #14. Merged by MoonEyes.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7342480414 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3078#issuecomment-7342480414). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T10:26:46Z. --- Merging. Head `2948cf3e4` merges cleanly with `main` `80910637f` and does not force a rebase of #2566. Independent check on head 2948cf3e4: enlight3d's red/green on main + PR (3 failures on main, 21 green, comment 7342252079); neoisg8's commit from #934 is an ancestor of the head; CI 5/5 green incl. no-game-data; no open review or question; item DRAFT-196 claimed in #14. Merged by MoonEyes. AI-assisted (Claude Code).
imShangLi commented 2026-12-02 10:36:16 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by imShangLi on 2026-12-02T10:36:16Z.


VERIFY-3078 — Linux, Fedora 45, Python 3.15.2, no GPU device, no game files

Verdict: PASS. The change refuses, with exit code 2, the two ways awc_shorts.py's catalog <out>/shorts.csv can collide with its own work: an input bank that is the catalog path (single-file src named shorts.csv in the output folder), and a bank whose export directory is the catalog path (a shorts.csv.awc bank, whose stem is shorts.csv). I reproduced both overwrites on the merge base (the first one silently clobbered the input bank and returned 0; the second created the export directory and then failed the catalog write with 1, leaving the output folder behind) and confirmed the fix refuses both with 2, leaves the bank bytes untouched, and — because the author's follow-up commit moved both checks before os.makedirs — leaves no output folder behind on refusal. The three new tests fail on the base and pass with the pull request; nothing regressed.

head 2948cf3e49c1e47ff92f5bf3f1ebba2577e7ffba ("awc_shorts: refuse a catalog collision before creating the output folder"), merge base origin/main at the time = a917c54d6aff8c9ef5dda2d8ebf938cb5c693902 (the pull request sits on it; main has since moved to 80910637). Two commits beyond the base: 92c713e7 (carry merge of refs/pr-all/934, keeping the original author's commit dc4c32ac by neoisg8) and 2948cf3e (the review follow-up). Two files, +51/−1: tools/awc_shorts.py, tests/test_awc_shorts.py.

1. What it changes

tools/awc_shorts.py writes its catalog to <out>/shorts.csv. main() gained a guard loop (lines 163–172) that runs after the source is listed and before os.makedirs(a.out) (line 174). For every bank (path, bank) it asks two questions with report_paths.same_report_path:

  • same_report_path(catalog, path) — is the catalog the same file as an input bank? (line 166–168, catalog would overwrite the input bank.)
  • same_report_path(catalog, os.path.join(a.out, bank)) — is the catalog the same path as a bank's export directory? (line 169–172, catalog would collide with bank export directory.)

Either answer is a refusal: a one-line message on stderr and return 2. This is the body of #934 (the original author's commit is kept as dc4c32ac), plus the follow-up commit 2948cf3e: #934 had put the second check after os.makedirs (in the destination-dedup loop), so a refused run had already created the output folder; the follow-up moved both checks before it (and deleted the check from the dedup loop, git show 2948cf3e).

The first check fires only for a single-file src named shorts.csv whose directory is the output folder (a directory scan lists only *.awc, so a bank file can never be named shorts.csv there). The second fires for any bank whose stem is shorts.csv — i.e. a shorts.csv.awc file (or a single-file src named shorts.csv.awc), whose export directory <out>/shorts.csv/ is the catalog's own path.

2. The two claims, checked

Claim: "an input bank named shorts.csv in the output folder was overwritten." Confirmed, and I reproduced it. With the merge-base tool (rg-3078/tree, the base commit):

$ awc_shorts.py shorts.csv . --jobs 1
  skip shorts: not a little-endian AWC
1 banks: 0 short streamed-music channels -> .      # exit 0
$ cat shorts.csv                                    # was "original input bank data"
bank,stream,duration_s,channels,packets,file

The bank was silently replaced by the catalog header (exit 0, no error). With the pull-request tool the same invocation prints awc_shorts: error: catalog would overwrite the input bank shorts.csv, exits 2, and the bank still holds original input bank data. This is the tool's own path-checking (same_report_path on the resolved paths), not a test artifact.

Claim: "a bank that exports to <out>/shorts.csv collided with the catalog after clips were already written." Confirmed in behaviour. With the pull-request tool, awc_shorts.py shorts.csv.awc . exits 2 with catalog would collide with bank export directory ./shorts.csv; awc_shorts.py shorts.csv.awc out (where out does not exist) exits 2 with ... out/shorts.csv and, per the third test, out/ is not created. On the merge base the same collision is not refused before the work happens: the red side shows the run returned 1 (not 2) — the export directory was created first, then the catalog write failed because shorts.csv was already a directory (test_catalog_collision_with_bank_export_directory_rejected fails with AssertionError: 1 != 2).

Claim: "both checks now run before os.makedirs, so a refused run leaves nothing behind." Confirmed from the code (lines 163–172 before line 174) and by test_catalog_collision_refusal_creates_no_output_folder, which asserts rc == 2 and not os.path.exists(out). On the base that test fails with AssertionError: 1 != 2 — the old code created out/ first.

Claim: refusal is exit code 2 with a one-line message. Confirmed: both branches return 2; the tests assert rc == 2, the message via assertIn, and that stderr has exactly one line (len(err.getvalue().splitlines()) == 1). A usage error rather than a failed run, consistent with the tool's other refusals (--jobs < 1, a bad range, a missing source) and with test_missing_input_exit_codes's BUILD-1046 convention.

3. What the tests do here

python3 -I tests/test_awc_shorts.py on the head: 21 tests, OK (no skip on Linux). The author's "21 tests OK (1 skipped)" is the same run on Windows, where test_bank_extensions_cannot_collapse_two_banks_into_one_export skips (self.skipTest("input volume does not support case-distinct files"), line 143) because NTFS does not normally allow clip.awc and clip.AWC side by side; ext4 does, so it runs here.

python3 -I scripts/red_green.py 3078 --no-cargo (work-dir rg-3078): verdict "red then green" — the three new tests go red→green, 0 regressions, 0 fail on both, 18 pass on both. The red side (merge base + the pull request's test file) is exactly the base tool with the three new tests, and I ran it by hand to see the failures:

test failure on the base
test_catalog_collision_with_input_bank_rejected AssertionError: 0 != 2 — the base tool ran the bank and returned 0 (the overwrite)
test_catalog_collision_with_bank_export_directory_rejected AssertionError: 1 != 2 — the base tool created the export dir, then failed the catalog write
test_catalog_collision_refusal_creates_no_output_folder AssertionError: 1 != 2 — the base tool created out/ before failing

The three tests are not vacuous: each fails on the base with exactly the behaviour the fix changes, and each asserts the consequence (bank bytes unchanged; no output folder) not just the exit code.

Also run: python3 -I scripts/check_no_game_data.py tools/awc_shorts.py tests/test_awc_shorts.py — exit 0 (clean); python3 -m compileall — clean; python3 -I -m unittest discover -s tests -p "test_docs_*.py" — 57 OK.

4. Anything wrong

Nothing blocking. Three observations, none a defect of the change:

  • The first check's reach is narrow by construction. A directory scan never yields a bank named shorts.csv, so catalog would overwrite the input bank only fires for a single-file src named shorts.csv. That is exactly the case the PR describes, and the guard is still the right place for it; it is not a gap, just worth knowing that the directory-scan path only ever hits the second check.
  • target is now computed twice per bank (the guard loop and the destination-dedup loop both do os.path.join(a.out, bank)). That is a redundant join and one extra same_report_path (a realpath + samefile) per bank in the guard — negligible for an offline asset export, not a hot path.
  • same_report_path vs path_key: the guard uses same_report_path, the pre-existing dedup uses path_key. Both come from report_paths; the guard's is the stricter of the two (it also folds hard links and case aliases). Consistent with the report-path rules in CONTRIBUTING.md.

5. What I did not check

  • Real AWC banks and a real game folder: the tool's export path is exercised here only through the synthetic banks the tests build. I did not run awc_shorts.py over a game's AWC directory (no game files, and the point of the PR is the catalog guard, not the exporter).
  • The full repository test suite and CI: I ran the touched test file, the docs/hygiene suite (57), the line-endings test, compileall and the clean-room check. I did not run the whole tests/ suite (semantic translator, viewer .cjs, rpf9dump, runtime/ CTest, the D3D12 Rust crates) — the change touches none of those, and red_green ran the only Python test file the pull request changes.
  • Windows behaviour: the author's "1 skipped" is a Windows-specific skip; I could not confirm it on this Linux box (ext4 allows case-distinct files, so the test runs). The same_report_path case-folding path for a case-insensitive volume is not exercised here.
  • The original #934 review thread (PierreEbele's note): I read the code and confirmed the follow-up commit matches the described intent (checks moved before os.makedirs), but I did not read #934's own review comments — that is a different pull request and I was asked to verify only #3078.
  • The full suite, CI queue: not run, as the author also states ("Not run: the full suite, CI").
<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7342713692 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3078#issuecomment-7342713692). Originally posted by [imShangLi](https://github.com/imShangLi) on 2026-12-02T10:36:16Z. --- ## VERIFY-3078 — Linux, Fedora 45, Python 3.15.2, no GPU device, no game files **Verdict: PASS.** The change refuses, with exit code 2, the two ways `awc_shorts.py`'s catalog `<out>/shorts.csv` can collide with its own work: an input bank that *is* the catalog path (single-file `src` named `shorts.csv` in the output folder), and a bank whose export directory is the catalog path (a `shorts.csv.awc` bank, whose stem is `shorts.csv`). I reproduced both overwrites on the merge base (the first one silently clobbered the input bank and returned 0; the second created the export directory and then failed the catalog write with 1, leaving the output folder behind) and confirmed the fix refuses both with 2, leaves the bank bytes untouched, and — because the author's follow-up commit moved both checks before `os.makedirs` — leaves no output folder behind on refusal. The three new tests fail on the base and pass with the pull request; nothing regressed. head `2948cf3e49c1e47ff92f5bf3f1ebba2577e7ffba` ("awc_shorts: refuse a catalog collision before creating the output folder"), merge base `origin/main` at the time = `a917c54d6aff8c9ef5dda2d8ebf938cb5c693902` (the pull request sits on it; `main` has since moved to `80910637`). Two commits beyond the base: `92c713e7` (carry merge of `refs/pr-all/934`, keeping the original author's commit `dc4c32ac` by neoisg8) and `2948cf3e` (the review follow-up). Two files, +51/−1: `tools/awc_shorts.py`, `tests/test_awc_shorts.py`. ### 1. What it changes `tools/awc_shorts.py` writes its catalog to `<out>/shorts.csv`. `main()` gained a guard loop (lines 163–172) that runs after the source is listed and **before** `os.makedirs(a.out)` (line 174). For every bank `(path, bank)` it asks two questions with `report_paths.same_report_path`: - `same_report_path(catalog, path)` — is the catalog the same file as an input bank? (line 166–168, `catalog would overwrite the input bank`.) - `same_report_path(catalog, os.path.join(a.out, bank))` — is the catalog the same path as a bank's export directory? (line 169–172, `catalog would collide with bank export directory`.) Either answer is a refusal: a one-line message on `stderr` and `return 2`. This is the body of #934 (the original author's commit is kept as `dc4c32ac`), plus the follow-up commit `2948cf3e`: #934 had put the **second** check after `os.makedirs` (in the destination-dedup loop), so a refused run had already created the output folder; the follow-up moved both checks before it (and deleted the check from the dedup loop, `git show 2948cf3e`). The first check fires only for a single-file `src` named `shorts.csv` whose directory is the output folder (a directory scan lists only `*.awc`, so a bank file can never be named `shorts.csv` there). The second fires for any bank whose stem is `shorts.csv` — i.e. a `shorts.csv.awc` file (or a single-file `src` named `shorts.csv.awc`), whose export directory `<out>/shorts.csv/` is the catalog's own path. ### 2. The two claims, checked **Claim: "an input bank named `shorts.csv` in the output folder was overwritten."** Confirmed, and I reproduced it. With the merge-base tool (`rg-3078/tree`, the base commit): ``` $ awc_shorts.py shorts.csv . --jobs 1 skip shorts: not a little-endian AWC 1 banks: 0 short streamed-music channels -> . # exit 0 $ cat shorts.csv # was "original input bank data" bank,stream,duration_s,channels,packets,file ``` The bank was silently replaced by the catalog header (exit 0, no error). With the pull-request tool the same invocation prints `awc_shorts: error: catalog would overwrite the input bank shorts.csv`, exits 2, and the bank still holds `original input bank data`. This is the tool's own path-checking (`same_report_path` on the resolved paths), not a test artifact. **Claim: "a bank that exports to `<out>/shorts.csv` collided with the catalog after clips were already written."** Confirmed in behaviour. With the pull-request tool, `awc_shorts.py shorts.csv.awc .` exits 2 with `catalog would collide with bank export directory ./shorts.csv`; `awc_shorts.py shorts.csv.awc out` (where `out` does not exist) exits 2 with `... out/shorts.csv` and, per the third test, `out/` is not created. On the merge base the same collision is not refused before the work happens: the red side shows the run returned **1** (not 2) — the export directory was created first, then the catalog write failed because `shorts.csv` was already a directory (`test_catalog_collision_with_bank_export_directory_rejected` fails with `AssertionError: 1 != 2`). **Claim: "both checks now run before `os.makedirs`, so a refused run leaves nothing behind."** Confirmed from the code (lines 163–172 before line 174) and by `test_catalog_collision_refusal_creates_no_output_folder`, which asserts `rc == 2` and `not os.path.exists(out)`. On the base that test fails with `AssertionError: 1 != 2` — the old code created `out/` first. **Claim: refusal is exit code 2 with a one-line message.** Confirmed: both branches `return 2`; the tests assert `rc == 2`, the message via `assertIn`, and that `stderr` has exactly one line (`len(err.getvalue().splitlines()) == 1`). A usage error rather than a failed run, consistent with the tool's other refusals (`--jobs < 1`, a bad range, a missing source) and with `test_missing_input_exit_codes`'s BUILD-1046 convention. ### 3. What the tests do here `python3 -I tests/test_awc_shorts.py` on the head: **21 tests, OK** (no skip on Linux). The author's "21 tests OK (1 skipped)" is the same run on Windows, where `test_bank_extensions_cannot_collapse_two_banks_into_one_export` skips (`self.skipTest("input volume does not support case-distinct files")`, line 143) because NTFS does not normally allow `clip.awc` and `clip.AWC` side by side; ext4 does, so it runs here. `python3 -I scripts/red_green.py 3078 --no-cargo` (work-dir `rg-3078`): **verdict "red then green"** — the three new tests go red→green, **0 regressions**, 0 fail on both, 18 pass on both. The red side (merge base + the pull request's test file) is exactly the base tool with the three new tests, and I ran it by hand to see the failures: | test | failure on the base | |---|---| | `test_catalog_collision_with_input_bank_rejected` | `AssertionError: 0 != 2` — the base tool ran the bank and returned 0 (the overwrite) | | `test_catalog_collision_with_bank_export_directory_rejected` | `AssertionError: 1 != 2` — the base tool created the export dir, then failed the catalog write | | `test_catalog_collision_refusal_creates_no_output_folder` | `AssertionError: 1 != 2` — the base tool created `out/` before failing | The three tests are not vacuous: each fails on the base with exactly the behaviour the fix changes, and each asserts the *consequence* (bank bytes unchanged; no output folder) not just the exit code. Also run: `python3 -I scripts/check_no_game_data.py tools/awc_shorts.py tests/test_awc_shorts.py` — exit 0 (clean); `python3 -m compileall` — clean; `python3 -I -m unittest discover -s tests -p "test_docs_*.py"` — 57 OK. ### 4. Anything wrong Nothing blocking. Three observations, none a defect of the change: - **The first check's reach is narrow by construction.** A directory scan never yields a bank named `shorts.csv`, so `catalog would overwrite the input bank` only fires for a single-file `src` named `shorts.csv`. That is exactly the case the PR describes, and the guard is still the right place for it; it is not a gap, just worth knowing that the directory-scan path only ever hits the second check. - **`target` is now computed twice per bank** (the guard loop and the destination-dedup loop both do `os.path.join(a.out, bank)`). That is a redundant `join` and one extra `same_report_path` (a `realpath` + `samefile`) per bank in the guard — negligible for an offline asset export, not a hot path. - **`same_report_path` vs `path_key`:** the guard uses `same_report_path`, the pre-existing dedup uses `path_key`. Both come from `report_paths`; the guard's is the stricter of the two (it also folds hard links and case aliases). Consistent with the report-path rules in `CONTRIBUTING.md`. ### 5. What I did not check - **Real AWC banks and a real game folder:** the tool's export path is exercised here only through the synthetic banks the tests build. I did not run `awc_shorts.py` over a game's AWC directory (no game files, and the point of the PR is the catalog guard, not the exporter). - **The full repository test suite and CI:** I ran the touched test file, the docs/hygiene suite (57), the line-endings test, compileall and the clean-room check. I did not run the whole `tests/` suite (semantic translator, viewer `.cjs`, `rpf9dump`, `runtime/` CTest, the D3D12 Rust crates) — the change touches none of those, and `red_green` ran the only Python test file the pull request changes. - **Windows behaviour:** the author's "1 skipped" is a Windows-specific skip; I could not confirm it on this Linux box (ext4 allows case-distinct files, so the test runs). The `same_report_path` case-folding path for a case-insensitive volume is not exercised here. - **The original #934 review thread (PierreEbele's note):** I read the code and confirmed the follow-up commit matches the described intent (checks moved before `os.makedirs`), but I did not read #934's own review comments — that is a different pull request and I was asked to verify only #3078. - **The full suite, CI queue:** not run, as the author also states ("Not run: the full suite, CI").
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!3078
No description provided.