Skip to content

PROD-2203: Add --preflight (dry-run preview) mode to sync/push#168

Draft
5PK wants to merge 3 commits into
mainfrom
prod-2203-preflight
Draft

PROD-2203: Add --preflight (dry-run preview) mode to sync/push#168
5PK wants to merge 3 commits into
mainfrom
prod-2203-preflight

Conversation

@5PK

@5PK 5PK commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

What & why

Implements PROD-2203. Adds a preflight mode to the sync/push command that previews what a sync would do — before committing any changes to the target.

Preflight runs the full source-pull, target-pull, dependency analysis and change detection that a real sync performs, then reports the creates / updates / skips / conflicts it would produce — without writing anything to the target instance or mapping files. This lets customers and support preview sensitive migrations safely.

Flags

  • --preflight — run the preview (no writes to target or mappings)
  • --preflight-json — emit the report as machine-readable JSON instead of the human table

Exits non-zero when conflicts are detected, so CI/scripts can gate a real sync on a clean preflight.

How it works

The key design point: skip and conflict decisions never reach the API (the sync decides "nothing to do" / "unsafe" and moves on), so a client-level interceptor can't observe them. Each pusher therefore records its already-computed decision at the decision point and skips the write.

  • New PreflightReport collector (src/lib/preflight/) — per-phase counts + table/JSON rendering
  • All 7 pushers instrumented: galleries, assets, models, containers, content, templates, pages
  • saveMappingFile hard-guarded under preflight (safety net); auto-publish suppressed
  • Previously-silent "target changed without --overwrite" fall-throughs (galleries/assets) are now surfaced as conflicts in the report

Sample output

🔎 PREFLIGHT — no changes were written to the target or mappings
Models: 2 create, 1 update, 5 skip, 0 conflict
Pages: 0 create, 3 update, 1 conflict
  ✗ [en-us] Home — target changed; use --overwrite to force
TOTAL: 2 create, 4 update, 6 skip, 1 conflict
⚠️  Conflicts detected — a real sync would require --force (exit code 1).

Testing

  • New unit tests for the report module + the saveMappingFile preflight guard
  • Full suite: 1743 tests passing (98 suites); tsc --noEmit clean; npm run build passes

Notes for reviewers

  • Related ticket PROD-2202 (move model validation to first sync step) will affect what the models phase reports under preflight, depending on merge order.
  • Suggest a quick live --preflight run against a throwaway target to eyeball report formatting (automated tests cover logic, not a live sync).

🤖 Generated with Claude Code

5PK and others added 3 commits June 18, 2026 12:59
Adds a preflight mode that runs the full source-pull, target-pull,
dependency analysis and change detection a real sync would perform, then
reports the creates/updates/skips/conflicts it WOULD produce — without
writing anything to the target instance or mapping files.

- New --preflight flag and --preflight-json (machine-readable output)
- Central PreflightReport collector (src/lib/preflight) with table + JSON
  rendering; populated at each pusher's decision point (the only place
  that can observe skips/conflicts, which never reach the API)
- All 7 pushers instrumented (galleries, assets, models, containers,
  content, templates, pages); gallery/asset silent target-changed
  fall-throughs now surfaced as conflicts
- saveMappingFile hard-guarded under preflight; auto-publish suppressed
- Exits non-zero when conflicts are detected (for CI gating)
- Tests: report module + saveMappingFile guard

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The preflight conflict warning said a real sync would require --force, but
the actual flag is --overwrite (as the per-item conflict details already
state). Align the wording to avoid pointing users at a non-existent flag.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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