# KRB next-batch v4 page-slot fix

## Why v3 misplaced sections

The v3 missing-sections repair used `findMainDropTarget()` with `helpers.describe()` metadata only:

```js
nodes.find(n => n.desc?.type === 'DropTarget') || ... || nodes[0]
```

In the Iggy/Webflow Code Lab runtime, `helpers.describe()` may be empty for Webflow elements even though the actual element has `el.type === 'DropTarget'`. When `desc.type` was unavailable, the function fell back to `nodes[0]` / Body, so newly inserted `Section / Text Content`, `Section / Two Column Text & Image`, `Section / Downloads`, `Section / Gateway CTA`, and `Section / Next Pages` were appended outside the Page Slot.

## Page-client readback

I read the 16 next-batch pages with `@webflow/page-client` and wrote:

- `krb-next-16-page-client-slot-audit-v1.json`
- `krb-next-16-page-client-slot-audit-v1-summary.json`

Confirmed body-level misplaced sections on:

- Cambridge International
- Sacred Heart Education
- Global Opportunities
- Teaching and Learning Framework
- New Year 5 Honours Program
- The Year 7 Experience
- Boarding Tour
- Facilities
- International
- Support

Confirmed already-in-slot content on:

- Boarding at KRB

Confirmed no extra inserted content yet on:

- Our Approach
- Co-curricular Program
- Junior School
- Senior School
- Early Learning Centre

## v4 fix behaviour

Script:

- `krb-next-20-live-scrape-import-v4-page-slot-fix.js`

Result prefixes:

- current page: `KRB_LIVE_SCRAPE_PAGE_SLOT_FIX_RESULT`
- all pages: `KRB_LIVE_SCRAPE_PAGE_SLOT_FIX_AUTO_RESULT`

Changes:

1. Robustly detects the actual Page Slot DropTarget with `row.el.type || row.desc.type`, not `helpers.describe()` alone.
2. Excludes the drop target that contains the Hero.
3. Prefers the DropTarget after/near the Hero in the page-structure wrapper.
4. Moves existing misplaced body-level content sections into the Page Slot before doing any count-based insertions.
5. Inserts still-missing sections only into the selected Page Slot.
6. Adds report fields:
   - `pageSlotDebug`
   - `misplacedBefore`
   - `movedIntoPageSlot`
   - `countsAfterMove`

## Run plan

Run in Code Lab. If you want to test first, temporarily set:

```js
dryRun: true,
runMode: 'current-page'
```

For the actual repair, use the generated defaults:

```js
dryRun: false,
runMode: 'all-pages'
```

After running, check:

- `movedIntoPageSlot` lists the misplaced sections that were moved.
- `inserted` only lists pages that were genuinely missing sections.
- `pageSlotDebug[0]` should show a positive score and no `Section / Hero` child.
- Run the page-client audit again; `misplaced` should be empty for the repaired pages and `inSlot` should contain the expected content sections.

No publish/delete/redirect/global-style operations are performed.
