Skip to content

fix: pull writes canonical model files and detects changes reliably - #243

Draft
angeloashmore wants to merge 8 commits into
mainfrom
aa/deep-sort-canonicalize
Draft

fix: pull writes canonical model files and detects changes reliably#243
angeloashmore wants to merge 8 commits into
mainfrom
aa/deep-sort-canonicalize

Conversation

@angeloashmore

@angeloashmore angeloashmore commented Jul 29, 2026

Copy link
Copy Markdown
Member

Resolves:

Description

prismic pull rewrote model files that had not changed, and it never rewrote files whose key order did not match the format it writes.

This PR fixes both. Model comparison now sorts keys at every depth before comparing, while field order is left untouched. Pull rewrites local files whose key order is not canonical. prismic sync uses the same comparison as pull. push and status still ignore key order, so nothing is pushed or reported when only key order differs.

Checklist

  • A comprehensive Linear ticket, providing sufficient context and details to facilitate the review of the PR, is linked to the PR.
  • If my changes require tests, I added them.
  • If my changes affect backward compatibility, it has been discussed.
  • If my changes require an update to the CONTRIBUTING.md guide, I updated it.

Preview

How to QA 1

Run prismic pull twice in a project with committed model files written by Slice Machine. The first pull rewrites the files. The second prints "Already up to date." and leaves no dirty files.

🤖 Generated with Claude Code

Footnotes

  1. Please use these labels when submitting a review:
    ❓ #ask: Ask a question.
    💡 #idea: Suggest an idea.
    ⚠️ #issue: Strongly suggest a change.
    🎉 #nice: Share a compliment.

angeloashmore and others added 6 commits July 29, 2026 23:07
Model canonicalization sorted keys only one level deep, so structurally
identical models with reordered keys inside nested config objects (e.g.
an Image field's constraint) compared as different, causing pull to
rewrite unchanged files.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@angeloashmore angeloashmore changed the title fix: canonicalize nested model config objects fix: pull writes canonical model files and detects changes reliably Jul 30, 2026
angeloashmore and others added 2 commits July 30, 2026 02:53
Sync compared raw remote JSON against canonical local files, so any
remote change re-synced every model whose key order differed. Sync now
uses pull's comparison: the remote model's canonical form against the
local file as parsed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Pull now has a test that pulled files keep field order, a second pull
changes nothing, and non-canonical files (types and slices) are
rewritten in canonical form. The status reorder test also covers a
slice and checks that push writes nothing. The scramble helper moves to
test/it.ts and handles slice field maps.

Co-Authored-By: Claude Fable 5 <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