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