Files
ujsx/tasks/mount-with-fibers.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

48 lines
2.1 KiB
Markdown

---
id: mount-with-fibers
name: Refactor mountNode to build fiber tree
status: pending
depends_on: [fiber-type]
created: 2026-05-18T16:22:57.152634856Z
modified: 2026-05-18T16:22:57.152635298Z
scope: moderate
risk: medium
impact: phase
level: implementation
---
# Description
Refactor the existing `mountNode` in `src/host/config.ts` to build a fiber tree alongside host instances during the mount phase. Currently, `mountNode` creates instances but discards them — the instance tree is unreachable for updates. After this task, `Root` holds a reference to the root fiber, enabling re-render and unmount.
The mount pipeline stays the same (depth-first, post-order append). The change is that each created instance is wrapped in a `Fiber` node that tracks its parent, children, and props. Function components remain transparent — they don't get their own fiber.
This task also stores the root fiber on the `Root` object so that subsequent renders can diff against it.
## Acceptance Criteria
- [ ] `mountNode` creates `Fiber` nodes for each intrinsic element and text instance
- [ ] Function components are transparent — no fiber for the component itself
- [ ] `URoot` children are mounted into the parent fiber (root is a transparent container)
- [ ] Primitives get text fibers with `tag: "#text"`
- [ ] Fiber tree is linked: `parent` and `children` fields are populated
- [ ] `Root` object holds a `rootFiber` reference (new field)
- [ ] `signalDisposers` initialized as empty array on each fiber
- [ ] `effect` initialized as `null` on each fiber
- [ ] Existing mount behavior preserved — hosts still receive same `createInstance`/`appendChild` calls
- [ ] Existing tests pass
- [ ] New test: after `render()`, `Root.rootFiber` has correct children structure matching the UNode tree
## References
- docs/architecture/reconciler.md — Fiber Node, Reconciliation Algorithm, Function Components sections
- docs/architecture/host-config.md — Mount Pipeline, No Instance Tree Reference gap
- docs/architecture/lifecycle.md — Fiber Tree Disposal
## Notes
> To be filled by implementation agent
## Summary
> To be filled on completion