Tasks follow the architecture spec phases: - Phase 0: key field on UElement (2 tasks + review) - Phase 1: reactive-host bridge / fiber tree (4 tasks + review) - Phase 2: key-based children reconciliation (3 tasks + review) - Phase 3: unmount & dispose support (4 tasks) - Phase 4: TypeBox value optimizations (4 tasks) Validated with taskgraph CLI: no cycles, 15 parallel generations, 3 high-risk tasks identified (signal-driven-updates, commit-mutations, fiber-disposal).
43 lines
1.7 KiB
Markdown
43 lines
1.7 KiB
Markdown
---
|
|
id: value-clone-prevprops
|
|
name: Value.Clone for prevProps snapshots
|
|
status: pending
|
|
depends_on: [value-equal-bailout]
|
|
created: 2026-05-18T16:22:57.354731873Z
|
|
modified: 2026-05-18T16:22:57.354732316Z
|
|
scope: narrow
|
|
risk: low
|
|
impact: component
|
|
level: implementation
|
|
---
|
|
|
|
# Description
|
|
|
|
Use `Value.Clone` to create proper `prevProps` snapshots before mutation. Currently the architecture spec says `fiber.prevProps` should hold the snapshot before reconciliation, but without deep cloning, `prevProps` and `fiber.props` could share nested references.
|
|
|
|
`Value.Clone` provides a deep clone that the `commitUpdate` contract relies on: `host.commitUpdate(instance, payload, tag, prevProps, nextProps, ctx)` needs both the before and after state to be independent.
|
|
|
|
This is the second optimization in the strategy (after `Value.Equal`), and it's about correctness, not just performance. Without `Value.Clone`, hosts that read `prevProps` during `commitUpdate` might see already-mutated values.
|
|
|
|
## Acceptance Criteria
|
|
|
|
- [ ] `Value.Clone` imported from `@alkdev/typebox/value`
|
|
- [ ] `fiber.prevProps` set to `Value.Clone(fiber.props)` before reconciliation updates props
|
|
- [ ] `prevProps` is a deep clone — no shared references with `fiber.props`
|
|
- [ ] `commitUpdate` receives independent `prevProps` and `nextProps`
|
|
- [ ] Existing tests pass
|
|
- [ ] New test: mutating `fiber.props` after setting `prevProps` does not affect `prevProps`
|
|
- [ ] New test: `commitUpdate` receives correct before/after prop values
|
|
|
|
## References
|
|
|
|
- docs/architecture/reconciler.md — TypeBox Optimization Layer, Value.Clone row
|
|
- docs/architecture/reconciler.md — Optimization Strategy (step 3)
|
|
|
|
## Notes
|
|
|
|
> To be filled by implementation agent
|
|
|
|
## Summary
|
|
|
|
> To be filled on completion |