Notice when Steam updated a game's install, and protect the version the player switched to #250
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
ethan-hann/SavePoint#250
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Second part of #243 (the first part, in 0.9.20, makes sure Steam is running before a Steam game starts from its program, and never starts a game through Steam's own launch path). Research: .han/out/research-243-drm-launch.md (kept locally), option O5.
Steam can still update an install on its own while it runs, which would overwrite a version the player switched to. Record the Steam manifest's buildid, TargetBuildID, StateFlags and LastUpdated (appmanifest_.acf, read only: D56.5 forbids writing store files) before a launch; warn before starting a Steam game that has an update waiting; and when both the install and the manifest changed during play, withhold the after-play choices that capture the install, offer a saves-only snapshot, and offer to put the player's version back. Gate the approach on the hand test the research names: an older install with an update pending, started from its program and through Steam, plus a cold Steam start, on Windows and on the Linux VM.
Design proposal (research only, nothing built)
What exists already (0.9.20, D67.4)
SteamInstallState(src/Savepoint.Core/Launch/SteamInstallState.cs) readsbuildid,LastUpdatedandStateFlagsfromappmanifest_<id>.acf, read-only.LaunchOrchestrator.Steam.csreads it before Steam starts, again once Steam is ready (RefuseBeforeSwitchWhenSteamUpdatesAsync) and again just before the program starts (RefuseWhenSteamUpdatesAsync). So the "before play" protection is built. What is missing is everything after the program starts: nothing keeps the ready-time reading,DescribeExitAsyncnever reads the manifest, andSessionState.Exitedonly knowsChangedInstallFileCount.Two gaps in the existing reader:
TargetBuildIDis not read, andIsUpdatingleaves out Validating (131072) and Update Stopping (8388608), although D67.4 says validation refuses.The flag bits
No Valve document lists them. Three independent readers agree on the bit table: Lutris appmanifest.py, steamlocate app.rs (bits 13 to 15 unused, which matches the code's mask), and LaunchBox's note (4 installed, 6 update required). Bits: 1 Uninstalled, 2 Update Required, 4 Fully Installed, 8 Encrypted, 16 Locked, 32 Files Missing, 64 App Running, 128 Files Corrupt, 256 Update Running, 512 Update Paused, 1024 Update Started, 2048 Uninstalling, 4096 Backup Running, 65536 Reconfiguring, 131072 Validating, 262144 Adding Files, 524288 Preallocating, 1048576 Downloading, 2097152 Staging, 4194304 Committing, 8388608 Update Stopping.
So: update waiting = bit 2 set, or
TargetBuildIDpresent and not equal tobuildid(LibraryFixtureshas real examples: 518 paused update, 22 locked). Update running = the work bits the code already masks, plus 131072 and 8388608. Update happened =buildidorLastUpdatedchanged since the reading taken at launch.What to read and when
TargetBuildIDandUpdateRequiredtoSteamInstallState. Widen the running mask by the two bits above.SessionBookrecord, next toStarts.DescribeExitAsync, and once more inCompleteSessionAsyncbefore a capture starts, since Steam applies a queued update as soon as the game quits.ReadSteamInstallAsyncgoes throughSteamGames.NeedsClient, which is false for Through Steam, and that is exactly the path where updates happen. The D67 refusals stay exe-only; only the record-and-compare widens.Player-facing flow
Before play.
LaunchPreviewgets aSteamUpdateWaitingnote besideSteamNeeded: "Steam has an update waiting for this game. If the game asks Steam to start it, Steam installs the update first and replaces the version you switched to. SavePoint will tell you after you play." For Through Steam: "Steam will install its update before the game starts." A note, not a refusal: the player may want the update.During play. Nothing new; D67 covers the window up to the program start.
After play.
SessionState.Exitedgains aSteamUpdatedflag, true only when the manifest changed since the ready-time reading andChangedInstallFileCountis above 0 (the install diff is the ground truth; the manifest says why). Then:DiscardChangesAsync(gameId, RepoRole.Install), which already restores the install to the snapshot the launch loaded; no new git work). Not now stays.What SavePoint cannot prevent
It never writes store files (D56.5), so it cannot stop Steam. It cannot protect a game that restarts itself through Steam, a Through Steam launch, or a Proton game on Linux; for those the promise is: told before, told after, never snapshotted as yours, and one click back. A background download that Steam applies after the exit reading and before the capture is caught by the re-read before capture. Steam does not update a running game, so the install diff is stable while the game runs.
Options
Hand test before building
On Windows and the Linux VM, with a game Steam has updated: switch to the older snapshot, confirm the manifest still names the newer
buildid, then (a) run the exe with Steam open, (b) start Through Steam, (c) close Steam and start it cold before any launch. Repeat with an update genuinely waiting (flags 6 or 518). Record flags,buildid,TargetBuildID,LastUpdated, and whether the files changed. If (b) leaves an older install alone, part of this design shrinks and Through Steam becomes safe; if (c) rewrites files, D67's ordering is confirmed. Also one restart-class game and Balatro.Open questions before building
buildidon each snapshot as a second version line ("Steam build 180836") beside the detected version, or keep the Version column as it is? This is the 7.06 versus 180836 question; a separate issue either way.autoUpdatein Galaxy's settings), or Steam only for 1.0?Rough size
Core: 4 to 6 files (
SteamInstallState,SessionBook, the session, complete and preview parts ofLaunchOrchestrator, two new completion choices with their plans), 1 to 2 days with tests fromLibraryFixturesmanifests. App: dialog cards, preview note, catalog keys, half a day. Docs and decision entry, half a day. Hand tests, one evening per OS, and they come first. Total about 3 to 4 days plus the hand tests.