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

  1. 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.
  2. Break it deliberately. Yield inside commit and produce a visibly half-updated UI. This is why commit is atomic.
  3. Double buffer. Build the new tree while the current one is displayed; swap on commit.
  4. Priorities. Add at least two levels and startTransition. A high-priority update must abandon in-progress low-priority work.
  5. 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