Skip to content

refactor(common): each domain event names the kind it is stored under once - #608

Merged
PiquelChips merged 1 commit into
mainfrom
refactor/544-sdk-event-kinds
Nov 21, 2026
Merged

PiquelChips merged 1 commit into
mainfrom
refactor/544-sdk-event-kinds

Conversation

@PiquelChips

@PiquelChips PiquelChips commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Part of #544.

Every DomainEvent kind was written twice. Serde derived the stored kind from the variant's name with rename_all = "snake_case", and DomainEvent::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.

HistoryEntry had already solved this with history_entry! (events/history.rs): each variant names its kind once, in #[serde(rename = "…")], and the macro generates kind() from it. That macro is now tagged_enum! in events/mod.rs, shared by both enums. DomainEvent's variants each carry their stored name, and kind() is generated from it.

  • Test kept, renamed: event_kinds_match_their_serde_tags is now one_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 from one_event_per_kind, and this test is what proves that list covers every variant.
  • docs/dev/extending/admin-operation.md now says a new event names its stored kind in its rename, instead of the compiler asking for a kind arm.
  • Files edited outside the SDK area: none.

Proof the stored kinds are unchanged:

  • Each rename was copied from the old kind() arm, and a script checked that every one equals its variant's snake_case name, which rename_all produced.
  • The renamed test passes against the new enum. It serializes every event and compares the deserializer's tag list with kind().
  • cargo semver-checks -p sourceorigin-common --baseline-rev origin/main: no semver update required. kind is still pub 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)

@PiquelChips PiquelChips added sdk Rust and TypeScript SDKs refactor No behviour changes labels Nov 20, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in sourceorigin.dev Nov 20, 2026
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: baa43134-4671-4356-b545-ff1f1f7d87bf
Commits

Reviewing files that changed from the base of the PR and between abc4bcf and 3fce6dc.

Files selected for processing: 4

  • crates/common/src/events/history.rs
  • crates/common/src/events/mod.rs
  • crates/common/src/tests.rs
  • docs/dev/extending/admin-operation.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@PiquelChips
PiquelChips marked this pull request as ready for review November 20, 2026 10:05
@PiquelChips
PiquelChips marked this pull request as draft November 21, 2026 14:00
@PiquelChips
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
PiquelChips force-pushed the refactor/544-sdk-event-kinds branch from ba15f90 to 3fce6dc Compare November 21, 2026 16:15
@PiquelChips
PiquelChips added this pull request to the merge queue Nov 21, 2026
Merged via the queue into main with commit bb278a2 Nov 21, 2026
14 checks passed
@PiquelChips
PiquelChips deleted the refactor/544-sdk-event-kinds branch November 21, 2026 18:10
@github-project-automation github-project-automation Bot moved this from Needs Triage to Done in sourceorigin.dev Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor No behviour changes sdk Rust and TypeScript SDKs

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant