alonso.torres 4b671476c1 🐛 Keep a switched swap only where the new variant holds a copy
A switch kept a swapped child of the copy wherever the new variant had a
shape of the same name and ancestor kinds, even a plain board a main had
detached. The kept swap then referred to a shape that is no copy head and
the file failed validation. The switch now keeps a swap only where the
new main holds a copy, and the other swaps go with the old head.

Benchmark (scripts/bench-components, ms, lower 2.5% quantile):

|                             :world | :baseline |   :now |   :mean | :ratio |
|------------------------------------+-----------+--------+---------+--------|
|  deepest-edit-through-three-levels |    35.215 | 20.978 |  21.326 |    0.6 |
| edit-through-a-chain-of-dependents |    68.931 |  40.47 |  41.523 |   0.59 |
|         library-update-into-copies |    83.083 | 47.521 |  50.404 |   0.57 |
|        main-edit-among-many-shapes |     4.837 |  2.175 |   2.476 |   0.45 |
|           main-edit-into-10-copies |      1.79 |  0.982 |   1.003 |   0.55 |
|          main-edit-into-100-copies |    15.415 |  9.423 |   9.949 |   0.61 |
|         main-edit-into-1000-copies |   153.086 | 99.435 | 101.227 |   0.65 |
|         variant-switch-into-copies |    32.052 |  21.14 |  21.923 |   0.66 |

AI-assisted-by: claude-opus-5-5
2026-11-18 10:29:47 +01:00
..