Skip to content

chore(saves): remove conflict_mode and clock_skew_tolerance_sec#265

Merged
danielcopper merged 5 commits intomainfrom
chore/258-remove-legacy-settings
May 6, 2026
Merged

chore(saves): remove conflict_mode and clock_skew_tolerance_sec#265
danielcopper merged 5 commits intomainfrom
chore/258-remove-legacy-settings

Conversation

@danielcopper
Copy link
Copy Markdown
Owner

@danielcopper danielcopper commented May 6, 2026

Summary

PR 2 of 2 for #258 (post-0.16 save sync polish). Removes the two legacy settings end-to-end: conflict_mode and clock_skew_tolerance_sec. Both were leftovers from before the 0.16 newest-wins matrix sync rewrite; the wiki had already pre-announced their removal in Save-Sync.md, and the actual domain/save_conflicts.resolve_conflict_by_mode consumer was deleted in PR1 (#264).

  • conflict_mode — removed from model, persistence, sanitize/allowlist, TS type, Settings UI dropdown, and launchInterceptor.ts. Behaviour change: the launch interceptor now always checks for conflicts and blocks launch when one is detected (previously only in "ask_me" mode). Users who had it set to newest_wins / always_upload / always_download will now see the conflict modal — but those modes never actually did anything in the matrix sync model post-0.16, so this catches the implementation up to the documented behaviour.
  • clock_skew_tolerance_sec — removed from model, persistence, TS type. Pure cleanup: zero consumers after PR1.
  • Migration strip_migrate_loaded_state now silently strips both legacy keys from loaded state. load_state does dict.update on the settings block, so orphan keys would otherwise survive forever. After the first load+save post-merge, on-disk state files are clean. Tests pin the strip behaviour and the defensive isinstance(settings, dict) guard (covers missing-key and non-dict edge cases).
  • WikiSave-Sync.md "When saves conflict" section + screenshot caption updated; Save-File-Sync-Architecture.md "Legacy field migration" extended to document the new strips, "Settings fields not driving behaviour" paragraph removed.

Closes #258.

Test plan

  • CI green: pytest, ruff, ruff format, basedpyright, lint-imports, pnpm build
  • Manual: Settings page renders without the conflict-mode dropdown; no console errors
  • Manual: trigger a real two-sided conflict, confirm modal blocks Play regardless of any prior conflict_mode setting
  • Manual: load a state file containing conflict_mode / clock_skew_tolerance_sec, trigger a save, confirm both keys are gone from the on-disk JSON

The 0.16 newest-wins matrix sync rewrite removed the only meaningful
consumer of conflict_mode (resolve_conflict_by_mode in domain/save_conflicts,
deleted in #264). The remaining frontend gate kept the launch-time conflict
check optional; that check should always run, so drop the setting end-to-end
and let the interceptor block launches whenever a save conflict is pending.
The only consumer (resolve_conflict_by_mode in domain/save_conflicts) was
deleted with the 0.16 newest-wins matrix sync rewrite (#264). Drop the
setting from the dataclass, defaults, sanitiser, and frontend type.
load_state merges persisted settings via dict.update, so old state files
keep removed keys (conflict_mode, clock_skew_tolerance_sec) forever. Pop
them in _migrate_loaded_state so the next save_state writes a clean file.
- Drop the throwaway empty-dict fallback from the legacy settings
  strip in `_migrate_loaded_state`; missing/non-dict settings now
  cleanly fall through the `isinstance` guard.
- Pin the defensive guard with two tests: missing `settings` key
  and non-dict `settings` value.
Extract the saves-block migration and the legacy-settings strip into
private helpers (_migrate_saves_entries, _strip_legacy_settings).
_migrate_loaded_state becomes a thin dispatcher. Cognitive complexity
22 -> below threshold (Sonar python:S3776).
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 6, 2026

@danielcopper danielcopper merged commit be441cc into main May 6, 2026
9 checks passed
@danielcopper danielcopper deleted the chore/258-remove-legacy-settings branch May 6, 2026 19:10
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.

polish(saves): 0.16 save sync follow-ups (modal, encoding, dead code)

1 participant