scripts/carve_all.ps1: validate dirs, filter -File and publish coverage.json atomically #1847

Merged
leonida/mandy
kirigayakazima merged 1 commit from fix/carve-all-safety into main 2026-11-28 15:02:39 +00:00

Pull request successfully merged and closed

kirigayakazima commented 2026-11-25 13:01:55 +00:00

Claimed in the coordination issue as: CARVE-ALL-FILE-FILTER-EMPTY-AND-ATOMIC-COVERAGE (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7163140447)

What and why

  • Validate -Game as a directory (Test-Path -LiteralPath $Game -PathType Container) and ensure -Out is not an existing file before creating $outFull via [System.IO.Directory]::CreateDirectory(...) (literal path safe with [ ] characters).
  • Add -File to Get-ChildItem -LiteralPath $Game -Recurse -File -Filter *.rpf so directories named *.rpf are skipped rather than passed to tools/rpf9_carve.py.
  • Emit valid "[]" JSON when no .rpf archives are found, write coverage.json atomically via .coverage.<pid>.<guid>.tmp UTF-8 no-BOM staging + Move-Item -LiteralPath ... -Force + finally cleanup, and skip Format-Table when $rows.Count -eq 0.
  • Preserve CRLF line endings on scripts/carve_all.ps1 and add PowerShell 5.1 regression tests in tests/test_carve_all_paths.py.

Tested

  • python -I tests/test_carve_all_paths.py -v (live Windows PowerShell 5.1) -> Ran 11 tests in 11.463s, OK.
  • python -I tests/test_carve_all_brackets.py -v -> Ran 1 test in 0.461s, OK.
  • Detached upstream/main (98c2f777) baseline worktree with updated tests/test_carve_all_paths.py -> Ran 11 tests in 11.603s, FAILED (failures=2, errors=1).
  • CRLF verification on scripts/carve_all.ps1 -> PS1_CRLF=81 PS1_LF_ONLY=0.
  • python -I tests/test_ci_registration.py -> Ran 16 tests in 5.282s, OK.
  • python -I tests/test_text_write_line_endings.py -> Ran 3 tests in 12.773s, OK.
  • python -I scripts/check_no_game_data.py scripts/carve_all.ps1 tests/test_carve_all_paths.py, python -I -m compileall -q tests/test_carve_all_paths.py, and git diff --check -> exit 0.

GPUs tested: n/a (Windows PowerShell 5.1 + stdlib Python tests on Windows 11 x64)

AI-assisted: yes

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)
Claimed in the coordination issue as: CARVE-ALL-FILE-FILTER-EMPTY-AND-ATOMIC-COVERAGE (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7163140447) ### What and why - Validate `-Game` as a directory (`Test-Path -LiteralPath $Game -PathType Container`) and ensure `-Out` is not an existing file before creating `$outFull` via `[System.IO.Directory]::CreateDirectory(...)` (literal path safe with `[ ]` characters). - Add `-File` to `Get-ChildItem -LiteralPath $Game -Recurse -File -Filter *.rpf` so directories named `*.rpf` are skipped rather than passed to `tools/rpf9_carve.py`. - Emit valid `"[]"` JSON when no `.rpf` archives are found, write `coverage.json` atomically via `.coverage.<pid>.<guid>.tmp` UTF-8 no-BOM staging + `Move-Item -LiteralPath ... -Force` + `finally` cleanup, and skip `Format-Table` when `$rows.Count -eq 0`. - Preserve CRLF line endings on `scripts/carve_all.ps1` and add PowerShell 5.1 regression tests in `tests/test_carve_all_paths.py`. ### Tested - `python -I tests/test_carve_all_paths.py -v` (live Windows PowerShell 5.1) -> `Ran 11 tests in 11.463s`, `OK`. - `python -I tests/test_carve_all_brackets.py -v` -> `Ran 1 test in 0.461s`, `OK`. - Detached `upstream/main` (`98c2f777`) baseline worktree with updated `tests/test_carve_all_paths.py` -> `Ran 11 tests in 11.603s`, `FAILED (failures=2, errors=1)`. - CRLF verification on `scripts/carve_all.ps1` -> `PS1_CRLF=81 PS1_LF_ONLY=0`. - `python -I tests/test_ci_registration.py` -> `Ran 16 tests in 5.282s`, `OK`. - `python -I tests/test_text_write_line_endings.py` -> `Ran 3 tests in 12.773s`, `OK`. - `python -I scripts/check_no_game_data.py scripts/carve_all.ps1 tests/test_carve_all_paths.py`, `python -I -m compileall -q tests/test_carve_all_paths.py`, and `git diff --check` -> exit `0`. GPUs tested: n/a (Windows PowerShell 5.1 + stdlib Python tests on Windows 11 x64) AI-assisted: yes ### 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)
zmasi commented 2026-11-28 12:21:39 +00:00

