WIP: fix(dev): the shared shader store takes a grown cache on Windows: the read-only file it replaces is made writable first #2825

Draft
llun wants to merge 1 commit from llun/Longshot:fix/mod-api-shader-store-windows into mod-api
Member

Summary

For #2822 (into mod-api). The shared shader store that scripts/devtools/shadercache.py keeps for dev.py keeps its files read-only (0o444). publish writes a grown cache to a temporary file and moves it over the store's copy. Windows won't replace a read-only file (os.replace: PermissionError: [WinError 5] Access is denied). The cleanup then fails the same way on the temporary file, which publish had also made read-only, so a base's second publish on Windows stops with that error and leaves a .tmp file in the store. This removes the read-only mark from the store's old copy before the move on Windows, and from the temporary file before removing it. Linux is unchanged.

Read first: publish in scripts/devtools/shadercache.py.

Testing

Tested: Windows 11, mise run test -- test_shader_store. The check's existing case, "a grown file replaces the store's", fails on mod-api @ eaf4a48b on Windows (the PermissionError above, from os.replace and then os.unlink) and passes here. It passes on Linux (WSL Ubuntu 24.04) both before and after. mise run lint passes.

Still to test: None.

Measurements

Verdict: fixed. A grown cache replaces the store's read-only copy on Windows: the check fails on mod-api and passes here.

