fw-04 step 02 — Two phases, double buffering, priorities
Goal
Derive render/commit separation from the requirement that work be discardable and output atomic.
Tasks
- Split the phases. Render builds; only commit touches the DOM. Get stage 10 green — the DOM must not change while work is pending, and exactly one continuation may perform DOM operations.
- Break it deliberately. Yield inside commit and produce a visibly half-updated UI. This is why commit is atomic.
- Double buffer. Build the new tree while the current one is displayed; swap on commit.
- Priorities. Add at least two levels and
startTransition. A high-priority update must abandon in-progress low-priority work. - Prove render purity is required. Mutate something external during render, then have that render discarded by a higher-priority update. Observe the corruption. This is a far better explanation than "React is functional."
Done when
- Stage 10 green, both tests
- Half-updated UI reproduced deliberately, then prevented
- Discarded-render corruption reproduced, then prevented by purity