Skip to content

Commit 80c962b

Browse files
committed
docs(changeset): Add section on version compatibility
1 parent e9bd912 commit 80c962b

File tree

1 file changed

+36
-5
lines changed

1 file changed

+36
-5
lines changed

src/wallet/changeset.rs

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,42 @@ type IndexedTxGraphChangeSet =
7676
///
7777
/// Existing fields may be extended in the future with additional sub-fields. New top-level fields
7878
/// are likely to be added as new features and core components are implemented. Existing fields may
79-
/// be removed in future versions of the library.
79+
/// be removed in future versions of the library following the deprecation policy below.
8080
///
81-
/// The authors reserve the right to make breaking changes to the [`ChangeSet`] structure in
82-
/// a major version release. API changes affecting the types of data persisted will display
83-
/// prominently in the release notes. Users are advised to look for such changes and update their
84-
/// application accordingly.
81+
/// ## Version Compatibility
82+
///
83+
/// Any change to the [`ChangeSet`] data structure MUST correlate with a major version bump per
84+
/// [Semantic Versioning]. We guarantee that version N can read and
85+
/// deserialize [`ChangeSet`] data written by version N-1 (one major version back), but this
86+
/// guarantee does NOT extend to version N-2 or earlier. New fields added in version N must
87+
/// implement [`Default`] so that when reading N-1 data, absent fields are populated with default
88+
/// values.
89+
///
90+
/// Limited forward compatibility is provided for downgrades: version N-1 will successfully
91+
/// deserialize version N data without errors by ignoring unknown fields. Users should be aware that
92+
/// features introduced in version N will not be available when downgrading to N-1, and that
93+
/// downgrading can result in loss of data if not backed up. For this reason we recommend carefully
94+
/// planning major upgrades and backing up necessary data to avoid compatibility issues.
95+
///
96+
/// Fields can be removed using a 3-version deprecation cycle: fields are marked deprecated in
97+
/// version N with a reason and instructions for migrating, the field is retained in version N+1
98+
/// for compatibility where it deserializes but may not be used, and finally removed in version
99+
/// N+2. This ensures the standard backwards compatibility guarantees while allowing the removal of
100+
/// deprecated fields.
101+
///
102+
/// ### Responsibilities
103+
///
104+
/// Library authors SHOULD test all upgrade paths using the persistence test suite and in CI.
105+
/// Library authors MUST document API changes prominently in the release notes and CHANGELOG,
106+
/// clearly mark deprecated fields including migration instructions, and follow the 3-version
107+
/// deprecation cycle before removing fields.
108+
///
109+
/// Users SHOULD back up wallet data before major version upgrades, test upgrades in non-production
110+
/// environments first, and monitor the release notes for warnings and updates. Users MUST complete
111+
/// migrations within the compatibility window, and not skip major versions (i.e. upgrade major
112+
/// versions sequentially).
113+
///
114+
/// ### Custom Persistence Implementations
85115
///
86116
/// The resulting interface is designed to give the user more control of what to persist and when
87117
/// to persist it. Custom implementations should consider and account for the possibility of
@@ -102,6 +132,7 @@ type IndexedTxGraphChangeSet =
102132
/// [`WalletPersister`]: crate::WalletPersister
103133
/// [`Wallet::staged`]: crate::Wallet::staged
104134
/// [`Wallet`]: crate::Wallet
135+
/// [Semantic Versioning]: <https://doc.rust-lang.org/cargo/reference/semver.html>
105136
#[derive(Default, Debug, Clone, PartialEq, Deserialize, Serialize)]
106137
pub struct ChangeSet {
107138
/// Descriptor for recipient addresses.

0 commit comments

Comments
 (0)