--- 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