Skip to content

bvh_groups: restore write mode before unlink on replace failure and publish mode on Windows (BVH-GROUPS-STAGE-CLEANUP) - #752

Open
trigger337 wants to merge 2 commits into
ProjectLeonida:mainfrom
trigger337:fix/bvh-groups-stage-cleanup
Open

trigger337 wants to merge 2 commits into
ProjectLeonida:mainfrom
trigger337:fix/bvh-groups-stage-cleanup

Conversation

@trigger337

Copy link
Copy Markdown
Contributor

In tools/bvh_groups.py write_json_report:

  1. os.chmod(staged.name, published_mode(destination)) was skipped on Windows (if os.name != "nt":) because unlinking a temporary file chmod'd to read-only mode in finally: failed with PermissionError on Windows. As a result, Windows output files retained NamedTemporaryFile's private 0600 permissions.
  2. Ensure os.chmod(staged.name, 0o600) before os.unlink in finally:, enabling published_mode(destination) on all platforms and ensuring that temporary staging files are never leaked on failed replacements.
  3. Added regression tests in tests/test_bvh_groups.py verifying read-only replacement failure staging cleanup with strict Windows unlink emulation, and Windows published mode application.

agent: yes
AI-assisted: yes

@abnalstlll-byte abnalstlll-byte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Clean staging file unlink hardening on Windows for �vh_groups.py: applies published_mode regardless of platform, catches all OSError on cleanup, and restores writable

@abnalstlll-byte abnalstlll-byte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Audited and verified. Clean-room compliant.

  • Restores 0o600 mode before unlinking staging file on replace failure in tools/bvh_groups.py.
  • Applies published_mode across all platforms.
  • Regression tests in tests/test_bvh_groups.py PASS.

@tiguan26 tiguan26 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: on a failed replace the staged file gets 0o600 back before os.unlink, so a staged copy left read-only (the published mode on Windows) is still removed; and 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).

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 28, 2026
@trigger337
trigger337 force-pushed the fix/bvh-groups-stage-cleanup branch from 2e5d803 to 40e7f50 Compare November 28, 2026 17:22
@github-actions github-actions Bot removed the needs rebase Conflicts with the base branch: rebase it on main label Nov 28, 2026
@zmasi

zmasi commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

#752 | head 40e7f50 (merged cleanly with main aa918e5) | python -I tests/test_bvh_groups.py + live Windows NTFS stat.S_IREAD read-only destination cleanup check | red on main: FAILED (failures=1) (write_json_report skipped published_mode(destination) on Windows under if os.name != "nt": and lacked os.chmod(staged.name, 0o600) before os.unlink(staged.name) in finally:) | green on PR+main: 18 ran, OK (18/18 unit tests OK, plus clean PermissionError with 0 secondary unlink exceptions and 0 leftover .bvh_groups-* temp files on Windows NTFS when replacing a read-only report.json) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yes

Audited tools/bvh_groups.py and tests/test_bvh_groups.py on Windows 11 NTFS, confirming published_mode(destination) preservation on Windows and os.chmod(staged.name, 0o600) write-bit restoration before os.unlink(staged.name) in finally:. Also verified tests/test_ci_registration.py, tests/test_text_write_line_endings.py, and scripts/check_no_game_data.py.

@OreoFR

OreoFR commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, main 53b77df : red 1 failure (ScanTest.test_publish_applies_published_mode_on_windows) / green 20 OK.

  • PR head 40e7f50, python -I tests/test_bvh_groups.py from the repository root.
  • Red (main + only this PR's test files): 18 run, 1 failure, 0 skips. The published mode is not applied on main.
  • Green (main + git merge --no-ff of this PR, no conflict): 20 run, OK, 0 skips.
  • Skips: none.
  • Verdict: READY.

Red = main + only the test files from this PR (git checkout pr-752 -- tests/test_bvh_groups.py); green = main + the merged PR. When green runs more tests than red, it is because the merge keeps tests main added since the PR branched.

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

@OreoFR

OreoFR commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

Thanks for this PR. It has a red/green verification by OreoFR on macOS (READY): #752 (comment)

The only thing missing for a merge is your claim in the coordination issue #2570 (see CONTRIBUTING.md). Once it is there, a maintainer can pick it up.

AI-assisted: Claude Code

…ublish mode on Windows (BVH-GROUPS-STAGE-CLEANUP)
@trigger337
trigger337 force-pushed the fix/bvh-groups-stage-cleanup branch from 40e7f50 to 28cb356 Compare November 29, 2026 15:24
@TheGeogeo

Copy link
Copy Markdown
Contributor

Tested 28cb3569e merged (no commit) with main dd87aa405: Python 3.12.4, Windows 11 10.0.26300, CPU only.

  • Green: tests/test_bvh_groups.py gives 20 tests OK, none skipped.
  • Red: with tools/bvh_groups.py back to main, test_publish_applies_published_mode_on_windows fails.
  • Base: main's own version of that test gives 18 tests OK. check_no_game_data.py is clean.

AI-assisted (Claude Code).

@MoonEyes

Copy link
Copy Markdown
Collaborator

@trigger337 could you merge current main into this branch (a merge, no rebase or force-push) so CI runs again?

TheGeogeo's red/green is on the current head 28cb3569e. What is in the way is CI on that head, which is red on translator-tests, stdlib-tests-linux, check, semantic-tests (ubuntu-latest) and macos-python and ran on an older base. On main at 4014af7f, CI was green except macos. I have not checked whether each red here comes from main or from this PR, so the new run should tell.

The merge changes the head, so the red/green will need to be run again on the new one.

AI-assisted: yes

@trigger337

Copy link
Copy Markdown
Contributor Author

@MoonEyes Merged latest main into fix/bvh-groups-stage-cleanup via git merge (no rebase/force-push). All 20 tests pass (python -I tests/test_bvh_groups.py). Registered in #2570 (#2570 (comment)).

AI-assisted: yes

@MoonEyes

Copy link
Copy Markdown
Collaborator

@TheGeogeo could you run your red/green again on the new head 61b02b9e3? @trigger337 merged main into the branch, and your run was on the previous head 28cb3569e. The two red checks on this head (check and linux-python-and-viewer) both fail on tests/test_tool_stdout_encoding.py because of tools/d3d12_run_fps.py, which this PR does not touch; main has had a fix for it since #2708, so a later run should tell.

AI-assisted: yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants