Scripts: replace coverage baselines atomically #2635

Open
luckyteagirl wants to merge 1 commit from upstream-pr/2645 into main
luckyteagirl commented 2026-11-26 04:54:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T04:54:44Z.


The coverage gate opens the existing baseline for writing, which truncates it before the new JSON is written. An interrupted write can leave later comparisons without a readable baseline. Write the report to a temporary file beside the baseline and replace the destination after the write succeeds.

What is in it

  • Stage and replace the baseline atomically, with cleanup and an error message on failure.
  • Preserve the existing baseline's mode on POSIX.
  • Test preservation of mode and contents, cleanup after a failed replacement, and successful retry.

Tested

  • Windows 11 build 26200, Ryzen 9 5980HX, Python 3.11.9.
  • With the failed-replacement regression and the implementation from main at b49be183, coverage gate tests ran with 9 passed, 1 failed, 0 skipped. The update incorrectly returned success despite the injected replacement failure.
  • On this commit, python -B -m unittest discover -s scripts -p 'test_*.py' ran on Windows with 26 passed, 0 failed, 1 skipped (the POSIX mode test).
  • On Ubuntu under WSL with Python 3.14.4, the POSIX regression failed on the previous PR revision (10 passed, 1 failed, 0 skipped), which set mode 0600 instead of 0664. The full Python suite on this commit ran with 27 passed, 0 failed, 0 skipped.
  • The local PR description checker passed.

Regression run

  • Not applicable to this scripts-only change.

Not tested

  • Rust workspace suite, GPU tests, and retail title smoke runs.

AI use

  • Codex (GPT-6.2-Sol) implemented and tested the change and drafted this description.
