Skip to content

fix(persistence): loadOrCreate swallows fetch failures — completed-game re-view can show a virgin 0:00 snapshot #830

Closed

Description

@wei18

What

SavedGameStore.loadOrCreate (Packages/PersistenceKit/Sources/Persistence/Live/SavedGameStore.swift:101-137) swallows any gateway.fetch failure into "treat as no existing record" — it cannot distinguish confirmed-no-record from fetch-failed, existence unknown. Callers that use it to re-open a completed game (Sudoku's completed-card re-view, and since #826 the past-day strip taps) therefore render a virgin snapshot — .completion(elapsedSeconds: 0, mistakeCount: 0), i.e. "0:00, 0 mistakes" — for a legitimately-completed game whose record simply failed to fetch (transient CK error, cold cache).

Scope notes

Fix direction (evaluate)

Make loadOrCreate (or a sibling loadIfExists) surface the tri-state: record / no-record / fetch-failed. Completed-game re-open callers should treat fetch-failed like the thrown path (fall back to .board or show a transient error), never a virgin snapshot. Audit other loadOrCreate callers for whether swallow-to-create is actually the semantics they want (for RESUME it probably is; for re-view it isn't).

Acceptance sketch

  • A gated/failing gateway fetch on a completed-game re-open never shows 0:00/0-mistakes; it falls back per the thrown-path contract
  • Resume-path behavior unchanged
  • Deterministic test at the store level for the tri-state

Surfaced by the #826 adversarial code review (2026-07-16).

Activity

  1. added
    bug
    on Jul 16, 2026
  2. wei18 commented on Jul 16, 2026

    @wei18
    OwnerAuthor

    🔒 Claiming — session 064a54f6 (Leader) dispatching implementation. Direction: tri-state at the store level (record / confirmed-no-record / fetch-failed); completed-game re-view callers treat fetch-failed like the thrown path (#379 .board fallback), resume-path semantics unchanged.

  3. added 2 commits that reference this issue on Jul 16, 2026
    02fc0f4
    64d77c6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions