From 187f98fc528712cf912ede7fecdc4fe9eb97c874 Mon Sep 17 00:00:00 2001 From: Lukas Date: Tue, 3 Mar 2026 18:06:13 +0100 Subject: [PATCH] Relax INV-1/INV-2 in 001-advance-turn spec to allow empty encounters Prepares for 002-add-combatant by treating an empty combatant list as a valid aggregate state (activeIndex must be 0). AdvanceTurn behavior on non-empty encounters is unchanged. Co-Authored-By: Claude Opus 4.6 --- specs/001-advance-turn/spec.md | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/specs/001-advance-turn/spec.md b/specs/001-advance-turn/spec.md index e0ef176..ef315e3 100644 --- a/specs/001-advance-turn/spec.md +++ b/specs/001-advance-turn/spec.md @@ -82,11 +82,20 @@ domain events. ### Edge Cases -- Empty combatant list: AdvanceTurn MUST reject with an error. +- Empty combatant list: valid aggregate state, but AdvanceTurn MUST + return a DomainError (no state change, no events). - Single combatant: every advance wraps and increments the round. - Large round numbers: no overflow or special-case behavior; round increments uniformly. +## Clarifications + +### Session 2026-03-03 + +- Q: Should an encounter with zero combatants be a valid aggregate state? → A: Yes. Empty encounter is valid; AdvanceTurn returns DomainError. +- Q: What is activeIndex when combatants list is empty? → A: activeIndex MUST be 0. +- Q: Does this change any non-empty encounter behavior? → A: No. All existing acceptance scenarios and event contracts remain unchanged. + ## Domain Model *(mandatory)* ### Key Entities @@ -113,10 +122,13 @@ MUST be verified by tests. ### Invariants -- **INV-1**: An encounter MUST have at least one combatant. - Operations on an empty encounter MUST fail. -- **INV-2**: activeIndex MUST always satisfy - 0 <= activeIndex < len(combatants). +- **INV-1**: An encounter MAY have zero combatants (an empty + encounter is a valid aggregate state). AdvanceTurn on an empty + encounter MUST return a DomainError with no state change and no + events. +- **INV-2**: If combatants.length > 0, activeIndex MUST satisfy + 0 <= activeIndex < combatants.length. If combatants.length == 0, + activeIndex MUST be 0. - **INV-3**: roundNumber MUST be a positive integer (>= 1) and MUST only increase (never decrease or reset). - **INV-4**: AdvanceTurn MUST be a pure function of the current