leonida-lua: write_file checks the name a file really has (8.3 short names) (D3D12-LUA-WRITE-FILE-SHORT-NAMES) #3372
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
3 participants
Due date
No due date set.
Reference
leonida/mandy!3372
Loading…
Reference in a new issue
No description provided.
Delete branch "github-pr/3372"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request successfully merged and closed
Claimed in the coordination issue as: D3D12-LUA-WRITE-FILE-SHORT-NAMES (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7280764804)
What and why
write_fileind3d12/crates/leonida-lua/src/api.rsrefusesmod.jsonand the blocked extensions (exe,dll, ...) by the name the mod passes. On a volume that keeps 8.3 short names, NTFS also callsmod.jsonMOD~1.JSO. That is a plain relative name: it passessafe_relativeandinside(), it is notmod.jsonandjsois not a blocked extension, so onmaina mod can overwrite its own manifest withleonida.write_file("MOD~1.JSO", ...).The change:
not_writable, used for both names below, so the two can't drift apart.manifest::inside(), when the path leads to a file that is there,write_filecanonicalizes it (on Windows that gives the long name), takes it relative to the canonicalized mod folder and runs the same check on it.MOD~1.JSOis refused asmod.json.main: the resolved path is compared relative to the mod's folder, sosub/mod.jsonis still writable. The short name of an ordinary file is still written.The short name of a file with a blocked extension keeps the first three letters of the extension (
helper-tool.exeisHELPER~1.EXE), somainalready refuses it. A test pins that.Tested
src/tests.rs, run throughleonida.write_file, usingGetShortPathNameWfor the alias. They skip with a message when the volume makes no short names. The test volume (NTFS, Windows 11) has 8.3 names on (dir /xshowsMOD~1.JSO).the_manifest_is_not_written_by_its_short_name: red onmain(09273248c): the write returnedtrueand replacedmod.json. Green with the fix: refused,mod.jsonunchanged, and the alias of an ordinary file is still written.a_blocked_file_is_not_written_by_its_short_name: green onmainand with the fix.cargo test -p leonida-lua --lib --locked: 49 passed, 0 failed.cargo clippy -p leonida-lua --all-targets --locked -- -D warnings: clean.rustfmt --check: no diff in the changed lines.python scripts/check_no_game_data.py: OK.GPUs tested: n/a (CPU-only tests)
AI-assisted: yes (Claude Code, Claude Opus 5.5)
Relation to other work
write_fileinto a temp file and rename. This check runs before that, on the firstinside()result, so the two merge cleanly (checked withgit merge-tree). With #3226 alone,MOD~1.JSOno longer writes into the manifest but replacesmod.jsonwith a file namedMOD~1.JSO, so the check is still needed there.Win32_Storage_FileSystemtoleonida-lua'swindows-sysfeatures, on the same line. It merges cleanly too.mod.json/is now refused becausemod.jsonis always there. A trailing slash on a new file is not covered:write_file("new.exe/", ...)still createsnew.exe, as onmain. That is #2683's normalization and is left for a separate PR.Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code
662d061e1into #3372 (tree tested by local CI) 27819d656eMerged by OreoFR (agent) at MoonEyes' request: his judge accepted it, MoonEyes gave the go for group A, and enlighted ran it 300 s on an RTX 3090 with no cost. That run did not reach
write_file, since no mod runs at boot. The CI tests are what cover the write.Local CI (normal mode,
--trust-pr-code) on headba8071a0cmerged into main662d061e1: PASS.--trust-pr-codewas used after reading the PR'sCargo.tomlchange: one morewindows-sysfeature (Win32_Storage_FileSystem). It changes nobuild.rsand no CI.make_game.py --help, Rust tests 840 s, Rust replay test 79 s, Rust build as shipped 85 s, standard-library Python tests 601 s.The forge refused the merge while the head was behind main. So
main(662d061e1) was merged into the head as27819d656, with the same tree the CI tested. Merged as30a851050.Post-merge gate run on an RTX 3090 (NVIDIA 621.40, Windows 11 Pro build 26300): head
ba8071a0cmerged intomain04a838fc4, diag profile withdiagnostics,dlss,mimalloc, msvc target. The merged head27819d656only adds a merge ofmain662d061e1; the change this PR adds is byte-identical in both (same patch id formain..head). Reference:main04a838fc4built the same way. Series X output 2560x1440, DLSS quality, no frame generation, 300 s standing at the save, fresh data.main; median frame 28.20 ms, p99 44.8 against 45.5 ms. Pauses as in the reference, none after 150 s.Verdict: PASS, no cost.
GPUs tested: NVIDIA GeForce RTX 3090, driver 621.40.
AI-assisted: run and report by Claude Code (Claude Opus 5.5).