Repository navigation
feat: US-003 - Poll and diff the external save file while the game runs (pure watch core + 5s monitor) - #8
Merged
Merged
Conversation
Domain (pure, tested): ExternalSaveWatch decides each poll from injected SaveFileStamp reads - NoChange / PendingStable / ChangedStable / Missing - with a two-identical-reads debounce so a partial flush mid-write is never parsed. ExternalSavePublish gates publication: a null candidate (failed parse) never replaces the last good snapshot. Reset() per session. Contract: IGameCompanionStore gains External + UpdateExternal + ClearExternal; GameCompanionStore implements them (Stop clears External too). App: ExternalSaveMonitor (registered in MauiProgram) polls the resolved save path (US-002 resolver) with a PeriodicTimer every 5 s, only while a session runs (Start/Stop - never polls otherwise). Each poll: FileInfo stat -> pure watch decision -> ISaveEngine.Validate before OpenSession -> ExternalCompanionSnapshotFactory.FromSession (US-001) -> UpdateExternal on the UI thread. Every I/O step is guarded: stat/read/parse failure keeps the last good snapshot, never crashes. 11 new Domain tests (debounce sequences, size-only/mtime-only changes, disappear/reappear, reset, publish gate). prd.json: US-003 passes=true. progress.txt: appended learnings (stamp-injection pattern, anti-partial-flush debounce, PeriodicTimer disposal throws ObjectDisposedException). Co-authored-by: Varonal <Varonal@users.noreply.github.com>
…o-save mode) The Missing decision must also forget the published stamp: the companion shows 'no save yet' instead of a stale snapshot when the emulator deletes the file. Co-authored-by: Varonal <Varonal@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary (US-003)
Domain (pure decision core, unit-tested) —
src/PKForge.Domain/ExternalSaveWatch.cs:SaveFileStamp(Path, Length, LastWriteUtc)+ExternalSaveWatch.Poll(stamp?)→NoChange / PendingStable / ChangedStable / Missing, with a two-identical-reads debounce: a changed file must read identical twice before it is parsed, so a partial flush mid-write is never parsed.Reset()per session.ExternalSavePublish.ShouldPublish(...)— a null candidate (failed parse) never replaces the last good snapshot.Contract —
IGameCompanionStoregainsExternal,UpdateExternal(...),ClearExternal();GameCompanionStoreimplements them,Stop()clearsExternaltoo.App —
ExternalSaveMonitor(new service, registered inMauiProgram):PeriodicTimerevery 5 s, running only betweenStart(romPath, emulator, label)andStop()(never polls without an external session). Each poll: resolve path (US-002) →FileInfostat → pure watch decision →ISaveEngine.ValidatebeforeOpenSession→ExternalCompanionSnapshotFactory.FromSession(US-001) →UpdateExternalon the UI thread. Every I/O step guarded: failure keeps the last good snapshot, never crashes.ObjectDisposedExceptionfrom timer disposal is swallowed as a normal stop.Tests: 11 new xunit tests (debounce sequences, size-only/mtime-only changes, disappear/reappear, reset, publish gate).
prd.json: US-003passes: true.progress.txt: appended learnings.Verification
dotnet test tests/PKForge.Domain.Tests -c Release+dotnet build src/PKForge.App -f net10.0-android.