Skip to content

Fix: Bind runtime effects to stable structural identity#52

Merged
phranck merged 10 commits into
mainfrom
issue/10-stable-structural-identity
Jul 20, 2026
Merged

Fix: Bind runtime effects to stable structural identity#52
phranck merged 10 commits into
mainfrom
issue/10-stable-structural-identity

Conversation

@phranck

@phranck phranck commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Summary

  • derive stable structural slots for modifiers, effects, and keyed children
  • bind @State and Observation to committed view identities with task-local hydration
  • preserve lifecycle callbacks and view tasks across reconstruction, including ID restart and cancellation behavior
  • keep State and Observation records alive across cached subtrees and release them on true unmount
  • document the updated state, observation, lifecycle, and task model

Dynamic collection traversal and duplicate-ID diagnostics remain in #12, which consumes the keyed identity primitive added here. Exact public task API coverage remains in #21. Together with #51, this addresses #1.

Closes #10

Checklist

  • Swift 6.0 compatible (no features requiring a newer compiler)
  • Builds on macOS and Linux (swift build succeeds on both)
  • All tests pass (swift test)
  • No new SwiftLint warnings (swiftlint)
  • Public APIs match SwiftUI signatures (parameter names, order, types)
  • Modifiers propagate through the View hierarchy

Test Plan

  • macOS deterministic quality gate with Xcode 16.2: 1,242 tests, strict lint, API contracts, versioned consumer, and DocC
  • Linux deterministic quality gate in the pinned Swift 6.0.3 container: 1,242 tests, strict lint, API contracts, versioned consumer, and DocC
  • focused State identity, lifecycle/task, Observation registry, cache-liveness, environment, and runtime characterization suites
  • expected result: stable State/effect identity across reconstruction, bounded runtime tables, and deterministic cleanup on unmount

phranck added 10 commits July 20, 2026 01:34
- derive modifier slots from structural paths

- add position-independent keyed child identities

- verify keyed state reorder and cleanup behavior
- derive lifecycle effects from structural modifier paths

- retain tasks across unchanged renders and restart on ID changes

- release callbacks and cancel tasks on true unmount

- preserve inherited actor isolation for task operations
- hydrate dynamic properties immediately before body evaluation

- persist State through a rebindable storage location

- keep sibling state isolated from parent construction context

- verify reconstruction, reorder, and unmount cleanup
- supersede stale callbacks by structural generation

- invalidate only the observed subtree

- remove registrations on unmount and runtime reset

- verify repeated renders keep registry storage bounded
- verify task-driven State survives view reconstruction

- assert mounted tasks do not restart unchanged

- assert disappear callbacks run only on true unmount
- Replace production mutation of unsafe ambient render state
- Preserve nested state, environment, and AppStorage binding scopes
- Cover deterministic restoration across nested hydration
- Document final-identity state and observation binding
- Describe stable lifecycle and mounted task slots
- Align render-cycle examples with task-local hydration
- Include the owning StateStorage when deciding whether to rebind
- Prevent identical structural paths from sharing boxes across runtimes
- Add a focused cross-runtime regression test
- Carry active Observation registrations through skipped cached subtrees
- Remove unrelated registrations at render-pass completion
- Cover direct and descendant cache liveness
- Mark persisted State and onChange records below cache hits active
- Keep descendant storage alive without evaluating cached bodies
- Add a nested State cache regression test
@phranck
phranck merged commit 94a0de7 into main Jul 20, 2026
6 checks passed
@phranck
phranck deleted the issue/10-stable-structural-identity branch July 20, 2026 07:41
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.

[P0-05] Bind state, observation, lifecycle, and tasks to stable structural identity

1 participant