Skip to content

PROD-3164/PROD-3212: sync page order, and stop on an empty source pull - #271

Open
5PK wants to merge 1 commit into
mainfrom
PROD-3164-page-order
Open

5PK wants to merge 1 commit into
mainfrom
PROD-3164-page-order

Conversation

@5PK

@5PK 5PK commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

Two fixes for issues found testing a customer's sync chain on 1.3.1.

Page order (PROD-3164)

A page save keeps an existing page's stored position, so a page moved on the source after its first sync stayed where it was on the target (verify: siblingOrderMismatch).

  • New pageOrder phase after pages (src/lib/page-order/sync-page-order.ts). It reads the target's sitemap live from the Management API, keeps the longest run of pages already in the source's order under each parent, and moves the rest with pageMethods.movePage (TS SDK 0.2.2, endpoint live in prod since 2026-11-13).
  • It doesn't move pages the page phase held (target changed since the last sync, or a conflict, without --overwrite) or pages outside a --pages scope. The other pages are ordered around them; if that can't fully work, it warns.
  • After a move, the mapping's targetVersionID moves forward in every locale, so the next sync doesn't see a target change. The page is queued for republishing in each locale where it was published on both sides.
  • --preflight lists each move once (previously once per locale), and --jsonSummary reports a pageOrder phase.

Source readiness (PROD-3212)

When the source's Fetch API (preview) wasn't ready, the pull was empty: every phase printed "Skipping … no data", and the sync exited 0 having synced nothing. With --syncDeletes, it would have read as everything deleted.

  • New src/lib/pushers/source-readiness.ts, checked in the orchestrator before anything is written.
  • Failure (Source validation failed, exit 1, preflight included): for a requested locale, no content items or no pages were pulled, but the mappings have entries of that kind.
  • Warning: nothing pulled and nothing mapped, or fewer than half as many pulled as mapped (mapped ≥ 20).
  • Not caught: a preview that stopped updating but still returns data.

Tests

  • src/lib/page-order/tests/sync-page-order.test.ts: the planner (order, parent change, root, mapping, fixed pages, dynamic items) and the runner (one move across locales, version bump, republish queue, held pages, --overwrite, preflight, failures).
  • src/lib/pushers/tests/source-readiness.test.ts
  • full-instance.test.ts: page order runs with no moves on a fresh sync, and an empty source pull on re-sync fails with no writes (sync and preflight).
  • Unit and hermetic suites: 146 suites, 2861 tests pass.

Not yet done

  • Live run on clone instances: needs access to the test clones. A 1.3.2 beta should be tested there before release.

🤖 Generated with Claude Code

Page order: a page save never moves an existing page, so a page moved on
the source stayed in its old place on the target. A new phase after pages
puts each synced page under the source's parent, in the source's place,
through the Management API page move (SDK 0.2.2 movePage). Only pages out
of place move; pages held by the page phase (target changed, no
--overwrite) and pages outside --pages stay put and the rest are ordered
around them. After a move the mapping's target version moves forward in
every locale and the page is queued for republishing. Preflight lists
each move once, not once per locale.

Source readiness: when the source's Fetch API (preview) isn't ready the
pull is empty, every phase skipped, and the sync exited 0 having synced
nothing. Before anything is written, each requested locale is checked: no
content items or no pages pulled while the mappings have some is a
"Source validation failed" run failure (exit 1, preflight too); nothing
pulled and nothing mapped, or under half of what is mapped, is a warning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant