alonso.torres 44c1cb89c1 🐛 Fix component validation and repair
Fixes in the validation of component refs and in the file repairs (Phase
3c).

- Name the component in the :ref-shape-is-head error.

  A copy shape whose near main is a nested copy head must be a head of the
  same component. The check reported no component, so its repair reheaded
  the shape with nil ids, validation found the same error again and the file
  never converged (F48). The error now carries the near main's component
  file and id, as :ref-shape-is-not-head does, and the repair reheads the
  shape with them.

  repair-components-test repairs a nested copy head that lost its component.

- Remove a stray component file in the :component-main repair.

  Validation reports :component-main on a shape inside a main that is not a
  head when it has :main-instance or :component-file. The repair only
  removed :main-instance, so a shape with :component-file kept the error
  after every pass and the file never converged (F47). For a shape that is
  not a head, the repair also removes :component-file.

  repair-components-test repairs a main child with a component file.

- Check refs inside copies at every level where they are local.

  Validation of the shapes inside a copy had two faults:
  - it checked the ref of a nested copy head (it exists, and is a child of
    the near main of its parent) only for heads directly under a top copy
    root: the flag that allowed it reached one level down, so heads under a
    group or nested twice were never checked (F87);
  - for a library copy it reported a ref the library has deleted since the
    file last took its updates (F104). That state is normal and lasts until
    the user takes the update, which removes the copy shape; the repair
    detached the shape or took another position instead, so the update no
    longer removed it.

  The flag now says whether the shapes refer into this file, and passes
  through every level of the copy: the children of a top copy refer into its
  component's file, and those of a swapped head into its own component's.
  :ref-shape-not-found and :ref-not-in-near-main are checked on nested heads
  only where it holds. The call on copy shapes that are not heads read the
  library from the shape itself, which only heads have, so it never ran; it
  goes.

  repair-components-test: a dangling ref on a head nested twice and on one
  under a group is reported; a library main that deleted its nested copy
  leaves the consuming file valid.

- Check the ref of every local copy shape that is not a head.

  Validation never reported a dangling :shape-ref on a copy shape that is
  not a head (F46). It now checks it wherever the shapes of the copy refer
  into this file; refs into a library may name a shape the library deleted
  since the file last took its updates (F104). The repair of
  :ref-shape-not-found looks for a matching main shape and, finding none,
  detaches the shape, which stays in the copy as a shape of its own.

  repair-components-test repairs a copy child with a dangling ref.

- Keep copies linked while their component's main is repaired.

  When a component's :main-instance-id or :main-instance-page was wrong,
  validation also reported :ref-shape-not-found on every copy of it, as
  their near main could not be found. Both repairs ran in the same pass: the
  component got its pointer back, and the copies, which the repair could not
  match against the old pointer, were detached (F60). Every user file the
  backend repaired lost those links.

  While some error in a component's main instance pointer is repaired, the
  :ref-shape-not-found errors wait for the next pass, which finds the near
  main and reports nothing.

  repair-components-test: the copies keep their link after the repair of
  :invalid-main-instance-id, :invalid-main-instance-page and
  :invalid-main-instance.

- Look up a library component's shapes in its library in repairs.

  The :ref-shape-not-found repair looks for a main shape the dangling ref
  can be matched to among the shapes of the copy's component. It found that
  component in the right file, local or library, but then read its shapes
  from the local file data, where a library component's main is not: nothing
  matched, and the whole copy was detached (F88). It now reads them from the
  component's own file.

  repair-components-test: a library copy that points at another copy of the
  same component is reassigned to the library main.

- Keep file repairs from touching the copies they fix.

  The repairs of a file's shapes wrote through the changes builder like an
  edit, so a repair of a copy shape touched the groups it changed: a copy
  shape whose geometry was reset kept the reset size as an override, and
  sync never gave it back its main's (F7, part 1). A repair is not an
  override; the repairs of shapes now touch nothing, and those that fix the
  touched groups still set them.

  repair-test: a copy shape with invalid geometry is repaired and stays
  untouched.

AI-assisted-by: claude-opus-5-5
2026-10-28 15:53:06 +01:00
..
2026-10-28 15:53:06 +01:00
2026-10-28 15:53:06 +01:00
2026-09-29 09:07:34 +02:00
2026-03-11 15:24:40 +01:00