<!-- greyfinch-sync:ivall/xcl:issue:5504238273 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2645). Originally posted by [luckyteagirl](https://github.com/luckyteagirl) on 2026-11-26T04:54:44Z. --- The coverage gate opens the existing baseline for writing, which truncates it before the new JSON is written. An interrupted write can leave later comparisons without a readable baseline. Write the report to a temporary file beside the baseline and replace the destination after the write succeeds. **What is in it** - Stage and replace the baseline atomically, with cleanup and an error message on failure. - Preserve the existing baseline's mode on POSIX. - Test preservation of mode and contents, cleanup after a failed replacement, and successful retry. **Tested** - Windows 11 build 26200, Ryzen 9 5980HX, Python 3.11.9. - With the failed-replacement regression and the implementation from main at b49be183, coverage gate tests ran with 9 passed, 1 failed, 0 skipped. The update incorrectly returned success despite the injected replacement failure. - On this commit, `python -B -m unittest discover -s scripts -p 'test_*.py'` ran on Windows with 26 passed, 0 failed, 1 skipped (the POSIX mode test). - On Ubuntu under WSL with Python 3.14.4, the POSIX regression failed on the previous PR revision (10 passed, 1 failed, 0 skipped), which set mode 0600 instead of 0664. The full Python suite on this commit ran with 27 passed, 0 failed, 0 skipped. - The local PR description checker passed. **Regression run** - Not applicable to this scripts-only change. **Not tested** - Rust workspace suite, GPU tests, and retail title smoke runs. **AI use** - Codex (GPT-6.2-Sol) implemented and tested the change and drafted this description.
github-actions[bot] commented 2026-12-01 02:32:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-12-01T02:32:05Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7298719687 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2645#issuecomment-7298719687). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-12-01T02:32:05Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 08:33:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:33:18Z.


Triage (#1607) – head 5310ccc

No open or merged PR makes the same change. #2253 and #2265 edit the same --update block of coverage_gate.py (refuse empty / failed sweeps), a different problem; they will conflict textually.
write_baseline writes a temp file in the target folder, keeps the old mode on POSIX, os.replaces it and removes the temp on failure; the test covers a failed replace. No problems found in the diff.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7305471769 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2645#issuecomment-7305471769). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T08:33:18Z. --- **Triage (#1607)** – head 5310ccc No open or merged PR makes the same change. #2253 and #2265 edit the same `--update` block of `coverage_gate.py` (refuse empty / failed sweeps), a different problem; they will conflict textually. `write_baseline` writes a temp file in the target folder, keeps the old mode on POSIX, `os.replace`s it and removes the temp on failure; the test covers a failed replace. No problems found in the diff. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Decodere commented 2026-12-02 09:00:55 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Decodere on 2026-12-02T09:00:55Z.


merge-check
base: 1c8b551475
head: 5310ccce9f
merge: clean (git merge --no-edit onto 1c8b5514, git diff --check clean; scripts/coverage_gate.py and scripts/test_coverage_gate.py, +72/-3)
build: not run (Tier 0 Python script diff; no Rust code changed)
tests: python -m unittest discover -s scripts -p "test_coverage_gate.py" -v -> 10 passed, 0 failed, 1 skipped (test_replacement_preserves_the_previous_baseline_mode: requires POSIX file modes; base 1c8b5514: 9 passed; new test_failed_replacement_preserves_the_previous_baseline passed); python -m unittest discover -s scripts -p "test_*.py" -> 66 passed, 1 skipped, 1 error (test_discord_mirror.py on Windows, same failure on base 1c8b5514). Rust workspace tests not run (Tier 0).
review: Read the full diff (+72/-3). write_baseline (scripts/coverage_gate.py:57-76) stages JSON into a same-directory temp file (delete=False), preserves existing file mode on POSIX, atomically swaps with os.replace, cleans up the temp file in finally on failure, and exits 2 cleanly on OSError in main(). Note: the POSIX chmod branch was not executed on Windows (skipped cleanly via skipUnless). No problems found.
performance: none (offline script in scripts/; zero runtime impact)
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 4060 8 GB (driver 621.40), Intel Core i5-11400F, 32 GB RAM, Windows 11 Build 26200, Python 3.15.2, Rust 1.100.1 MSVC, DXC 1.9.2602.17 / Antigravity (Gemini 4 Neon)

<!-- greyfinch-sync:ivall/xcl:comment:7340244270 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2645#issuecomment-7340244270). Originally posted by [Decodere](https://github.com/Decodere) on 2026-12-02T09:00:55Z. --- merge-check base: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f head: 5310ccce9ff14d9e0faabb4b2af2b770c27b42ff merge: clean (`git merge --no-edit` onto `1c8b5514`, `git diff --check` clean; `scripts/coverage_gate.py` and `scripts/test_coverage_gate.py`, +72/-3) build: not run (Tier 0 Python script diff; no Rust code changed) tests: `python -m unittest discover -s scripts -p "test_coverage_gate.py" -v` -> 10 passed, 0 failed, 1 skipped (`test_replacement_preserves_the_previous_baseline_mode`: requires POSIX file modes; base `1c8b5514`: 9 passed; new `test_failed_replacement_preserves_the_previous_baseline` passed); `python -m unittest discover -s scripts -p "test_*.py"` -> 66 passed, 1 skipped, 1 error (`test_discord_mirror.py` on Windows, same failure on base `1c8b5514`). Rust workspace tests not run (Tier 0). review: Read the full diff (+72/-3). `write_baseline` (`scripts/coverage_gate.py:57-76`) stages JSON into a same-directory temp file (`delete=False`), preserves existing file mode on POSIX, atomically swaps with `os.replace`, cleans up the temp file in `finally` on failure, and exits 2 cleanly on `OSError` in `main()`. Note: the POSIX chmod branch was not executed on Windows (skipped cleanly via `skipUnless`). No problems found. performance: none (offline script in `scripts/`; zero runtime impact) verdict: safe to merge hardware / tool and model: NVIDIA GeForce RTX 4060 8 GB (driver 621.40), Intel Core i5-11400F, 32 GB RAM, Windows 11 Build 26200, Python 3.15.2, Rust 1.100.1 MSVC, DXC 1.9.2602.17 / Antigravity (Gemini 4 Neon)
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2645:upstream-pr/2645'
git switch 'upstream-pr/2645'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2645'
git switch 'upstream-pr/2645'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2645'
git switch 'upstream-pr/2645'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2645'
git switch 'main'
git merge --squash 'upstream-pr/2645'
git switch 'main'
git merge --ff-only 'upstream-pr/2645'
git switch 'main'
git merge 'upstream-pr/2645'
git push origin 'main'
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
xcl-dev/xcl!2635
No description provided.