Require explicit VERSION in Integrable trait #97
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The
Integrabletrait currently provides a defaultconst VERSION: i32 = 1.This makes "I didn't think about versioning" and "I deliberately chose version 1"
indistinguishable at the implementation site.
VERSIONis the only mechanism that prevents a layout change from producing asilent
MacMismatch(which the system treats as tampering) instead of theexpected
PayloadVersionMismatch. If a developer modifies the fields of anIntegrabletype and forgets to bumpVERSION, existing envelopes will failverification with the wrong error is a false tamper signal. The default makes
this mistake easy to introduce and invisible during review.
Remove the default to make
VERSIONa required constant. Every implementationmust now declare it explicitly, placing the version number physically adjacent
to the struct fields is a natural checkpoint when the layout changes.
All six existing implementations are updated to
const VERSION: i32 = 1;.No behavior changes; the only effect is that future implementors must make a
conscious decision rather than inheriting a silent default.
A deeper fix is deriving VERSION as a structural fingerprint of the Hashable
fields via the macro, so any layout change auto-invalidates envelopes is left
as a follow-up. (#99)