Repository navigation
refactor(common): each domain event names the kind it is stored under once - #608
Merged
Merged
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 6 minutes. View limit details
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. |
PiquelChips
marked this pull request as ready for review
November 20, 2026 10:05
PiquelChips
marked this pull request as draft
November 21, 2026 14:00
PiquelChips
marked this pull request as ready for review
November 21, 2026 14:38
… serde rename DomainEvent wrote each kind twice, by serde's rename_all and by hand in kind(), with a 270-line test keeping the two equal. It now uses the macro HistoryEntry already used, renamed tagged_enum! and shared by both, which writes the rename and generates kind() from it.
PiquelChips
force-pushed
the
refactor/544-sdk-event-kinds
branch
from
November 21, 2026 16:15
ba15f90 to
3fce6dc
Compare
PiquelChips
enabled auto-merge
November 21, 2026 16:16
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.
Part of #544.
Every
DomainEventkind was written twice. Serde derived the storedkindfrom the variant's name withrename_all = "snake_case", andDomainEvent::kind()spelled all 68 out again by hand. A 279-line test,event_kinds_match_their_serde_tags, built one event of every kind to check that the two agreed. Renaming a variant in Rust also silently changed the name it is stored under.HistoryEntryhad already solved this withhistory_entry!(events/history.rs): each variant names itskindonce, in#[serde(rename = "…")], and the macro generateskind()from it. That macro is nowtagged_enum!inevents/mod.rs, shared by both enums.DomainEvent's variants each carry their stored name, andkind()is generated from it.event_kinds_match_their_serde_tagsis nowone_event_per_kind_covers_every_variant.kind()and the serde tag come from the same literal, so they can't disagree any more. But fix(auth): the security events count includes picture and notification changes, like the history #600, merged since, builds its security-history test fromone_event_per_kind, and this test is what proves that list covers every variant.docs/dev/extending/admin-operation.mdnow says a new event names its stored kind in its rename, instead of the compiler asking for akindarm.Proof the stored kinds are unchanged:
kind()arm, and a script checked that every one equals its variant's snake_case name, whichrename_allproduced.kind().cargo semver-checks -p sourceorigin-common --baseline-rev origin/main: no semver update required.kindis stillpub const fn kind(&self) -> &'static str.just test -p sourceorigin-common --all-features(44/44), doc tests (24), clippy with and without--all-features, rustdoc with-D warnings,just rust unused,just docs.Note
Written by Claude Opus 5.5 in Claude Code, from an audit by a Claude Opus 5.5 subagent and reviewed by Claude Opus 5.5 (via T3 Code)