📎 Let a switched head's carried size follow its parent

The composable model carried a switched copy's geometry onto the new
head as a plain value, while the other carried shapes keep the parent
whose later resizes size them. Resizing the copy that holds the head then
scaled it through its constraint in production, and the model expected
its old size.

The head now carries its geometry with its parent too, its size only:
its place is its position's.

Test: generated `a-switched-head-in-a-copy-scales-with-its-parent`.

Harness only; the benchmark is not run.

Also in this commit:

- Draw 100 programs per random property on the JVM. The coverage check of a
  random composition test asks each kind for 0.5% of the run's changes. At 50
  programs a seed could draw a kind too few times: the stale library property
  drew its child removal 4 times, all changing state, and failed its check while
  its property passed. At 100 programs that seed passes, and the shares vary
  less.

AI-assisted-by: claude-opus-5-5
This commit is contained in:
alonso.torres 2026-11-15 23:21:06 +01:00
parent 2778039f10
commit 07427e39e7
2 changed files with 13 additions and 4 deletions

View File

@ -990,9 +990,10 @@
(not-empty (merge (apply dissoc (:applied-tokens placed) carried)
(select-keys (:applied-tokens old) carried))))
;; a carried geometry sits in the new parent, whose later
;; resizes move and size it through its constraints
(and (= :geometry-group group) new-parent (not root?))
(vary-meta assoc ::position {:shape shape :parent new-parent :sized? false})))))))
;; resizes move and size it through its constraints; the
;; head's place is its position's, so only its size follows
(and (= :geometry-group group) new-parent)
(vary-meta assoc ::position {:shape shape :parent new-parent :sized? root?})))))))
result (cond->> (dissoc groups :swap-group)
;; the head carries only its own layout item overrides
(= root-id (:id shape))

View File

@ -1597,7 +1597,7 @@
;; programs each random composition test draws: on the JVM enough for every
;; kind to reach its coverage share; in JS a parity check of the same code
(def ^:private coverage-programs #?(:clj 50 :cljs 15))
(def ^:private coverage-programs #?(:clj 100 :cljs 15))
(defn- coverage-errors
"The coverage errors of `cg/coverage-errors` on the JVM, whose programs
@ -2469,6 +2469,14 @@
:layout-copies false}]
:ops [[:transform 0 10 0 8] [:apply-token 12 11] [:style 12 3 0 1] [:token-value 0 2]]}))))
(t/deftest a-switched-head-in-a-copy-scales-with-its-parent
;; the head authors the size the switch carried, which its copy parent's
;; later resize scales through its constraint
(t/is (map? (cg/run {:world [2 2 {:tokens true :variants true :rich-variants true :text true :layout nil
:layout-copies true}]
:ops [[:paste 10 0 0 0] [:nest 12 0 0 0] [:nest 16 0 0 0] [:style 17 9 6 0] [:move 0 0 0 0]
[:resize 3 0 0 0] [:move 0 0 0 0] [:switch 15 0 0 0] [:resize 17 0 0 0]]}))))
(t/deftest an-update-main-of-a-swap-keeps-the-constraints-its-children-showed
;; a swap pushed inside a copy of the main takes the place of a board whose
;; icon scrolls fixed; the pushed icon keeps the copy's constraints as an