Skip to content

schema-versioned migration/upgrade path for settlement storage #452

Description

@mikewheeleer

Summary

There is no safe way to evolve settlement storage — an upgrade risks reading stale layouts. Add a schema-version field and a guarded migration entrypoint.

Why this matters

Storage evolution without versioning corrupts state on upgrade. A version gate + migration makes upgrades safe and idempotent.

Requirements

  • Store a schema_version; expose it via a read view.
  • Add an admin-guarded migrate() that upgrades in-place, gated on the current version.
  • Migration is idempotent — running it twice is a no-op.
  • Emit an event recording the version transition.

Technical guidance

  • Refuse to migrate from an unexpected version.
  • Keep pre/post invariants asserted in tests.

Edge cases — each must have a test

  • migrate from old version -> upgrades, version bumped
  • migrate again -> no-op
  • migrate from wrong version -> rejected
  • non-admin migrate -> rejected
  • post-migration invariants hold

Acceptance criteria

  • All requirements and every edge case above implemented and covered by tests
  • New unit and integration tests; existing tests still pass and no regressions
  • Structured, typed errors (no leaked internals; stable codes)
  • cargo fmt --check, cargo clippy --all-targets -- -D warnings, and cargo test all pass locally
  • Code follows the repo's existing conventions; no duplication or dead code
  • Short docs/comments explaining the design and any non-obvious decisions
  • PR description explains the approach and includes Closes #<issue>

Out of scope

  • Automatic on-read migration
  • Downgrade path

Rewards

Part of the GrantFox OSS / Official Campaign (FWC26) — this task may be rewarded. PR quality is assessed by AI: depth, correctness under edge cases, meaningful tests, and clean design are what earn the reward. Shallow changes (typos, formatting, trivial docs) do not qualify.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions