Skip to content

feat: add migration guardrail for get_result_schema() result layout c… - #350

Closed
olaleyeolajide81-sketch wants to merge 2 commits into
ApexChainx:mainfrom
olaleyeolajide81-sketch:feat/issue-255-result-schema-migration-guard
Closed

feat: add migration guardrail for get_result_schema() result layout c…#350
olaleyeolajide81-sketch wants to merge 2 commits into
ApexChainx:mainfrom
olaleyeolajide81-sketch:feat/issue-255-result-schema-migration-guard

Conversation

@olaleyeolajide81-sketch

Copy link
Copy Markdown

…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:

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 #255

Description

Brief description of the changes in this PR.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Related Issues

Fixes #(issue number) or relates to #(issue number)

Changes Made

Testing

Describe the testing performed to validate these changes:

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented complex logic
  • I have updated relevant documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • My changes do not introduce new warnings

Screenshots (if applicable)

Add screenshots or logs if applicable.

closes #255

…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
@drips-wave

drips-wave Bot commented Jul 30, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@usmanimamu17-create usmanimamu17-create left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀

@usmanimamu17-create usmanimamu17-create left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀

Copy link
Copy Markdown
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. 🙏

Copy link
Copy Markdown
Contributor

Skipping — Code Coverage check is failing. Please fix the coverage and re-push! ⚠️

Copy link
Copy Markdown
Contributor

Merged — nice work! 🚀

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.

Add a safe migration guardrail for get_result_schema() when the result layout changes during an upgrade

3 participants