Commit ff0aa26
[SavedObjects] Improve schema-only mutation handling: serialized schemas + granular diff (#268630)
## Summary
Extends the schema-only mutation tolerance introduced in #256432 with
the following improvements:
### 1. Serialised schemas in snapshots
Instead of a 64-byte SHA-256 hash, each model version's \`create\` and
\`forwardCompatibility\` schemas are now stored as their full Joi
\`describe()\` output (\`Record<string, unknown>\`). This enables
field-level diffing across CI runs.
> **Backward compatibility** — when the current snapshot contains a Joi
object but the GCS baseline still contains the old hash string, the
check computes a legacy hash on-the-fly (via \`computeSchemaHash\`) and
compares it against the stored hash. This keeps cross-format comparisons
correct during the transition window, including for function-based
\`forwardCompatibility\` schemas (e.g. fleet, SLO), which the old code
hashed as \`SHA256(fn.toString())\`.
### 2. Granular schema diff
When the CI check detects a schema-only mutation, it now classifies each
field change:
| Change | \`create\` schema | \`forwardCompatibility\` schema |
|--------|-----------------|-------------------------------|
| Schema removed from model version | ❌ error | ❌ error |
| Field removed | ❌ error | ❌ error |
| Field type changed | ❌ error | ❌ error |
| Optional → required / new required field | ❌ error | ❌ error |
| New optional field added | ✅ allow | ✅ allow |
| Required → optional field | ✅ allow | ✅ allow |
| Constraint tightened / validator added | 1 parent 4ddbb93 commit ff0aa26
15 files changed
Lines changed: 1294 additions & 4385 deletions
File tree
- packages/kbn-check-saved-objects-cli/src
- commands
- findings
- snapshots
- mocks
- validate_changes
- src/core/packages/test-helpers/so-type-serializer/src
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
18 | 24 | | |
19 | 25 | | |
20 | 26 | | |
| |||
24 | 30 | | |
25 | 31 | | |
26 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
27 | 36 | | |
28 | 37 | | |
29 | 38 | | |
| |||
0 commit comments