Introduce JSONFileStore and retire copy-pasted settings / wizard / history writers
#81
Closed
opened 2026-09-10 18:23:12 +01:00 by gronod
·
1 comment
No Branch/Tag Specified
main
docs/27-roadmap-candidates
develop
milestone/m13-print-ticket
feat/218-paper-source
feat/217-panel-ticket-restore
bugfix/211-print-output-flip
milestone/m12-native-spool
feat/202-airprint-detection
feat/201-native-print-operation
feat/201-raster-canvas
feat/201-ticket-capture
feat/201-pm-ticket-bridge
chore/m11-sync-develop
milestone/m11-print-settings
chore/m11-docs-hygiene
feat/186-panel-binding
feat/181-canon-media-locale
feat/180-epson-qual-options
feat/183-stage2-print-settings
chore/m11-tracking
docs/ui-interactive-map
v2.0.4-prerelease-docs27
v2.0.4
v2.0.3
v2.0.3-prerelease
v2.0.2
v2.0.1
v2.0.0
Labels
Clear labels
Bug/Architecture
Bug/Backend
Bug/DevOps
Bug/UI
Compat/Breaking
Feature/Architecture
Feature/Backend
Feature/DevOps
Feature/UI
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Project/ICCery-v2
Core / wizard / process infra defect
Argyll orchestration, file/data defect
Build, packaging, CI defect
Views, controls, dialogs defect
Breaking change that won't be backward compatible
Core / wizard / process infra
Argyll orchestration, file/data engines
Build, packaging, CI
Views, controls, dialogs
Something is not working
Documentation changes
Improve existing functionality
New functionality
This is security issue
Issue or pull request related to testing
Priority
Critical
1
The priority is critical
Priority
High
2
The priority is high
Priority
Low
4
The priority is low
Priority
Medium
3
The priority is medium
ICCery v2 Mac rewrite
Reviewed
Confirmed
1
Issue has been confirmed
Reviewed
Duplicate
2
This issue or pull request already exists
Reviewed
Invalid
3
Invalid issue
Reviewed
Won't Fix
3
This issue won't be fixed
Status
Abandoned
3
Somebody has started to work on this but abandoned work
Status
Blocked
1
Something is blocking this issue or pull request
Status
Need More Info
2
Feedback is required to reproduce issue or to continue work
Milestone
No items
No Milestone
M7 — Deduplicate & consolidate (develop)
Projects
Clear projects
No projects
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: gronod/iccery-v2-mac#81
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
SettingsStore,WizardStateStore, andVerificationHistoryStoreeach build a pretty-printed, sorted-keysJSONEncoderand write viaAtomicFileWriter. Load policy differs (defaults vs throw) and must stay different.Spec refs
wizard_state.json,settings.json)verification_history.json— never overwrite unreadable files)Packages/ICCeryCore/Sources/ICCeryCore/Files/AtomicFileWriter.swiftScope
In
New
Packages/ICCeryCore/Sources/ICCeryCore/Files/JSONFileStore.swift:Shared encoder flags:
[.prettyPrinted, .sortedKeys]. Date strategy parameterized (history uses ISO-8601; settings/wizard do not encode dates today).Rewire:
SettingsStore.load/save—corrupt: .replaceWithDefault, default.default. Keepvalidate()before save andsettingsDidChangenotification after successful save.WizardStateStore.load/save— same policy, default.default.VerificationHistoryStore—corrupt: .throwCorrupt.load()still hydrates the in-memory cache;append/clearstill refuse to write if load throws. Capacity trim stays in the actor.PresetStore.exportmay use the same encoder helper (encodePretty(_:)) but stays a single-preset blob, not a file store.Out
Full solution
SettingsStoreis referenced byAppEnvironment, UI tests, settings dialog). Do not force view models to talk toJSONFileStoredirectly.JSONFileStore.savemust callAtomicFileWriter.write.AtomicFileWriter/AppPaths— do not duplicatecreateDirectory.Rewrite invariants
settings.json/wizard_state.json→ defaults, never crash launch.verification_history.json→ throw, leave file intact (issue 26).SettingsStore.savestill throwsSettingsError.validationFailedand writes nothing.Dependencies
Blocks-on: none.
Unblocks: none required. Safe to land in parallel with the runner ticket.
Test
Tests/ICCeryCoreTests/SettingsTests.swift:.defaultWizardGatingTests/ settings tests — addWizardStateStoreTestsif missing):.defaultcalibrationOriginalBasename/sessionModeVerificationHistoryStoreTests.swift:loadthrows and a subsequentappendalso throws without replacing the fileJSONFileStoreTests.swiftwith a temp directory covering both policies.Acceptance criteria
Implementation originally landed in stacked commit
d4261bavia PR #87.Completion/verification landed in PR #97 at
12584d1.Acceptance evidence:
[x] Centralised JSONEncoder pretty/sorted configuration in JSONFileStore.
[x] VerificationHistoryStore.clear() preserves corrupt history files on load failure.
[x] Preserved .replaceWithDefault for settings/wizard and .throwCorrupt for history.
[x] Lexical key sorting and ISO-8601 history timestamps verified.
Verification at milestone/m8-consolidation
891a504ee7:targeted suites: passed (25 tests)
full universal ICCeryCoreTests: 339 passed, 0 failed
full ICCeryUITests: 29 passed, 0 failed
Closing manually after code and tests are present on the milestone branch.