fix!: fence aggregate replay by event schema version - #246
Open
patrickleet wants to merge 1 commit into
Open
Conversation
Fence generated handlers by the declared event schema version after upcasting, before decoding or invoking domain code. BREAKING CHANGE: aggregate! registrations for versioned handlers must declare version = N. Unsupported older and future event versions now fail replay even when their payload layout matches. Refs: incidents/aggregate-replay-event-version
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
An aggregate handler currently accepts any event with its registered name if the payload happens to decode. Because replay payloads are positional, an older or future schema with the same layout can silently apply the wrong domain semantics.
Generated replay now checks the event schema version after the existing upcaster stage and before decoding or invoking the handler. Rejected events cannot change aggregate state or append events. Both
#[sourced]andaggregate!use the same generated check, including snapshot-tail loads through native and cell repositories.For example, this handler accepts version 2 directly and version 1 only through a declared upcaster to version 2:
Lower-level registrations now declare the handler version explicitly:
Omitted versions default to 1, consistent with
#[event]and#[digest]. The README documents the syntax and migration.Breaking change
aggregate!registrations for versioned handlers must declareversion = Nmatching their recorder. Unsupported older and future versions now fail replay even when their payload layouts match. Existing stored events are unchanged; supported older events require a complete upcaster chain to the handler version.Validation
cargo test --workspace --all-targetspassed.cargo test --workspace --all-features --all-targets --quietpassed.rustfmt --checkandgit diff --checkpassed.The all-features run uses the repository's normal environment-gated integration tests; it does not claim a live celld deployment test.
Whole-workspace
cargo fmt --all -- --checkstill reports pre-existing differences in eight untouched files on basef095c863:src/lib.rs,src/microsvc/cell_host/{causal,command}.rs,src/microsvc/mod.rs,src/microsvc/service/{routes,runtime,tests}.rs, andtests/causal_wait_path/main.rs. This PR leaves that unrelated formatting out.Stacked on #245; this PR contains only the replay-version change.