A switch kept a swap whose subtree holds a copy of a nested copy's
component of the new variant, the copy the swap goes into. The move of
the kept swap was refused and it stayed at the page root. A switch now
keeps a swap only when it holds no copy of a component of the shapes it
would be inside: the ancestors of its place in the new variant, and
those of the copy.
Benchmark (scripts/bench-components, ms, lower 2.5% quantile):
| :world | :baseline | :now | :mean | :ratio |
|------------------------------------+-----------+--------+---------+--------|
| deepest-edit-through-three-levels | 35.215 | 19.637 | 20.776 | 0.56 |
| edit-through-a-chain-of-dependents | 68.931 | 40.27 | 42.936 | 0.58 |
| library-update-into-copies | 83.083 | 52.234 | 53.028 | 0.63 |
| main-edit-among-many-shapes | 4.837 | 2.105 | 2.231 | 0.44 |
| main-edit-into-10-copies | 1.79 | 1.079 | 1.11 | 0.6 |
| main-edit-into-100-copies | 15.415 | 10.333 | 10.617 | 0.67 |
| main-edit-into-1000-copies | 153.086 | 97.413 | 103.833 | 0.64 |
| variant-switch-into-copies | 32.052 | 22.451 | 23.0 | 0.7 |
Common suite: 2379 tests, 1 failure, the known insufficient-random-coverage
of random-stale-library-compositions (detach attempted once in 20
programs).
AI-assisted-by: claude-opus-5-5