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).
2.2 KiB
2.2 KiB
id, name, status, depends_on, created, modified, scope, risk, impact, level
| id | name | status | depends_on | created | modified | scope | risk | impact | level | |
|---|---|---|---|---|---|---|---|---|---|---|
| key-matching-algorithm | Key-based old↔new child matching | pending |
|
2026-05-18T16:22:57.216123897Z | 2026-05-18T16:22:57.216124341Z | narrow | medium | component | implementation |
Description
Implement the key-based matching algorithm that maps old children to new children by key field. When the tree structure changes (children added, removed, reordered), positional matching is insufficient — it would destroy and recreate instances instead of moving them.
This algorithm builds two maps from the old and new child lists:
oldKeyMap:Map<key | null, Fiber>— old children keyed by theirkeyfield (positional fallback fornullkeys)- New children are classified as: matched (key exists in old), added (new key), removed (old key not in new)
For matched children:
- Same type: will reconcile props (same as Step 2)
- Type changed: remove old + insert new
Unkeyed children (key = undefined) fall back to positional matching.
Acceptance Criteria
reconcileChildrenfunction implemented insrc/host/reconcile.ts- Builds
oldKeyMapfrom existing fiber children - Classifies new children into matched, added, removed sets
- Matched children with same type → flag for prop reconciliation
- Matched children with different type → old removed, new inserted
- Unkeyed children (key = undefined) use positional matching fallback
- Duplicate keys: warn and use last-wins (per ADR-004 consequences)
- Pure function — no side effects, returns classification for downstream use
- New test: keyed children reordered → matched correctly by key
- New test: keyed child added at start → old children matched, new child added
- New test: keyed child removed → classified as removed
- New test: mixed keyed and unkeyed children → key-based for keyed, positional for unkeyed
- New test: duplicate key → last-wins, no crash
References
- docs/architecture/reconciler.md — Step 3 (Reconcile Children, Key-Based)
- docs/architecture/decisions/004-key-as-first-class-field.md — ADR-004, duplicate key behavior
Notes
To be filled by implementation agent
Summary
To be filled on completion