Make Stored in-memory-only and add GraphUserDefault#110
Draft
muukii wants to merge 4 commits into
Draft
Conversation
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
Storeda final, in-memory-only graph primitiveStorageabstraction and the@GraphStored(backed:)syntax@GraphUserDefaultas a reference-identity UserDefaults synchronization owner composed around an internalStoredMotivation
Storedis the graph's primitive mutation boundary. Making external persistence replace its value storage mixed graph behavior with Foundation cache, observer, and lifecycle concerns, and required generic lock hand-offs inside the source node.This change inverts that dependency:
Storedalways owns its value in memory, whileGraphUserDefaultis a separate model that owns UserDefaults synchronization and delegates graph behavior to an internalStorednode.GraphUserDefaultis afinal class, and its projected value returns the same instance. Retaining$propertytherefore retains the observer and synchronization lifecycle, while writes through the projection follow the same persistence path as writes through the wrapped property.Breaking changes
Storage,InMemoryStorage,UserDefaultsStorage,_Stored,UserDefaultsStored, andGraphStorageBacking@GraphStored(backed:)overload;@GraphStoredis now always in-memory@GraphUserDefault("key")Stored<Value>toGraphUserDefault<Value>No compatibility layer is included intentionally.
Concurrency and lifecycle
UserDefaultsAccessCoordinatorserializes UserDefaults reads and writes across value types and store instancesStoredpublishes dependency invalidation and callbacks only after releasing its node lockGraphUserDefaultowns its observer token and removes it when the final projected or wrapper reference is releasedValidation
swift test --filter GraphUserDefaultTests(16 tests passed)swift test(17 XCTest tests and 147 Swift Testing tests passed)git diff --checkbuild-developmentpassedpackage-testpassed the complete@GraphUserDefaultsuite, but the job remains red after one rerun because four unchanged tests time out with the same eight issues already present on currentmainThe matching failures are
concurrentInvocationsAreSerializedAndCoalesced,readWaitsForCoordinatedMutation,sharedCoordinatorBlocksReadsAcrossStores, andstuckMain. They occur in both the PR run and the current main run.