Skip to content

Fix/enforce archive state as terminal - #59

Merged
amodelandme merged 3 commits into
devfrom
fix/enforce-archive-state-as-terminal
May 1, 2026
Merged

amodelandme merged 3 commits into
devfrom
fix/enforce-archive-state-as-terminal

Conversation

@amodelandme

Copy link
Copy Markdown
Owner

Summary

Flag now treats archival as a terminal state. Every mutation method on the entity
(SetEnabled, UpdateStrategy, UpdateName, Update, Archive) carries a guard
clause as its first statement: if IsArchived is true, the method throws a new
FlagDomainException whose message names the flag. The exception extends
BanderasException with StatusCode = 409, so the existing GlobalExceptionMiddleware
maps it to a 409 Conflict ProblemDetails response with no middleware change. The
change is contained entirely within the Domain layer — no controllers, services,
repositories, or migrations were touched.

Changes in this PR

  • Domain — new FlagDomainException (sealed, BanderasException-derived, 409); guard clause added as the first statement of all five Flag mutation methods
  • Tests — new FlagArchivedInvariantTests (10 tests: 5 archived-guard + 5 happy-path baselines)
  • Docs — current-state.md, roadmap.md, and the Flag DDD backlog updated; spec + implementation notes added under Docs/Decisions/enforce-archive-state-as-terminal - PR# 59/

Spec

Docs/Decisions/enforce-archive-state-as-terminal - PR# 59/spec.md

Implementation Notes

Docs/Decisions/enforce-archive-state-as-terminal - PR# 59/implementation-notes.md

Definition of Done

  • FlagDomainException exists in Banderas.Domain/Exceptions/ and extends BanderasException with StatusCode = 409
  • Guard clause is the first statement in SetEnabled()
    (SetEnabled, UpdateStrategy, UpdateName, Update, Archive) carries a guard
    clause as its first statement: if IsArchived is true, the method throws a new
    FlagDomainException whose message names the flag. The exception extends
    BanderasException with StatusCode = 409, so the existing GlobalExceptionMiddleware
    maps it to a 409 Conflict ProblemDetails response with no middleware change. The
    change is contained entirely within the Domain layer — no controllers, services,
    repositories, or migrations were touched.

Changes in this PR

  • Domain — new FlagDomainException (sealed, BanderasException-derived, 409); guard clause added as the first
    statement of all five Flag mutation methods
  • Tests — new FlagArchivedInvariantTests (10 tests: 5 archived-guard + 5 happy-path baselines)
  • Docs — current-state.md, roadmap.md, and the Flag DDD backlog updated; spec + implementation notes added
    under Docs/Decisions/enforce-archive-state-as-terminal - PR# 59/

@amodelandme
amodelandme merged commit df36d0b into dev May 1, 2026
9 checks passed
@amodelandme
amodelandme deleted the fix/enforce-archive-state-as-terminal branch May 1, 2026 22:04
@amodelandme amodelandme mentioned this pull request May 5, 2026
8 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant