Add FrozenChildObservationTests: live-vs-frozen observation contract#27
Merged
Merged
Conversation
Characterises why a non-live @model value silently fails to drive a SwiftUI view — the mechanism behind the "sub-view stuck at a child's birth state" symptom whose framework fix (optional/container same-id unanchored child) landed in #26. - A child read out of a live parent is itself live (context != nil, lifetime == .active) and tracks subsequent mutations — the normal read path never hands a frozen copy to a sub-view. - A frozen copy (same modelID, no context) does NOT participate in Apple's withObservationTracking (the iOS 17+ registrar path SwiftUI uses), so a view holding one never re-renders. Hence a non-live value must never reach an @ObservedModel. - Also covers reading per-instance identity via the public `modelID` (added in #26) when an explicit domain `id` shadows Identifiable.id. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…bservation-tests # Conflicts: # CHANGELOG.md
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
Follow-up to #26 (merged), which fixed the optional/container same-
idunanchored-child bug and exposedpublic var Model.modelID. This PR adds the regression/characterisation tests for the underlying observation contract — the why behind the "SwiftUI sub-view stuck at a child's birth state" field symptom. Tests only; no source changes.FrozenChildObservationTestspins down:context != nil,lifetime == .active) and tracks subsequent mutations — the normal read path never hands a frozen copy to a sub-view.modelID,context == nil) silently does not participate in Apple'swithObservationTracking— the iOS 17+ registrar path SwiftUI drives invalidation through — so a view holding one never re-renders. This is the precise mechanism that makes a non-live value render birth state forever, and the reason such a value must never reach an@ObservedModel.modelID(added in Fix unanchored optional/container child on same-id replace; expose modelID #26) distinguishes two distinct instances that reuse the same explicit domainid(whereIdentifiable.idalone cannot).Validation
scripts/test --filter SwiftModelTests.FrozenChildObservationTests— all 4 tests pass against currentmain(post-#26). No source changes, so no behavior risk.🤖 Generated with Claude Code