feat!: Member集約を3状態モデルに再設計し、DiscordAccountを独立集約に分離#90
Closed
KinjiKawaguchi wants to merge 8 commits intodevelopfrom
Closed
feat!: Member集約を3状態モデルに再設計し、DiscordAccountを独立集約に分離#90KinjiKawaguchi wants to merge 8 commits intodevelopfrom
KinjiKawaguchi wants to merge 8 commits intodevelopfrom
Conversation
29393c4 to
988d3a8
Compare
988d3a8 to
af3afec
Compare
室員管理の仕様に基づきMember集約をリモデリング: - 識別子をUUIDから大学メールアドレスに変更 - discriminated unionで室員/未確認/元室員の3状態を型レベルで表現 - 状態に応じた属性の有無を型システムで強制 - イミュータブルな集約(操作は新インスタンスを返す) - ドメインイベントの定義と集約内での収集機構を追加 - DiscordAccountを集約から除外(外部サービス連携コンテキストへ移行予定) - Departmentを削除しAffiliation(shared kernel)で所属を表現 BREAKING CHANGE: Member集約のAPIが全面的に変更 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- ExternalServiceLink集約: 外部サービスとのアカウント紐付けを独立した境界づけられたコンテキストとして新設 - Faculty集約: 学部・学科のマスターデータ管理(学科の追加・削除、同名重複チェック) - GraduateSchool集約: 研究科・専攻のマスターデータ管理(課程別管理、専攻の追加・削除) - 不要な例外を削除(DiscordAccount系、InvalidDepartment)し、マスターデータ用例外を追加 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
組織構造はuniversityStructure.tsの型定義で管理されており、 ランタイムCRUD用のエンティティは不要。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- MemberSuspendedをMemberUnconfirmedにリネーム(クラス名・メソッド名との整合性) - 未使用のExternalServiceUnlinkedイベントを削除(YAGNI) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
対応サービスを型レベルで制限し、不正な値の混入を防ぐ。 現時点ではDiscordのみ対応。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
986b7f9 to
f615833
Compare
UUIDをDBのPKおよびEvent集約からの参照用の技術的識別子として保持する。 emailはビジネス上の識別子として併存する。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
汎用的なExternalServiceLinkはSpeculative Generalityだったため削除し、 Discord固有のDiscordAccount集約として再設計: - DiscordId(Branded Type)で型安全に識別 - nickNameをDiscord固有の属性として保持 - MemberIdでMember集約を参照 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2 tasks
personalEmailは任意項目のため、null/undefinedではなくRecorded<Email>で 記録有無を明示する。Recorded型をKarte集約からshared kernelに移動。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was referenced Mar 22, 2026
Merged
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.
Why
室員管理システムのドメインモデル設計書に基づき、ドメイン層を再設計する。
現行のMemberは単一クラスで全状態を扱い、Discord連携やDepartment(CS/BI/IA等)を集約内に持つ構造だが、仕様で求められる室員/未確認/元室員の状態遷移やAffiliationベースの所属管理に対応できていない。
What
Member集約の3状態モデル
ActiveMember(室員): MemberId, email, 名前, 個人メール, 学籍番号, 所属UnconfirmedMember(未確認): MemberId, email, 名前, 個人メールFormerMember(元室員): MemberId, email, 名前, 個人メールtype Member = ActiveMember | UnconfirmedMember | FormerMember設計上の特徴
MemberId(UUID, Branded Type)は技術的識別子(DB PK, Event集約からの参照用)、emailはビジネス識別子pullDomainEvents()で取り出し可能ドメインイベント(12種)
室員登録、除籍、再登録、未確認移行、確認復帰、内部進学、転学部、転学科、転専攻、学籍番号変更、名前変更、個人メールアドレス変更
DiscordAccount集約(独立した境界づけられたコンテキスト)
DiscordId(Branded Type)で型安全に識別nickNameをDiscord固有の属性として保持MemberIdでMember集約を参照削除・整理
DiscordAccount(Member集約内のエンティティ)→ 独立集約に移行Departments(CS/BI/IA等のenum)→ Affiliation(shared kernel)に置き換え後続PRで対応するもの(Expand → Migrate → Contract)
Test plan
🤖 Generated with Claude Code