Skip to content

Write author-owned payload files through a staging file - #103

Merged
sambvfx merged 1 commit into
NVIDIAGameWorks:mainfrom
sambvfx:staged-author-payload-copy
Nov 20, 2026
Merged

sambvfx merged 1 commit into
NVIDIAGameWorks:mainfrom
sambvfx:staged-author-payload-copy

Conversation

@sambvfx

@sambvfx sambvfx commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

An interrupted write of an author-owned payload file could leave a partial file that every later launch kept as an author's edit.

DirectoryRuntimePayload.extractAuthorTree streamed each bundled file straight onto its live path. A copy that failed partway left a partial file there, and a partial file matches no shipped version, so the hash check that protects edits kept it. An unedited lighting profile could stay half-written for good without anyone having edited it. The first write of a missing file had the same hole.

Changes

  • Staged writes. Each author-owned file is copied to <name>.staging beside its target, flushed to disk, and moved into place only once the copy is complete. A failed copy or move leaves the previous live file as it was and removes the staging file, so the next launch still sees an unedited default and replaces it.
  • The flush. It covers a power loss or a system crash. Without it the move can reach the disk before the bytes it moved, and the file comes back empty or zeroed, which is kept as an edit like any other partial file.
  • The move. It is atomic where the file system supports it, and it retries like the other renames the extraction commits with.
  • Cleanup. A failed write removes its one staging file and never a folder's contents, because the tree is author-owned.
  • The SDK tree keeps its direct copy. It is written into remix-sdk.staging/, which a retry deletes and rebuilds and which replaces the live SDK only after every copy succeeds.

Testing

  • DirectoryRuntimePayloadTest opens the bundled file through a stream that fails after half its bytes and checks, for an update and for a first write, that the live file is unchanged, no staging file remains, a retry writes the file, and an author's edit beside it is kept.
  • Both tests fail against the direct copy: the live file holds the first half of the new default.
  • A third test holds the live file open so the move fails on every retry, and checks the same things. It fails when the move sits outside the cleanup.
  • A fourth puts a folder on the staging path and checks that a failed write deletes nothing inside it. It fails against a recursive cleanup.
  • gradlew build test passes for each 1.21.1 loader with 0 failures: Fabric 912 JVM tests, Forge 892, NeoForge 886.
  • Not fault-injected in a running game, and no test shows that the flush reached the disk.

Fixes #95

🤖 Generated with Claude Code

@sambvfx
sambvfx force-pushed the staged-author-payload-copy branch from 8b9495e to 777ba09 Compare November 18, 2026 21:46
@nv-ajaus nv-ajaus assigned nv-ajaus and unassigned nv-ajaus Nov 19, 2026
@sambvfx
sambvfx force-pushed the staged-author-payload-copy branch from 777ba09 to 65569ea Compare November 19, 2026 00:27
`DirectoryRuntimePayload.extractAuthorTree` streamed each bundled file
straight onto its live path. A copy that failed partway left a partial
file there, and a partial file matches no shipped version, so every
later launch kept it as an author's edit. An unedited lighting profile
could stay half-written for good without anyone having edited it. The
first write of a missing file had the same hole.

Each author-owned file is now copied to `<name>.staging` beside its
target, flushed to disk, and moved into place only once the copy is
complete. The move is atomic where the file system supports it, and it
retries like the other renames the extraction commits with. A failed
copy or move leaves the previous live file as it was and removes the
staging file, and only that one file, so the next launch still sees an
unedited default and replaces it.

The flush covers a power loss or a system crash. Without it the move
can reach the disk before the bytes it moved, and the file comes back
empty or zeroed, which is kept as an edit like any other partial file.

The SDK tree keeps its direct copy. It is written into
`remix-sdk.staging/`, which a retry deletes and rebuilds and which
replaces the live SDK only after every copy succeeds.

## Testing

- `DirectoryRuntimePayloadTest` opens the bundled file through a stream
  that fails after half its bytes and checks, for an update and for a
  first write, that the live file is unchanged, no staging file remains,
  a retry writes the file, and an author's edit beside it is kept.
- Both tests fail against the direct copy: the live file holds the
  first half of the new default.
- A third test holds the live file open so the move fails on every
  retry, and checks the same things. It fails when the move sits
  outside the cleanup.
- A fourth puts a folder on the staging path and checks that a failed
  write deletes nothing inside it. It fails against a recursive cleanup.
- `gradlew build test` passes for each 1.21.1 loader with 0 failures:
  Fabric 912 JVM tests, Forge 892, NeoForge 886.
- Not fault-injected in a running game, and no test shows that the
  flush reached the disk.

Fixes NVIDIAGameWorks#95

Signed-off-by: Sam Bourne <sbourne@nvidia.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@sambvfx
sambvfx force-pushed the staged-author-payload-copy branch from 65569ea to ed911be Compare November 20, 2026 02:00
@sambvfx
sambvfx merged commit f53915e into NVIDIAGameWorks:main Nov 20, 2026
11 checks passed
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.

Interrupted shipped-profile updates can preserve a partial file as an author edit

2 participants