[fm] Add guardrails for fact payload representations#10508
Draft
smklein wants to merge 1 commit into
Draft
Conversation
adb0d8a to
012096a
Compare
012096a to
ddeac01
Compare
smklein
commented
May 29, 2026
| //! directory, bump `KNOWN_VERSIONS` and `dbinit.sql` (see | ||
| //! `schema/crdb/README.adoc`) — even though, from CockroachDB's point of view, | ||
| //! the column is unchanged JSONB and only the data changes — add a case to | ||
| //! `validate_data_migration()` in `nexus/tests/integration_tests/schema.rs`, and |
Collaborator
Author
There was a problem hiding this comment.
I do still feel like this is perhaps the most critical piece here - validating data migrations, with:
"Shove old format into DB"
"Run migration"
"Migrated old data can deserialize as new data"
But hopefully the rest of scaffolding here helps catch "when we should do that".
Persisted diagnosis-engine fact payloads (the fm_fact.payload JSONB column) had no signal when their serialized shape changed. Because deployed databases already hold rows in the old shape, such a change is a data migration, not just a code change, and CockroachDB's schema-diff tests do not catch it (the column is unchanged JSONB; only the data changes). Add payload-stability tests in nexus/fm/src/diagnosis: - schemars JSON-schema snapshot per DE payload (structure: variants, fields, types, and embedded-enum domains, including cross-crate types like ZpoolHealth) - strum-enforced serde byte sample per variant (exact on-disk bytes), plus a round-trip test proving the pinned format still deserializes - a central every_de_payload_is_pinned check over DiagnosisEngineKind so a future DE cannot silently skip the guardrail The schemars/strum derives are cfg(test)-gated, so they stay dev-only with no production footprint. Module docs in diagnosis/mod.rs explain additive (serde-compatible) vs breaking changes and how to write a DE-scoped JSONB data migration that reuses the schema/crdb mechanism.
ddeac01 to
d7de080
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Persisted diagnosis-engine fact payloads (the fm_fact.payload JSONB column) had no signal when their serialized shape changed. Because deployed databases already hold rows in the old shape, such a change is a data migration, and CockroachDB's schema-diff tests do not catch it (the column is unchanged JSONB; only the data changes).
Add payload-stability tests in
nexus/fm/src/diagnosis:The schemars/strum derives are cfg(test)-gated, so they stay dev-only with no production footprint. Module docs in diagnosis/mod.rs explain additive (serde-compatible) vs breaking changes and how to write a DE-scoped JSONB data migration that reuses the schema/crdb mechanism.