Commit 0b444db
fix(sync): sort fields before hashing in fingerprintSchema (27)
fingerprintSchema sorted tables and views before hashing but not fields, on
the same expression. Field-listing order isn't a stable API contract (and
CLAUDE.md already classifies field order as best-effort, non-drift), so a
field-order-only difference between plan-time and apply-time snapshots
flipped the fingerprint. The apply() drift guard treats that as a real
schema change: it hard-aborts a fresh apply (forcing a wasteful re-plan on
an unchanged schema) or, on a resume, emits a false RESUME_DRIFT_BYPASS
"someone else changed the dest" warning.
Sort the composed id=name=type strings the same way the views line already
does — equivalent to sorting by field id (unique, always the first token)
since ids can never collide, so order stops mattering while a genuine
rename/retype still changes the string content and therefore the hash.
Swept src/sync/ for sibling instances of the same pattern (identity hash
over an unsorted collection) — none found; every other join/sort site is
either already order-independent or deliberately order-sensitive for
best-effort order-drift reporting (compare.js).
Added regression coverage: same fields in different order -> same
fingerprint; add/remove/rename/retype a field -> different fingerprint.
Reverted the fix locally to confirm the new test fails without it, then
restored it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>1 parent fe12bb2 commit 0b444db
2 files changed
Lines changed: 57 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
20 | 26 | | |
21 | 27 | | |
22 | 28 | | |
23 | 29 | | |
24 | 30 | | |
25 | 31 | | |
26 | | - | |
| 32 | + | |
27 | 33 | | |
28 | 34 | | |
29 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
23 | 72 | | |
24 | 73 | | |
25 | 74 | | |
| |||
0 commit comments