Baseline: mod-api (#2822's head), the branch this PR goes into: the bug is there, not on main.

Setup: Windows 11, mise run test -- test_shader_store. The game and the builds are not affected: only the development tool's file move changes.

Before: mod-api @ eaf4a48b After: this PR @ 8b5d81b3
tests/test_shader_store.py, Windows FAIL: PermissionError: [WinError 5] Access is denied (os.replace, then os.unlink of the read-only temporary) pass
tests/test_shader_store.py, Linux (WSL Ubuntu 24.04) pass pass

Risks

The sandbox: not touched. This is dev.py's shared shader store on a developer's PC. The confined game's grants are unchanged, and the store's files stay read-only after the move.

Only dev.py's shared shader store on Windows changes. The store's new copy is still read-only after the move. A revert is enough. Players notice nothing.

Checklist

Ready for review

  • One topic, on current mod-api (#2822's head); the title is a Conventional Commit.
  • Tested on my own PC, as Testing says (a development tool and its check: no game run).
  • mise run test passes (any failure that also fails on main is named). (This check passes. The whole suite on mod-api has Windows-only failures, which another PR into mod-api fixes.)
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A fix: a game-free test that fails on main and passes here. (The existing check fails on mod-api on Windows.)
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

## Summary For [#2822](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2822) (into `mod-api`). The shared shader store that `scripts/devtools/shadercache.py` keeps for `dev.py` keeps its files read-only (0o444). `publish` writes a grown cache to a temporary file and moves it over the store's copy. Windows won't replace a read-only file (`os.replace`: `PermissionError: [WinError 5] Access is denied`). The cleanup then fails the same way on the temporary file, which `publish` had also made read-only, so a base's second publish on Windows stops with that error and leaves a `.tmp` file in the store. This removes the read-only mark from the store's old copy before the move on Windows, and from the temporary file before removing it. Linux is unchanged. Read first: `publish` in `scripts/devtools/shadercache.py`. ## Testing **Tested:** Windows 11, `mise run test -- test_shader_store`. The check's existing case, "a grown file replaces the store's", fails on `mod-api` @ eaf4a48b on Windows (the `PermissionError` above, from `os.replace` and then `os.unlink`) and passes here. It passes on Linux (WSL Ubuntu 24.04) both before and after. `mise run lint` passes. **Still to test:** None. ## Measurements **Verdict:** fixed. A grown cache replaces the store's read-only copy on Windows: the check fails on `mod-api` and passes here. Baseline: `mod-api` (#2822's head), the branch this PR goes into: the bug is there, not on `main`. Setup: Windows 11, `mise run test -- test_shader_store`. The game and the builds are not affected: only the development tool's file move changes. | | Before: mod-api @ eaf4a48b | After: this PR @ 8b5d81b3 | |---|---|---| | `tests/test_shader_store.py`, Windows | FAIL: `PermissionError: [WinError 5] Access is denied` (`os.replace`, then `os.unlink` of the read-only temporary) | pass | | `tests/test_shader_store.py`, Linux (WSL Ubuntu 24.04) | pass | pass | ## Risks **The sandbox:** not touched. This is `dev.py`'s shared shader store on a developer's PC. The confined game's grants are unchanged, and the store's files stay read-only after the move. Only `dev.py`'s shared shader store on Windows changes. The store's new copy is still read-only after the move. A revert is enough. Players notice nothing. ## Checklist ### Ready for review - [x] One topic, on current `mod-api` (#2822's head); the title is a Conventional Commit. - [x] Tested on my own PC, as Testing says (a development tool and its check: no game run). - [ ] `mise run test` passes (any failure that also fails on `main` is named). (This check passes. The whole suite on `mod-api` has Windows-only failures, which another PR into `mod-api` fixes.) - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A fix: a game-free test that fails on `main` and passes here. (The existing check fails on `mod-api` on Windows.) - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(game)!: the game side and the whole mod API in Rust, with system mods and the sandbox on by default
Some checks failed
CI / Third-party parts and guide screenshots (pull_request) Successful in 28s
PR description / Title and description (pull_request_target) Successful in 47s
CI / What the change needs (pull_request) Successful in 2m21s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 1m48s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
9e6b9c5782
The game side (between the C host and the lifted game) and the mod API move from C to Rust (game/crates), every game
setting and feature becomes a system mod (game/mods, Rust or TypeScript), and longshot-builder becomes the game's only
entrypoint, its sandboxer (Landlock and seccomp on Linux, an AppContainer on Windows) and its broker over one framed
channel. Native C mods and wasm are removed. The Insert menu is the menu system mod. One squashed commit of the former
mod-api branch (#2434).

Co-authored-by: Chloe Christley <[email protected]>
Co-authored-by: Jer9 <[email protected]>
Co-authored-by: snaildev99 <[email protected]>
Co-authored-by: SqueezyLemonade <[email protected]>
Co-authored-by: flashman4 <[email protected]>
Co-authored-by: dyst <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(dev): the shared shader store takes a grown cache on Windows: the read-only file it replaces is made writable first
All checks were successful
PR description / Title and description (pull_request_target) Successful in 37s
5b3107f78a
shadercache.publish keeps the store's files read-only (0o444) and moves a new copy over the old one. Windows moves
nothing over a read-only file (os.replace: PermissionError, WinError 5), and its cleanup then failed the same way on
the read-only temporary it had made, so a base's second publish on Windows stopped with the error and left the
temporary file in the store. tests/test_shader_store.py's "a grown file replaces the store's" fails on mod-api on
Windows for this reason and passes here; Linux is unchanged.

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Member

Possibly related, for context:

  • PR #737 feat(vk): one shader cache store for every game folder, so a build whose translation is unchanged prepares nothing — Open shader-store work; separate runtime store, not this devtools publish fix.
Possibly related, for context: - PR #737 feat(vk): one shader cache store for every game folder, so a build whose translation is unchanged prepares nothing — Open shader-store work; separate runtime store, not this devtools publish fix.
Author
Member

Measurements: the check's result before (mod-api @ 9e6b9c57, fails on Windows) and after (5b3107f7, passes; Linux passes both), with a Baseline line, as standards.md's Measurements asks of a fix.

Measurements: the check's result before (mod-api @ 9e6b9c57, fails on Windows) and after (5b3107f7, passes; Linux passes both), with a Baseline line, as standards.md's Measurements asks of a fix.
llun force-pushed fix/mod-api-shader-store-windows from 5b3107f78a
All checks were successful
PR description / Title and description (pull_request_target) Successful in 37s
to ac99f738e5
All checks were successful
PR description / Title and description (pull_request_target) Successful in 12s
2026-11-29 22:15:14 +00:00
Compare
Author
Member

Rebased onto mod-api's new squash eaf4a48b (the same tree as 9e6b9c57, which this branch was on): the diff is this PR's own commits again. The checks and runs above hold as they are (the tree under them is unchanged); the description's commits are the new ones.

Rebased onto mod-api's new squash eaf4a48b (the same tree as 9e6b9c57, which this branch was on): the diff is this PR's own commits again. The checks and runs above hold as they are (the tree under them is unchanged); the description's commits are the new ones.
Author
Member

Risks now says how this change stands with the sandbox (what it touches, and why the confined game reaches nothing more).

Risks now says how this change stands with the sandbox (what it touches, and why the confined game reaches nothing more).
llun force-pushed fix/mod-api-shader-store-windows from ac99f738e5
All checks were successful
PR description / Title and description (pull_request_target) Successful in 12s
to 1299b88735
All checks were successful
PR description / Title and description (pull_request_target) Successful in 16s
2026-11-29 23:27:29 +00:00
Compare
Author
Member

Rebased onto mod-api's newest (4cc50ca1: main's newest merged in), with no conflict; this PR's own checks were run again on the rebased head and pass as before. The merge touched none of this PR's files (#2827: only a comment in host/hos_main.c, far from its change), so the measurements and runs above hold; the After commit is the rebased head.

Rebased onto mod-api's newest (4cc50ca1: main's newest merged in), with no conflict; this PR's own checks were run again on the rebased head and pass as before. The merge touched none of this PR's files (#2827: only a comment in host/hos_main.c, far from its change), so the measurements and runs above hold; the After commit is the rebased head.
llun force-pushed fix/mod-api-shader-store-windows from 1299b88735
All checks were successful
PR description / Title and description (pull_request_target) Successful in 16s
to 755aa273c6
All checks were successful
PR description / Title and description (pull_request_target) Successful in 12s
2026-11-29 23:58:31 +00:00
Compare
Author
Member

Rebased onto mod-api @ 816d2354 (#2837, headless shots of the mods' UI), now 755aa273. No conflict, and the diff is the same as before (same git patch-id). #2837 touches none of this PR's files.

Rebased onto `mod-api` @ 816d2354 ([#2837](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2837), headless shots of the mods' UI), now 755aa273. No conflict, and the diff is the same as before (same `git patch-id`). #2837 touches none of this PR's files.
llun force-pushed fix/mod-api-shader-store-windows from 755aa273c6
All checks were successful
PR description / Title and description (pull_request_target) Successful in 12s
to 14db9da8e8
All checks were successful
PR description / Title and description (pull_request_target) Successful in 1m39s
2026-11-30 00:38:55 +00:00
Compare
llun force-pushed fix/mod-api-shader-store-windows from 14db9da8e8
All checks were successful
PR description / Title and description (pull_request_target) Successful in 1m39s
to 8b5d81b3bc
All checks were successful
PR description / Title and description (pull_request_target) Successful in 22s
2026-11-30 00:42:56 +00:00
Compare
Author
Member

Rebased onto mod-api @ c5e5b676: it was re-squashed onto main @ 46291934 (#2833) twice today (cdbb8551, then c5e5b676), which made this PR show main's and the whole mod API's diff. Now 8b5d81b3, the same diff as before (same git patch-id), no conflict. The changes underneath touch none of this PR's files, so its checks still hold.

Rebased onto `mod-api` @ c5e5b676: it was re-squashed onto main @ 46291934 (#2833) twice today (cdbb8551, then c5e5b676), which made this PR show main's and the whole mod API's diff. Now 8b5d81b3, the same diff as before (same `git patch-id`), no conflict. The changes underneath touch none of this PR's files, so its checks still hold.
All checks were successful
PR description / Title and description (pull_request_target) Successful in 22s
This pull request is marked as a work in progress.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'fix/mod-api-shader-store-windows:llun-fix/mod-api-shader-store-windows'
git switch 'llun-fix/mod-api-shader-store-windows'

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 'mod-api'
git merge --no-ff 'llun-fix/mod-api-shader-store-windows'
git switch 'llun-fix/mod-api-shader-store-windows'
git rebase 'mod-api'
git switch 'mod-api'
git merge --ff-only 'llun-fix/mod-api-shader-store-windows'
git switch 'llun-fix/mod-api-shader-store-windows'
git rebase 'mod-api'
git switch 'mod-api'
git merge --no-ff 'llun-fix/mod-api-shader-store-windows'
git switch 'mod-api'
git merge --squash 'llun-fix/mod-api-shader-store-windows'
git switch 'mod-api'
git merge --ff-only 'llun-fix/mod-api-shader-store-windows'
git switch 'mod-api'
git merge 'llun-fix/mod-api-shader-store-windows'
git push origin 'mod-api'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!2825
No description provided.