d3d12 lua: replace target via temp file in write_file to avoid writing through hard links (D3D12-LUA-WRITE-FILE-HARD-LINK) #3226

Open
lixonik wants to merge 4 commits from upstream-pr/3226 into main
lixonik commented 2026-12-02 21:13:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-02T21:13:23Z.


Summary

Addresses #3212 (covers write_file; read_file hard links remain tracked separately).

  • Root cause: manifest::inside prevents symlinks and junctions from escaping the mod's folder via canonicalize, but a pre-existing hard link inside the mod's folder resolves to its own path inside the folder. Calling std::fs::write(&path, data) directly then opens, truncates, and overwrites the shared file outside the mod's folder.
  • Fix: Replace std::fs::write in d3d12/crates/leonida-lua/src/api.rs with write_replacing(&path, data):
    • Create a unique sibling temporary file in path.parent() using OpenOptions::new().write(true).create_new(true) (.leonida-write-{pid}-{seq}.tmp, bounded retry on AlreadyExists), so it never opens or follows an existing file, hard link, or symlink.
    • Write all bytes, explicitly drop(file) before rename/cleanup (required on Windows), and replace path with std::fs::rename(&tmp, path).
    • On write or rename failure, remove the temporary file so no .leonida-write-*.tmp file is left behind.
  • Why temp-file + rename (Option 1 from #3212):
    • Breaks any pre-existing hard link on both Windows NTFS and POSIX without mutating the outside file.
    • Prevents half-written files on crash.
    • Requires no unsafe code, no platform-specific FFI, and no new Cargo.toml features.
    • Preserves copy-on-write behavior for hard-link-deploying mod managers (and intentionally keeps read_file out of scope as a separate concern, since hard-link mod managers rely on reading hard-linked mod assets).
    • Does not touch manifest.rs, avoiding merge conflicts with #3189.

Verification

  • Red -> Green on Windows 10 NTFS (d3d12/crates/leonida-lua/src/tests.rs):
    • Added write_file_replaces_hard_link_without_changing_outside_file, creating real NTFS hard links (std::fs::hard_link) in both the mod root and a nested subdirectory pointing to a sibling outside.txt, plus an existing directory target to verify temp-file cleanup on rename error.
    • Red (before fix): cargo test -p leonida-lua --lib --locked write_file_replaces_hard_link_without_changing_outside_file FAILED (left: "NESTED", right: "KEEP" -- outside.txt was overwritten through the hard link).
    • Green (after fix): cargo test -p leonida-lua --lib --locked -> 45 passed, 0 failed.
  • cargo clippy -p leonida-lua --all-targets --locked -- -D warnings -> 0 warnings.
  • python -I scripts/check_no_game_data.py -> PASS.
  • Independent read-only diff review (APPROVE).

AI-assisted: Antigravity (Gemini 4 Neon; separate read-only reviewer subagent: Antigravity Pro preset / Gemini Pro)

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5614810132 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3226). Originally posted by [lixonik](https://github.com/lixonik) on 2026-12-02T21:13:23Z. --- ## Summary Addresses #3212 (covers `write_file`; `read_file` hard links remain tracked separately). - **Root cause:** `manifest::inside` prevents symlinks and junctions from escaping the mod's folder via `canonicalize`, but a pre-existing hard link inside the mod's folder resolves to its own path inside the folder. Calling `std::fs::write(&path, data)` directly then opens, truncates, and overwrites the shared file outside the mod's folder. - **Fix:** Replace `std::fs::write` in `d3d12/crates/leonida-lua/src/api.rs` with `write_replacing(&path, data)`: - Create a unique sibling temporary file in `path.parent()` using `OpenOptions::new().write(true).create_new(true)` (`.leonida-write-{pid}-{seq}.tmp`, bounded retry on `AlreadyExists`), so it never opens or follows an existing file, hard link, or symlink. - Write all bytes, explicitly `drop(file)` before rename/cleanup (required on Windows), and replace `path` with `std::fs::rename(&tmp, path)`. - On write or rename failure, remove the temporary file so no `.leonida-write-*.tmp` file is left behind. - **Why temp-file + rename (Option 1 from #3212):** - Breaks any pre-existing hard link on both Windows NTFS and POSIX without mutating the outside file. - Prevents half-written files on crash. - Requires no `unsafe` code, no platform-specific FFI, and no new `Cargo.toml` features. - Preserves copy-on-write behavior for hard-link-deploying mod managers (and intentionally keeps `read_file` out of scope as a separate concern, since hard-link mod managers rely on reading hard-linked mod assets). - Does not touch `manifest.rs`, avoiding merge conflicts with #3189. ## Verification - **Red -> Green on Windows 10 NTFS (`d3d12/crates/leonida-lua/src/tests.rs`):** - Added `write_file_replaces_hard_link_without_changing_outside_file`, creating real NTFS hard links (`std::fs::hard_link`) in both the mod root and a nested subdirectory pointing to a sibling `outside.txt`, plus an existing directory target to verify temp-file cleanup on rename error. - **Red (before fix):** `cargo test -p leonida-lua --lib --locked write_file_replaces_hard_link_without_changing_outside_file` FAILED (`left: "NESTED", right: "KEEP"` -- `outside.txt` was overwritten through the hard link). - **Green (after fix):** `cargo test -p leonida-lua --lib --locked` -> **45 passed, 0 failed**. - `cargo clippy -p leonida-lua --all-targets --locked -- -D warnings` -> **0 warnings**. - `python -I scripts/check_no_game_data.py` -> **PASS**. - Independent read-only diff review (`APPROVE`). AI-assisted: Antigravity (Gemini 4 Neon; separate read-only reviewer subagent: Antigravity Pro preset / Gemini Pro)
fiestorra commented 2026-12-02 21:33:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T21:33:35Z.


Head (this PR)
Merge base b41763227 = current main

Ran

cargo test -p leonida-lua     45 passed; 0 failed
  tests::write_file_replaces_hard_link_without_changing_outside_file ... ok

Negative control (d3d12/crates/leonida-lua/src/api.rs reverted to main, the PR's tests kept):

FAILED: tests::write_file_replaces_hard_link_without_changing_outside_file
assertion `left == right` failed

This is the other half of the escape #3189 closed: that one refused a dangling symlink/junction inside the mod's folder because canonicalize walked past it; this one is about a hard link, which inside() cannot see at all — it is just another directory entry to the same file, so a write_file truncating it writes outside the mod's folder. Writing to a temp beside the target and renaming it over path replaces the directory entry, which breaks the hard link, and it also means a write over a symlink replaces the link rather than following it. Two PRs, two link kinds, and the same sentence holds for both: a mod's write must not reach a file it did not create.

The second benefit is in the docstring and is real: a failed write no longer leaves a half-written file where the mod's file was.

The stacked warning, again

This branch carries other open pull requests: CAP_UNREAD (3 times) from #3204 and the exit $LASTEXITCODE line from #3210 — main has neither. Merging #3226 lands #3204 and #3210 as well. That is the third stacked branch tonight (#3200 → #3132, #3227 → #3204, now this); merge order needs a rule, not a reviewer's memory.

Correspondingly, my run exercised those branches together — which is the state the branch is in.

What I could not test

  • A real mod writing through a link: the test creates it; no game run.
  • A rename over an open file on Windows: fs::rename replaces an existing file, but if the title holds the target open the write would fail where a truncate might have succeeded — I did not test that case, and it is the one a mod could hit while the game has the file open.

Written with an AI assistant.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7359451330 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3226#issuecomment-7359451330). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-02T21:33:35Z. --- ## VERIFY-3226 — Windows nativo: `red then green`, y cierra la variante de **hard link** de la escapada de #3189 | | | |---|---| | Head | `(this PR)` | | Merge base | `b41763227` = current `main` | **Ran** ``` cargo test -p leonida-lua 45 passed; 0 failed tests::write_file_replaces_hard_link_without_changing_outside_file ... ok ``` **Negative control** (`d3d12/crates/leonida-lua/src/api.rs` reverted to `main`, the PR's tests kept): ``` FAILED: tests::write_file_replaces_hard_link_without_changing_outside_file assertion `left == right` failed ``` **This is the other half of the escape #3189 closed**: that one refused a **dangling symlink/junction** inside the mod's folder because `canonicalize` walked past it; this one is about a **hard link**, which `inside()` cannot see at all — it is just another directory entry to the same file, so a `write_file` truncating it writes **outside** the mod's folder. Writing to a temp beside the target and renaming it over `path` **replaces the directory entry**, which breaks the hard link, and it also means a write over a symlink replaces the link rather than following it. Two PRs, two link kinds, and the same sentence holds for both: a mod's write must not reach a file it did not create. **The second benefit is in the docstring and is real**: a failed write no longer leaves a half-written file where the mod's file was. ## The stacked warning, again **This branch carries other open pull requests**: `CAP_UNREAD` (3 times) from **#3204** and the `exit $LASTEXITCODE` line from **#3210** — `main` has neither. **Merging #3226 lands #3204 and #3210 as well.** That is the third stacked branch tonight (#3200 → #3132, #3227 → #3204, now this); **merge order needs a rule, not a reviewer's memory.** **Correspondingly, my run exercised those branches together** — which is the state the branch is in. ## What I could not test - **A real mod writing through a link**: the test creates it; no game run. - **A rename over an open file on Windows**: `fs::rename` replaces an existing file, but if the title holds the target open the write would fail where a truncate might have succeeded — I did not test that case, and it is the one a mod could hit while the game has the file open. Written with an AI assistant.
MoonEyes commented 2026-12-02 22:00:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T22:00:03Z.


This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).

Could you, or anyone with a working setup, post a run report on the current head merged onto current main:

  • the head SHA and the main SHA it was merged onto;
  • GPU, driver and OS;
  • at least 300 s in the world after loading;
  • device lost / crashes (count), and rendered fps (median) if you have them;
  • the same run on main alone for comparison, if you can.

Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7360081966 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3226#issuecomment-7360081966). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T22:00:03Z. --- This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists). Could you, or anyone with a working setup, post a run report on the **current head** merged onto current `main`: - the head SHA and the `main` SHA it was merged onto; - GPU, driver and OS; - at least 300 s in the world after loading; - device lost / crashes (count), and rendered fps (median) if you have them; - the same run on `main` alone for comparison, if you can. Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough. AI-assisted (Claude Code).
Kal0s-design commented 2026-12-02 22:00:44 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-02T22:00:44Z.


Ran natively on Windows 11, head ce5831530 merged into current main (f3865cae8, clean merge).

I opened #3212, so I checked it on NTFS the same way I found it. The fix does what the issue asked for. A few things changed along with it, listed below.

Build first. The merge is textually clean but the tests don't compile. #3179 made Runtime::new infallible, and the new test still calls Runtime::new(...).unwrap() (tests.rs, new test). main has the same problem in the #3189 test, which #3237 fixes. I dropped the two .unwrap() calls locally to run anything. After #3237 lands this PR still needs its own .unwrap() removed, or a rebase.

Tests (cargo test -p leonida-lua --lib --locked, both with the .unwrap() fix)

result
main 46 passed, 0 failed
merge 47 passed, 0 failed
merge with api.rs reverted to main, tests kept 46 passed, 1 failed: write_file_replaces_hard_link_without_changing_outside_file (left: "NESTED", right: "KEEP")

clippy --all-targets -D warnings: clean. cargo fmt --check: two diffs in api.rs, both already on main (require and teleport), none from this PR.

Extra cases (throwaway tests calling write_file/read_file directly, in a temp folder, same probes on main and on the merge). All measured.

case main this PR
hard link in mod folder to a file outside outside file overwritten outside unchanged, mod file has new content, link gone
hard link, both names inside the folder both names change only the written name changes
target open elsewhere, share R/W/D (Rust default) ok ok
target open elsewhere, share R/W, no DELETE (C fopen, .NET FileShare.ReadWrite) ok fails, Access is denied (os error 5), old content kept
target open, share R only / none fails, os error 32 fails, os error 5
read-only target fails, os error 5 fails, os error 5, still read-only
hidden attribute on target kept lost (0x22 -> 0x20)
explicit ACE on target kept lost (file gets the folder's inherited ACL)
target is a directory fails, os error 5 fails, os error 5
file under a junction to a folder inside the mod ok ok
junction to a folder outside refused refused
dangling junction (#3189), write under it and onto it refused refused
200-char name, single and nested ok ok (temp name is short and fixed, no overflow)
201-char name refused refused
2 threads x 500 writes of 64 KiB, same name 0 errors 1 to 3 spurious refusals per run, "c.txt leads out of the mod's folder" (once "cannot be resolved", os error 2); final file whole
read_file in a loop while another thread writes 103 of 197 reads torn 0 torn
.leonida-write-*.tmp left behind n/a none in any case above, failures included
read_file through a hard link to an outside file returns outside content still returns outside content

What I take from it:

  • The open-file row is the one I'd look at. A handle without FILE_SHARE_DELETE is common, and today the in-place write gets through while the swap does not. If the title or a tool keeps a mod's file open like that, the mod's saves start failing with a plain "Access is denied". No temp file is left, so it fails cleanly. It's still a change worth a line in the docs, or a clearer message.
  • Attributes and explicit ACLs reset to whatever the folder gives a new file. Probably fine for mod data, but it's a side effect of the swap.
  • The concurrent refusals look like a race in inside(). canonicalize opens the old file just as the rename replaces it, and the path it gets back is no longer under the mod's folder. Nothing gets out and nothing is left behind, but the message is misleading. One mod writing from one thread won't hit it. On the plus side, a reader never sees a half-written file now.
  • read_file is still open through a hard link. The PR body says that's out of scope on purpose. I'd keep #3212 open for it, or open a follow-up, rather than close it with this PR.

Read, not run: a crash between creating the temp file and the rename leaves a .leonida-write-<pid>-<n>.tmp in the mod's folder, and nothing cleans it up later. write_all failing halfway removes the temp. I couldn't make it fail on demand.

Conflicts: with #3125 and #3115 the conflicts are the same ones they already have with main (runtime.rs/sandbox.rs/docs and sandbox.rs/tests.rs). This PR adds none. #3189 and #3179 are merged.

Not checked: a real mod or mod manager in the game, file symlinks (they need Developer Mode), other filesystems (FAT32/exFAT, network shares), and a process killed mid-write.

GPUs tested: n/a (CPU-only tests).
AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7360098190 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3226#issuecomment-7360098190). Originally posted by [Kal0s-design](https://github.com/Kal0s-design) on 2026-12-02T22:00:44Z. --- Ran natively on Windows 11, head `ce5831530` merged into current `main` (`f3865cae8`, clean merge). I opened #3212, so I checked it on NTFS the same way I found it. The fix does what the issue asked for. A few things changed along with it, listed below. **Build first.** The merge is textually clean but the tests don't compile. #3179 made `Runtime::new` infallible, and the new test still calls `Runtime::new(...).unwrap()` (tests.rs, new test). `main` has the same problem in the #3189 test, which #3237 fixes. I dropped the two `.unwrap()` calls locally to run anything. After #3237 lands this PR still needs its own `.unwrap()` removed, or a rebase. **Tests** (`cargo test -p leonida-lua --lib --locked`, both with the `.unwrap()` fix) | | result | |---|---| | `main` | 46 passed, 0 failed | | merge | 47 passed, 0 failed | | merge with `api.rs` reverted to `main`, tests kept | 46 passed, 1 failed: `write_file_replaces_hard_link_without_changing_outside_file` (`left: "NESTED"`, `right: "KEEP"`) | clippy `--all-targets -D warnings`: clean. `cargo fmt --check`: two diffs in `api.rs`, both already on `main` (require and teleport), none from this PR. **Extra cases** (throwaway tests calling `write_file`/`read_file` directly, in a temp folder, same probes on `main` and on the merge). All measured. | case | `main` | this PR | |---|---|---| | hard link in mod folder to a file outside | outside file overwritten | outside unchanged, mod file has new content, link gone | | hard link, both names inside the folder | both names change | only the written name changes | | target open elsewhere, share R/W/D (Rust default) | ok | ok | | target open elsewhere, share R/W, no DELETE (C `fopen`, .NET `FileShare.ReadWrite`) | ok | **fails, `Access is denied (os error 5)`**, old content kept | | target open, share R only / none | fails, os error 32 | fails, os error 5 | | read-only target | fails, os error 5 | fails, os error 5, still read-only | | hidden attribute on target | kept | **lost** (0x22 -> 0x20) | | explicit ACE on target | kept | **lost** (file gets the folder's inherited ACL) | | target is a directory | fails, os error 5 | fails, os error 5 | | file under a junction to a folder inside the mod | ok | ok | | junction to a folder outside | refused | refused | | dangling junction (#3189), write under it and onto it | refused | refused | | 200-char name, single and nested | ok | ok (temp name is short and fixed, no overflow) | | 201-char name | refused | refused | | 2 threads x 500 writes of 64 KiB, same name | 0 errors | **1 to 3 spurious refusals per run**, "`c.txt` leads out of the mod's folder" (once "cannot be resolved", os error 2); final file whole | | `read_file` in a loop while another thread writes | 103 of 197 reads torn | 0 torn | | `.leonida-write-*.tmp` left behind | n/a | none in any case above, failures included | | `read_file` through a hard link to an outside file | returns outside content | **still returns outside content** | What I take from it: - The open-file row is the one I'd look at. A handle without `FILE_SHARE_DELETE` is common, and today the in-place write gets through while the swap does not. If the title or a tool keeps a mod's file open like that, the mod's saves start failing with a plain "Access is denied". No temp file is left, so it fails cleanly. It's still a change worth a line in the docs, or a clearer message. - Attributes and explicit ACLs reset to whatever the folder gives a new file. Probably fine for mod data, but it's a side effect of the swap. - The concurrent refusals look like a race in `inside()`. `canonicalize` opens the old file just as the rename replaces it, and the path it gets back is no longer under the mod's folder. Nothing gets out and nothing is left behind, but the message is misleading. One mod writing from one thread won't hit it. On the plus side, a reader never sees a half-written file now. - `read_file` is still open through a hard link. The PR body says that's out of scope on purpose. I'd keep #3212 open for it, or open a follow-up, rather than close it with this PR. Read, not run: a crash between creating the temp file and the rename leaves a `.leonida-write-<pid>-<n>.tmp` in the mod's folder, and nothing cleans it up later. `write_all` failing halfway removes the temp. I couldn't make it fail on demand. Conflicts: with #3125 and #3115 the conflicts are the same ones they already have with `main` (runtime.rs/sandbox.rs/docs and sandbox.rs/tests.rs). This PR adds none. #3189 and #3179 are merged. Not checked: a real mod or mod manager in the game, file symlinks (they need Developer Mode), other filesystems (FAT32/exFAT, network shares), and a process killed mid-write. GPUs tested: n/a (CPU-only tests). AI-assisted: yes (Claude Code).
lixonik commented 2026-12-02 22:48:22 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-02T22:48:22Z.


Thanks @fiestorra and @Kal0s-design for the thorough native Windows NTFS verification and edge-case matrix!

A few quick notes on your points:

  • Unstacked branch (@fiestorra): This PR has a single commit (ce5831530, touching only api.rs and tests.rs) branched from main at a51cda3aa -- #3204 and #3210 were already merged into main before a51cda3aa (they appeared only when diffed against an older local b41763227).
  • #3212 scope (@Kal0s-design): Updated the PR body from Fixes #3212 to Addresses #3212 so read_file hard links remain tracked separately as requested.
  • Runtime::new infallibility (#3179 / #3237) + @MoonEyes in-game gate: As soon as #3237 lands on main (fixing tests.rs:1089 on main), I will merge origin/main into this branch, drop the .unwrap() in write_file_replaces_hard_link_without_changing_outside_file, add a note on the FILE_SHARE_DELETE open-file behavior in write_replacing, and post the >= 300 s RTX 5070 in-game run report on the resulting head.

AI-assisted: yes (Antigravity -- Gemini 4 Neon).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7361184076 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3226#issuecomment-7361184076). Originally posted by [lixonik](https://github.com/lixonik) on 2026-12-02T22:48:22Z. --- Thanks @fiestorra and @Kal0s-design for the thorough native Windows NTFS verification and edge-case matrix! A few quick notes on your points: - **Unstacked branch (`@fiestorra`):** This PR has a single commit (`ce5831530`, touching only `api.rs` and `tests.rs`) branched from `main` at `a51cda3aa` -- `#3204` and `#3210` were already merged into `main` before `a51cda3aa` (they appeared only when diffed against an older local `b41763227`). - **`#3212` scope (`@Kal0s-design`):** Updated the PR body from `Fixes #3212` to `Addresses #3212` so `read_file` hard links remain tracked separately as requested. - **`Runtime::new` infallibility (`#3179` / `#3237`) + `@MoonEyes` in-game gate:** As soon as `#3237` lands on `main` (fixing `tests.rs:1089` on `main`), I will merge `origin/main` into this branch, drop the `.unwrap()` in `write_file_replaces_hard_link_without_changing_outside_file`, add a note on the `FILE_SHARE_DELETE` open-file behavior in `write_replacing`, and post the `>= 300 s` RTX 5070 in-game run report on the resulting head. AI-assisted: yes (Antigravity -- Gemini 4 Neon).
fiestorra commented 2026-12-02 23:09:20 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T23:09:20Z.


Taken on all three points.

  1. Branch shape: ce5831530 alone — confirmed, and I should have checked git log --first-parent before writing "unstacked" as a question. My apologies for the noise.
  2. Fixes → Addresses #3212: good call — read_file's hard links are still open, so the closing keyword would have been a lie.
  3. Runtime::new infallibility: I hit the same wall from the other side tonight and #3237 is the fix — on main (ef35d683e) cargo test -p leonida-lua does not compile (error[E0599]: no method named unwrap found for struct Runtime, tests.rs:1089), and #3237's head (2a5338d79) is 46 passed, 0 failed. I verified it and asked for it to be merged first in #2570; every PR's d3d12 (windows-latest) is red at Build until it lands, so your in-game gate is waiting on it too.

Once #3237 is in, this one can be read by CI like any other.

Written with an AI assistant.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7361632993 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3226#issuecomment-7361632993). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-02T23:09:20Z. --- **Taken on all three points.** 1. **Branch shape**: `ce5831530` alone — **confirmed**, and I should have checked `git log --first-parent` before writing "unstacked" as a question. My apologies for the noise. 2. **`Fixes` → `Addresses #3212`**: good call — `read_file`'s hard links are still open, so the closing keyword would have been a lie. 3. **`Runtime::new` infallibility**: **I hit the same wall from the other side tonight and #3237 is the fix** — on `main` (`ef35d683e`) `cargo test -p leonida-lua` does not compile (`error[E0599]: no method named unwrap found for struct Runtime`, `tests.rs:1089`), and **#3237's head (`2a5338d79`) is 46 passed, 0 failed**. I verified it and asked for it to be merged first in #2570; **every PR's `d3d12 (windows-latest)` is red at Build until it lands**, so your in-game gate is waiting on it too. Once #3237 is in, this one can be read by CI like any other. Written with an AI assistant.
lixonik commented 2026-12-03 02:38:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-03T02:38:58Z.


@MoonEyes @Kal0s-design Updated against current main (d15e048a7, which includes #3179, #3189, and #3244) in 3325f8602:

  • Removed .unwrap() on Runtime::new(...) in write_file_replaces_hard_link_without_changing_outside_file.
  • Documented the Windows FILE_SHARE_DELETE open-handle behavior in write_replacing.

Build & Unit Checks (Windows 10 x64, RTX 5070 12 GB, driver 595.79)

  • python -I scripts/check_no_game_data.py -> PASS
  • cargo test -p leonida-lua --lib --locked -> 48 passed, 0 failed
  • cargo clippy -p leonida-lua --all-targets --locked -- -D warnings -> 0 warnings
  • cargo build --profile diag --features "diagnostics,dlss,mimalloc" --locked -> PASS

RUN (in game, RTX 5070 12 GB, 315 s in-world gate) -- PASS

  • Head / base: 3325f8602 (merged origin/main d15e048a7)
  • GPU / Driver / OS: NVIDIA GeForce RTX 5070 (12 GB), driver 595.79, Windows 10 x64
  • Profile: -SeriesS -NoFrameGen, same restored save snapshot
Run Time in world (total) World samples (max draws) Device lost / crashes / errors Median FPS (ms) Slowest / fastest tenth (fps)
PR #3226 (3325f8602 on d15e048a7) 315 s (491.5 s) 64 (5,525) 0 / 0 / 0 28.2 fps (35.4 ms) 22.7 / 29.5
Reference main (8877be372, same profile) 315 s (441.9 s) 63 (4,338) 0 / 0 / 0 27.9 fps (35.8 ms) 26.1 / 29.6

AI-assisted: Antigravity (Gemini 4 Neon; separate read-only reviewer subagent: Antigravity Pro preset / Gemini Pro).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7365704544 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3226#issuecomment-7365704544). Originally posted by [lixonik](https://github.com/lixonik) on 2026-12-03T02:38:58Z. --- @MoonEyes @Kal0s-design Updated against current `main` (`d15e048a7`, which includes #3179, #3189, and #3244) in `3325f8602`: - Removed `.unwrap()` on `Runtime::new(...)` in `write_file_replaces_hard_link_without_changing_outside_file`. - Documented the Windows `FILE_SHARE_DELETE` open-handle behavior in `write_replacing`. ### Build & Unit Checks (Windows 10 x64, RTX 5070 12 GB, driver 595.79) - `python -I scripts/check_no_game_data.py` -> **PASS** - `cargo test -p leonida-lua --lib --locked` -> **48 passed, 0 failed** - `cargo clippy -p leonida-lua --all-targets --locked -- -D warnings` -> **0 warnings** - `cargo build --profile diag --features "diagnostics,dlss,mimalloc" --locked` -> **PASS** ### **RUN (in game, RTX 5070 12 GB, 315 s in-world gate) -- PASS** - **Head / base:** `3325f8602` (merged `origin/main` `d15e048a7`) - **GPU / Driver / OS:** NVIDIA GeForce RTX 5070 (12 GB), driver 595.79, Windows 10 x64 - **Profile:** `-SeriesS -NoFrameGen`, same restored save snapshot | Run | Time in world (total) | World samples (max draws) | Device lost / crashes / errors | Median FPS (ms) | Slowest / fastest tenth (fps) | | --- | ---: | ---: | ---: | ---: | ---: | | **PR #3226 (`3325f8602` on `d15e048a7`)** | `315 s` (`491.5 s`) | `64` (`5,525`) | **`0` / `0` / `0`** | **`28.2 fps`** (`35.4 ms`) | `22.7` / `29.5` | | **Reference `main` (`8877be372`, same profile)** | `315 s` (`441.9 s`) | `63` (`4,338`) | **`0` / `0` / `0`** | **`27.9 fps`** (`35.8 ms`) | `26.1` / `29.6` | AI-assisted: Antigravity (Gemini 4 Neon; separate read-only reviewer subagent: Antigravity Pro preset / Gemini Pro).
lixonik commented 2026-12-03 14:40:00 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-03T14:40:00Z.


Merged origin/main (128579e9e) cleanly into 0feb48c11 to re-trigger CI after the earlier linux-python-and-viewer job was cancelled (zero changes to leonida-lua vs 3325f8602; same 2 files changed, 104 insertions(+), 1 deletion(-) diff against origin/main).

Local verification (0feb48c11)

  • python -I scripts/check_no_game_data.py -> PASS
  • cargo test -p leonida-lua --lib --locked -> 48 passed, 0 failed
  • cargo clippy -p leonida-lua --all-targets --locked -- -D warnings -> 0 warnings

AI-assisted: yes (Antigravity -- Gemini 4 Neon).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7381826928 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3226#issuecomment-7381826928). Originally posted by [lixonik](https://github.com/lixonik) on 2026-12-03T14:40:00Z. --- Merged `origin/main` (`128579e9e`) cleanly into `0feb48c11` to re-trigger CI after the earlier `linux-python-and-viewer` job was cancelled (zero changes to `leonida-lua` vs `3325f8602`; same `2 files changed, 104 insertions(+), 1 deletion(-)` diff against `origin/main`). ### Local verification (`0feb48c11`) - `python -I scripts/check_no_game_data.py` -> **PASS** - `cargo test -p leonida-lua --lib --locked` -> **48 passed, 0 failed** - `cargo clippy -p leonida-lua --all-targets --locked -- -D warnings` -> **0 warnings** AI-assisted: yes (Antigravity -- Gemini 4 Neon).
MoonEyes commented 2026-12-03 16:18:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-03T16:18:31Z.


In-game gate run on an RTX 4060 8 GB (driver 610.88, Windows 11), in a batch of #3132, #3200 and #3226 merged into main d227aa73e; this PR tested at its current head 0feb48c11. Series S 1080, DLSS FG 2x, play-nvidia.ps1 -SeriesS -Resolution 1080 -FrameGen 2 -PrecompileUsed, scripted walk, 330 s.

  • Result: PASS. No device lost, no crash, no unhandled exception; the run ended on its time limit.
  • Median over the last 240 s: 17.2 fps (main alone today: 16-17.5); 15.7 frames per 1000 over 100 ms.
  • Covered: a normal launch and walk with this PR's code in the build. It does not isolate this PR's own change from the two others in the batch.

AI-assisted (Claude Opus 5.5), run and read by MoonEyes' agent.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7384619615 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3226#issuecomment-7384619615). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-03T16:18:31Z. --- In-game gate run on an RTX 4060 8 GB (driver 610.88, Windows 11), in a batch of #3132, #3200 and #3226 merged into main `d227aa73e`; this PR tested at its current head `0feb48c11`. Series S 1080, DLSS FG 2x, `play-nvidia.ps1 -SeriesS -Resolution 1080 -FrameGen 2 -PrecompileUsed`, scripted walk, 330 s. - Result: **PASS**. No device lost, no crash, no unhandled exception; the run ended on its time limit. - Median over the last 240 s: 17.2 fps (main alone today: 16-17.5); 15.7 frames per 1000 over 100 ms. - Covered: a normal launch and walk with this PR's code in the build. It does not isolate this PR's own change from the two others in the batch. AI-assisted (Claude Opus 5.5), run and read by MoonEyes' agent.
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/3226:upstream-pr/3226'
git switch 'upstream-pr/3226'

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/3226'
git switch 'upstream-pr/3226'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3226'
git switch 'upstream-pr/3226'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3226'
git switch 'main'
git merge --squash 'upstream-pr/3226'
git switch 'main'
git merge --ff-only 'upstream-pr/3226'
git switch 'main'
git merge 'upstream-pr/3226'
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
ProjectLeonida/mandy!3226
No description provided.