image_query_probe: publish mode on Windows (IMAGE-QUERY-PROBE-STAGE-CLEANUP) #796

Open
github-bot wants to merge 1 commit from github-bot/gh-796 into main AGit
Owner

@⁠trigger337 on GitHub · 2026-11-24 13:56 UTC · original
trigger337:fix/image-query-probe-stage-cleanup → main · +38 −2 · 2 files · 1 commits · open

In tools/image_query_probe.py, _write_json already restored 0o600 before unlinking on failure in its except BaseException block, but previously skipped applying published_mode on Windows via if os.name != "nt":.

Remove the Windows skip so Windows outputs inherit published permissions consistently across platforms, and add synthetic regression tests for cleanup on replace failure and Windows published_mode application.

Tests pass (21/21 in test_image_query_probe.py), scripts/check_no_game_data.py passes cleanly.

agent: yes
AI-assisted: yes

**@⁠trigger337** on GitHub · 2026-11-24 13:56 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/796) `trigger337:fix/image-query-probe-stage-cleanup` → `main` · +38 −2 · 2 files · 1 commits · open In `tools/image_query_probe.py`, `_write_json` already restored `0o600` before unlinking on failure in its `except BaseException` block, but previously skipped applying `published_mode` on Windows via `if os.name != "nt":`. Remove the Windows skip so Windows outputs inherit published permissions consistently across platforms, and add synthetic regression tests for cleanup on replace failure and Windows `published_mode` application. Tests pass (21/21 in `test_image_query_probe.py`), `scripts/check_no_game_data.py` passes cleanly. agent: yes AI-assisted: yes
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:21:46 +00:00
Author
Owner

@⁠tiguan26 on GitHub · 2026-11-25 03:59 UTC · original · approved these changes

Approving. Merged into current main with no conflicts; the PR's tests pass (Linux, Python 3.13). Same pattern as the rest of the *-STAGE-CLEANUP series: the published mode now also applies on Windows (the os.name guard is gone), using file_mode.published_mode. Only the staging/permission lines change.

AI-assisted (Claude).

**@⁠tiguan26** on GitHub · 2026-11-25 03:59 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/796#pullrequestreview-6051667100) · **approved these changes** Approving. Merged into current main with no conflicts; the PR's tests pass (Linux, Python 3.13). Same pattern as the rest of the *-STAGE-CLEANUP series: the published mode now also applies on Windows (the os.name guard is gone), using file_mode.published_mode. Only the staging/permission lines change. AI-assisted (Claude).
Author
Owner

@⁠DeadlyChirp on GitHub · 2026-11-25 15:23 UTC · original

Tested on Windows 11, Python 3.12.10, with this PR merged onto upstream main b0f3d3998 (merge commit 5fc3e33b4).

python -I tests/test_image_query_probe.py:

  • PR: 21 tests OK (1 skipped). main: 19 tests OK (1 skipped).
  • The skip is the existing hardware-oracle test (no AMD clang). The 2 new tests run and pass.

(AI-assisted test run; output checked by hand.)

**@⁠DeadlyChirp** on GitHub · 2026-11-25 15:23 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/796#issuecomment-7166779649) Tested on Windows 11, Python 3.12.10, with this PR merged onto upstream main b0f3d3998 (merge commit 5fc3e33b4). `python -I tests/test_image_query_probe.py`: - PR: 21 tests OK (1 skipped). main: 19 tests OK (1 skipped). - The skip is the existing hardware-oracle test (no AMD clang). The 2 new tests run and pass. (AI-assisted test run; output checked by hand.)
Author
Owner

@⁠PierreEbele on GitHub · 2026-11-25 20:41 UTC · original

Reviewed 9e7e655: I ran tests/test_image_query_probe.py on the PR (21 OK) and on main (19 OK), with this PR's test file on main (only test_publish_applies_published_mode_on_windows fails there, so it does pin the fix), plus test_file_mode, test_replace_retry, test_missing_input_exit_codes, check_no_game_data.py, and a probe comparing the two trees. The guard removal is right and matches the other staging writers; two issues in the new tests: (1) test_publish_cleans_up_staged_file_when_replace_fails_even_if_readonly never reaches the staging code - with a 0o444 destination, os.open(destination, os.O_WRONLY) (line 302) raises before any temp file is created (probe: replace/unlink mocks 0 calls, on main too). Please patch published_mode to return 0o444 while keeping the destination writable so the cleanup path is actually exercised; (2) that test also leaves report.json at 0o444, which on a native Windows run makes TemporaryDirectory teardown fail with PermissionError - restore 0o600 in a finally like the existing readonly test does. I could not run Windows here, so (2) is from shutil.rmtree/read-only semantics, not an execution. AI-assisted review.

Recommendation: Fix first

**@⁠PierreEbele** on GitHub · 2026-11-25 20:41 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/796#issuecomment-7174047054) Reviewed 9e7e655: I ran `tests/test_image_query_probe.py` on the PR (21 OK) and on `main` (19 OK), with this PR's test file on `main` (only `test_publish_applies_published_mode_on_windows` fails there, so it does pin the fix), plus `test_file_mode`, `test_replace_retry`, `test_missing_input_exit_codes`, `check_no_game_data.py`, and a probe comparing the two trees. The guard removal is right and matches the other staging writers; two issues in the new tests: (1) `test_publish_cleans_up_staged_file_when_replace_fails_even_if_readonly` never reaches the staging code - with a `0o444` destination, `os.open(destination, os.O_WRONLY)` (line 302) raises before any temp file is created (probe: replace/unlink mocks 0 calls, on `main` too). Please patch `published_mode` to return `0o444` while keeping the destination writable so the cleanup path is actually exercised; (2) that test also leaves `report.json` at `0o444`, which on a native Windows run makes `TemporaryDirectory` teardown fail with `PermissionError` - restore `0o600` in a `finally` like the existing readonly test does. I could not run Windows here, so (2) is from `shutil.rmtree`/read-only semantics, not an execution. AI-assisted review. **Recommendation:** Fix first
Author
Owner

@⁠tiguan26 on GitHub · 2026-11-26 06:59 UTC · original

Confirming @⁠PierreEbele's finding: with this PR's test file against main's tool, only test_publish_applies_published_mode_on_windows fails here (Linux, run as root), so that one pins the change. The cleanup test passes on main even as root and never reaches the staging code. My approval was for the guard removal, which is right; I didn't check each test against main. Patching published_mode to 0o444 on a writable destination, as suggested, would let the cleanup test do its job, and restoring the destination's mode before the temporary directory is removed avoids the Windows teardown error. AI-assisted (Claude).

**@⁠tiguan26** on GitHub · 2026-11-26 06:59 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/796#issuecomment-7184977561) Confirming @⁠PierreEbele's finding: with this PR's test file against main's tool, only `test_publish_applies_published_mode_on_windows` fails here (Linux, run as root), so that one pins the change. The cleanup test passes on main even as root and never reaches the staging code. My approval was for the guard removal, which is right; I didn't check each test against main. Patching `published_mode` to 0o444 on a writable destination, as suggested, would let the cleanup test do its job, and restoring the destination's mode before the temporary directory is removed avoids the Windows teardown error. AI-assisted (Claude).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/796/head:github-bot/gh-796'
git switch 'github-bot/gh-796'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-796'
git switch 'github-bot/gh-796'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-796'
git switch 'github-bot/gh-796'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-796'
git switch 'main'
git merge --squash 'github-bot/gh-796'
git switch 'main'
git merge --ff-only 'github-bot/gh-796'
git switch 'main'
git merge 'github-bot/gh-796'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.