alonso.torres f1f5ed862a 🐛 Advance a pasted copy to its component's main by its content refs
Pasting a copy held in a swapped head inside a copy inside a main left
an invalid file (`:ref-not-in-near-main`). The clipboard advanced each
shape by the number of copy levels it leaves, but the swap above makes
its references reach the component's main one step sooner, so its nested
copies overshot past that main. Users reach it by copying such a copy
and pasting it on the page (F591).

Every copy the clipboard advances now refers each shape to its
counterpart in the main of its component: the first of its content
references there, which a swapped head below follows by its slot. It
keeps the overrides of the references it skips. The level count stays
only as the fallback when a shape finds no counterpart. This generalizes
the case of a swapped reference among those it skips (F590).

Found by a fresh gate round (seed 20261117, variant property).

Test (swap-group-test, fails before the fix):
`paste-out-of-a-swapped-head-reaches-the-nested-copies-of-its-component`.

Benchmark (bench-components, alone):

|                             :world | :baseline |    :now |   :mean | :ratio |
|------------------------------------+-----------+---------+---------+--------|
|  deepest-edit-through-three-levels |    35.215 |  21.742 |  22.873 |   0.62 |
| edit-through-a-chain-of-dependents |    68.931 |  46.657 |  47.664 |   0.68 |
|         library-update-into-copies |    83.083 |  52.163 |  53.121 |   0.63 |
|        main-edit-among-many-shapes |     4.837 |    2.34 |   2.519 |   0.48 |
|           main-edit-into-10-copies |      1.79 |   1.103 |   1.136 |   0.62 |
|          main-edit-into-100-copies |    15.415 |  10.677 |  11.348 |   0.69 |
|         main-edit-into-1000-copies |   153.086 | 108.821 | 113.548 |   0.71 |
|         variant-switch-into-copies |    32.052 |   21.95 |  22.607 |   0.68 |

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