#1847 | head 35205833160450ad0eaab80b18a1c712f22040c3 (merged cleanly with main d48a957bb) | python -I tests/test_carve_all_paths.py | red on main: FAILED (failures=2, errors=1) (attempted to carve a fake.rpf directory, failed to create bracketed out [empty]\coverage.json, and threw Substring error when -Game was a file) | green on PR+main: 11 tests OK | Windows 11 (powershell.exe 5.1), Python 3.12.10 | AI-assisted: yes

Audited scripts/carve_all.ps1 and tests/test_carve_all_paths.py on Windows 11 PowerShell (powershell.exe), verifying -PathType Container / -PathType Leaf validation on -Game and -Out, -File filtering on Get-ChildItem, -LiteralPath safety on [empty] bracketed output paths, and UTF-8-no-BOM temporary file staging + Move-Item -LiteralPath atomic publication of coverage.json (including "[]" on empty archive sets). Also verified tests/test_ci_registration.py (18 OK), tests/test_text_write_line_endings.py (3 OK), and scripts/check_no_game_data.py.

#1847 | head 35205833160450ad0eaab80b18a1c712f22040c3 (merged cleanly with main d48a957bb) | `python -I tests/test_carve_all_paths.py` | red on main: `FAILED (failures=2, errors=1)` (attempted to carve a `fake.rpf` directory, failed to create bracketed `out [empty]\coverage.json`, and threw `Substring` error when `-Game` was a file) | green on PR+main: `11 tests OK` | Windows 11 (`powershell.exe` 5.1), Python 3.12.10 | AI-assisted: yes Audited `scripts/carve_all.ps1` and `tests/test_carve_all_paths.py` on Windows 11 PowerShell (`powershell.exe`), verifying `-PathType Container` / `-PathType Leaf` validation on `-Game` and `-Out`, `-File` filtering on `Get-ChildItem`, `-LiteralPath` safety on `[empty]` bracketed output paths, and UTF-8-no-BOM temporary file staging + `Move-Item -LiteralPath` atomic publication of `coverage.json` (including `"[]"` on empty archive sets). Also verified `tests/test_ci_registration.py` (`18 OK`), `tests/test_text_write_line_endings.py` (`3 OK`), and `scripts/check_no_game_data.py`.
MoonEyes commented 2026-11-28 15:02:29 +00:00

Red/green: classified READY by cloud-4 (red on main 09c153948, green on head merged with main); head 352058331604 unchanged since 2026-11-25, before that run.
Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main d48a957bb in GitHub Actions: no new failure.
AI-assisted (Claude Code, Claude Opus 5.5)

Red/green: classified READY by cloud-4 (red on main 09c153948, green on head merged with main); head 352058331604 unchanged since 2026-11-25, before that run. Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main d48a957bb in GitHub Actions: no new failure. AI-assisted (Claude Code, Claude Opus 5.5)
Sign in to join this conversation.
No description provided.