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).
52 lines
2.2 KiB
Markdown
52 lines
2.2 KiB
Markdown
---
|
|
id: value-diff-payloads
|
|
name: Value.Diff granular prop payloads
|
|
status: pending
|
|
depends_on: [value-hash-detection]
|
|
created: 2026-05-18T16:22:57.384875485Z
|
|
modified: 2026-05-18T16:22:57.384875927Z
|
|
scope: narrow
|
|
risk: medium
|
|
impact: component
|
|
level: implementation
|
|
---
|
|
|
|
# Description
|
|
|
|
Add `Value.Diff` to produce granular property-level diff payloads for `commitUpdate`. Instead of passing the full `prevProps` and `nextProps` to the host, `Value.Diff` identifies exactly which properties changed, allowing hosts to apply targeted updates.
|
|
|
|
This is the lowest-priority optimization per the architecture doc — "nice-to-have for hosts wanting granular updates." It's optional and the reconciler is correct without it.
|
|
|
|
**Critical constraint:** `Value.Diff` throws `ValueDiffError` on function values. Since `PropValue` includes functions, `Value.Diff` must either strip function props before diffing or catch the error and fall back to full replacement.
|
|
|
|
Implementation approach:
|
|
1. Before calling `Value.Diff`, strip function-valued props
|
|
2. Call `Value.Diff(cleanPrevProps, cleanNextProps)`
|
|
3. If `Value.Diff` throws (unexpected function somehow), catch and fall back to full `prepareUpdate`
|
|
4. Use the diff result as the payload for `commitUpdate`
|
|
|
|
## Acceptance Criteria
|
|
|
|
- [ ] `Value.Diff` imported from `@alkdev/typebox/value`
|
|
- [ ] Function-valued props stripped before `Value.Diff` call
|
|
- [ ] `ValueDiffError` caught and falls back to full `prepareUpdate`
|
|
- [ ] Diff result used as `commitUpdate` payload
|
|
- [ ] Hosts that don't need granular diffs can ignore the diff payload and use `prevProps`/`nextProps`
|
|
- [ ] Existing tests pass
|
|
- [ ] New test: `Value.Diff` payload contains only changed keys
|
|
- [ ] New test: function-valued props don't crash `Value.Diff` (stripped or caught)
|
|
- [ ] New test: diff error falls back gracefully to `prepareUpdate`
|
|
|
|
## References
|
|
|
|
- docs/architecture/reconciler.md — TypeBox Optimization Layer, Value.Diff row, Value.Diff on Functions
|
|
- docs/architecture/reconciler.md — Optimization Strategy (step 5, optional)
|
|
- docs/architecture/schema.md — PropValue includes functions
|
|
|
|
## Notes
|
|
|
|
> To be filled by implementation agent
|
|
|
|
## Summary
|
|
|
|
> To be filled on completion |