feat: add migration guardrail for get_result_schema() result layout c… - #350
Closed
olaleyeolajide81-sketch wants to merge 2 commits into
Closed
Conversation
…hanges (ApexChainx#255) Introduces a two-level safety gate that prevents SLAResult layout changes from being merged without a deliberate, reviewed schema version bump. ## Level 1 — Compile-time gate schema_migration_tests.rs contains an exhaustive SLAResult destructure: let SLAResult { outage_id: _, status: _, mttr_minutes: _, threshold_minutes: _, amount: _, payment_type: _, rating: _, config_version_hash: _, recorded_at: _ } = s; If a field is added or removed from SLAResult the destructure fails to compile — surfacing the change before any runtime tests run. ## Level 2 — Runtime / CI gate New constant: RESULT_SCHEMA_FIELD_COUNT = 9 Records the number of named fields in SLAResult. Must be updated in the same commit that adds or removes a field, together with RESULT_SCHEMA_VERSION. New field: SLAResultSchema::result_field_count Exposes RESULT_SCHEMA_FIELD_COUNT via get_result_schema() so backend consumers can detect layout drift at runtime without hardcoding field lists. New test module: schema_migration_tests.rs (5 tests) - test_result_schema_field_count_sentinel: asserts count == 9 - test_get_result_schema_version_matches_constant: asserts get_result_schema() returns schema_version == RESULT_SCHEMA_VERSION and result_field_count == RESULT_SCHEMA_FIELD_COUNT - test_result_schema_symbols_are_stable: asserts every symbol matches the canonical value baked into compute_result - test_result_schema_no_deprecated_symbols_at_v1: asserts deprecated list empty - test_config_bundle_schema_version_consistent: asserts get_config_bundle() embeds the same version and field count ## CI step added .github/workflows/ci.yml: dedicated 'Result schema migration guard' step in the e2e-tests job runs 'cargo test --lib schema_migration_tests' with a comment explaining the purpose and pointing to the migration guide. ## Documentation docs/result-schema-migration-guard.md: complete reference covering the two-level mechanism, step-by-step change process for adding/removing fields, symbol deprecation protocol, backend consumer guidance, and a release-process checklist including a required 'Schema Migration Note' PR section. CHANGELOG.md: [Unreleased] entries for all additions above. Closes ApexChainx#255
|
@olaleyeolajide81-sketch Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
Skipping — this PR touches .github/workflows/ files which require elevated token permissions to push. Please rebase manually or ask a repo admin to merge. 🙏 |
Contributor
|
Skipping — Code Coverage check is failing. Please fix the coverage and re-push! |
Contributor
|
Merged — nice work! 🚀 |
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.
…hanges (#255)
Introduces a two-level safety gate that prevents SLAResult layout changes from being merged without a deliberate, reviewed schema version bump.
Level 1 — Compile-time gate
schema_migration_tests.rs contains an exhaustive SLAResult destructure:
If a field is added or removed from SLAResult the destructure fails to compile — surfacing the change before any runtime tests run.
Level 2 — Runtime / CI gate
New constant: RESULT_SCHEMA_FIELD_COUNT = 9
Records the number of named fields in SLAResult. Must be updated in the
same commit that adds or removes a field, together with RESULT_SCHEMA_VERSION.
New field: SLAResultSchema::result_field_count
Exposes RESULT_SCHEMA_FIELD_COUNT via get_result_schema() so backend
consumers can detect layout drift at runtime without hardcoding field lists.
New test module: schema_migration_tests.rs (5 tests)
CI step added
.github/workflows/ci.yml: dedicated 'Result schema migration guard' step in the e2e-tests job runs 'cargo test --lib schema_migration_tests' with a comment explaining the purpose and pointing to the migration guide.
Documentation
docs/result-schema-migration-guard.md: complete reference covering the two-level mechanism, step-by-step change process for adding/removing fields, symbol deprecation protocol, backend consumer guidance, and a release-process checklist including a required 'Schema Migration Note' PR section.
CHANGELOG.md: [Unreleased] entries for all additions above.
Closes #255
Description
Brief description of the changes in this PR.
Type of Change
Related Issues
Fixes #(issue number) or relates to #(issue number)
Changes Made
Testing
Describe the testing performed to validate these changes:
Checklist
Screenshots (if applicable)
Add screenshots or logs if applicable.
closes #255