🐛 Author a pushed swap's constraints against its own main

Update main of a swap pushed into a main makes the swap a plain nested copy
of its own component. It kept the constraints of its old position, such as
an authored fixed scroll, without marking them as overrides, so the next
sync from its own main would reset them.

Mark the constraints group when the old position's constraints differ from
the new main's, as orientation already is. The update-main model predicts
the same from the swapped head before the update.

A fresh-seed JVM library run found this. Its shrunk program fails I4
before the fix and passes unchanged after it. Goldens are unchanged.

Full suites ran once on the tree with this fix and the related fixes that
follow it. Common passes lint, JVM, JavaScript and formatting: JVM 2059
tests / 33770 assertions; JavaScript 1995 / 32377. All six component
properties pass 40 programs each at seed 712 in both runtimes. Full rebuilt
frontend passes 1798 / 15737. Backend passes 1838 / 9293; exporter passes
16 / 40; consumer lint and formatting pass.

Compare lower-quantile milliseconds with the saved baseline; keep that
baseline unchanged. The machine/JVM warning makes ratios rough. No world
is flagged.

World                      Baseline       Now    Ratio
Main into 10 copies           1.790     0.895     0.50
Main into 100 copies         15.415     8.623     0.56
Main into 1000 copies       153.086    86.717     0.57
Three nesting levels         35.215    17.928     0.51
Dependency chain             68.931    35.381     0.51
Library update               83.083    43.344     0.52
Many plain shapes             4.837     2.118     0.44
Variant switch               32.052    18.854     0.59

AI-assisted-by: claude-opus-5-5
This commit is contained in:
alonso.torres 2026-10-30 20:18:55 +01:00
parent d3f073fe82
commit 80b65c8dbb
2 changed files with 19 additions and 2 deletions

View File

@ -954,7 +954,8 @@
(defn- rehead-pushed-swap
"A pushed swap becomes a plain nested copy. Its old position's
orientation becomes authored when it differs from its own main."
orientation and constraints become authored when they differ from its
own main."
[shape main container]
(let [shape (-> shape
(assoc :shape-ref (:id main))
@ -965,7 +966,10 @@
expected (get-in main-container [:objects (:id main)])]
(cond-> shape
(and expected (orient-like shape expected (gsh/shape->center shape)))
(update :touched ctk/set-touched-group :geometry-group))))
(update :touched ctk/set-touched-group :geometry-group)
(and main (some #(not= (get shape %) (get main %)) [:constraints-h :constraints-v :fixed-scroll]))
(update :touched ctk/set-touched-group :constraints-group))))
(defn- author-pushed-content
"Taking a new content reference makes the pushed differences authored.

View File

@ -683,6 +683,19 @@
(t/is (mth/close? 0 (rotation :sync-random-0-outer-0) 0.01))
(t/is (mth/close? 45 (rotation :sync-random-0-innercopy-1) 0.01))))
(t/deftest a-pushed-swap-authors-the-constraints-of-its-old-position
(let [program {:world [2 0 {:variants true :text-styles true :layout nil :layout-item-margins false
:library true :rich-variants true :layout-children false
:layout-copies true :text true}]
:ops [[:style 12 7 7 0] [:nest 0 0 0 0] [:swap 8 0 0 0] [:edit 0 0 1 1] [:update-main 0]]}
situation (:situation (cg/run program))
outer (tm/shape-by-id situation (thi/id :sync-variant-outer-0))
pushed (tm/shape-by-id situation (first (:shapes outer)))]
;; The old position authored fixed scroll; the new nested copy keeps it
;; against its own main, which does not scroll.
(t/is (true? (:fixed-scroll pushed)))
(t/is (contains? (:touched pushed) :constraints-group))))
(t/deftest detached-swapped-head-follows-its-own-component-without-position-overrides
(t/is (map? (cg/run {:world [2 1 {:library true :variants true}]
:ops [[:edit 0 0 1 2] [:update-main 0] [:library-sync]