# KRB Image Cluster Replacement v4

## Sylvain's docs finding / bug workaround

If Page Slot ordered insert is bugged, v4 uses the workaround Sylvain suggested, but avoids recreating configured components where possible.

Instead of deleting and rebuilding everything after the Image Cluster, it **moves the existing trailing component instances** by appending them again. Earlier KRB scripts have used `append(existingElement)` as a move operation, which should preserve each instance's props/content.

## Replacement algorithm

For a standalone case such as:

```txt
[A, Section / Image Cluster, B, C]
```

v4 does:

```txt
append Component / Slider Gallery
=> [A, Image Cluster, B, C, Slider Gallery]

append existing B, then existing C
=> [A, Image Cluster, Slider Gallery, B, C]

remove old Image Cluster
=> [A, Slider Gallery, B, C]
```

For a paired text+gallery case:

```txt
[A, Section / Text Content, Section / Image Cluster, B, C]
```

v4 appends the new `Section / Two Column Text & Image`, moves B/C after it, then removes the old Text Content and Image Cluster pair.

## Safety behavior

- Still defaults to `dryRun: true` and `runMode: 'current-page'`.
- Direct ordered insertion methods are still tried first.
- If those fail, v4 uses append/rotate.
- It verifies intermediate and final child indexes.
- It removes the old source only after the new replacement is positioned correctly.
- If verification fails before source removal, the old source stays in place for manual review.

Result prefix:

```txt
KRB_IMAGE_CLUSTER_REPLACEMENT_V4_RESULT
```

## Weddings test

1. Open `/community/weddings`.
2. Run v4 unchanged first (`dryRun: true`).
3. Set `dryRun: false` and run on Weddings.
4. Check:
   - `replacementMethod` should be `append replacement, rotate trailing siblings, remove source` if the fallback was used.
   - `rotateFallback.trailingComponents` should list the sections that were moved after the new gallery.
   - `topLevelAfter` should show `Component / Slider Gallery` where `Section / Image Cluster` used to be.

No publish/site/script/CMS/redirect/style operations are included.
