Files
ujsx/tasks/key-on-uelement.md
glm-5.1 c9c32a6aa6 decompose reconciler roadmap into 20 implementation tasks across 5 phases
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).
2026-05-18 16:26:52 +00:00

45 lines
1.7 KiB
Markdown

---
id: key-on-uelement
name: Add key field to UElement
status: pending
depends_on: []
created: 2026-05-18T16:22:57.098951833Z
modified: 2026-05-18T16:22:57.098952376Z
scope: narrow
risk: low
impact: component
level: implementation
---
# Description
Add `key?: string` as a first-class field on `UElement` in both the TypeScript type and the TypeBox Module schema. This is Reconciler Roadmap Phase 0 (ADR-004).
The `key` field enables identity-based children matching in the reconciler. Without it, reconciliation is positional-only, which breaks when children are reordered, inserted, or removed. `key` is a reconciler concern, not a component concern — it must live outside `props` so that component schemas don't need to declare it and component functions never receive it.
`URoot` does NOT get a `key` field. Roots are unique per `createRoot()` call and are never children of another element.
## Acceptance Criteria
- [ ] `UElement` TypeScript type has `key?: string` field
- [ ] TypeBox Module `UElement` schema includes `Type.Optional(Type.String())` for `key`
- [ ] `URoot` TypeScript type has no `key` field
- [ ] `URoot` TypeBox schema has no `key` field
- [ ] `isUElement` type guard still correctly discriminates UElement from URoot
- [ ] Existing tests pass (`npm run test`)
- [ ] New test: `UElement` with `key` field validates and type-checks
- [ ] New test: `UElement` without `key` field still works (backward compatible)
## References
- docs/architecture/schema.md — Known Gaps: `key` field on `UElement`
- docs/architecture/decisions/004-key-as-first-class-field.md — ADR-004
- docs/architecture/reconciler.md — Reconciler Roadmap Phase 0
## Notes
> To be filled by implementation agent
## Summary
> To be filled on completion