Atomic addCombatant with optional initial state #15
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The
addCombatantdomain function currently only accepts(encounter, id, name), forcing the hook layer to compose multiple sequential domain calls and directstore.save()mutations to set initial stats when adding from bestiary or player characters. This makes combatant creation non-atomic, bypasses domain validation for some fields, and produces no events for fields set via the bypass. ExtendingaddCombatantto accept an optionalCombatantInitbag makes creation atomic and moves all validation into the domain.Acceptance Criteria
addCombatantdomain function accepts an optionalCombatantInitparameter (maxHp, ac, initiative, creatureId, color, icon, playerCharacterId)CombatantAddedevent is emitted containing the full initial stateaddFromBestiaryin the hook uses the new atomicaddCombatantinstead of multi-step compositionaddFromPlayerCharacterin the hook uses the new atomicaddCombatantinstead of multi-step compositionstore.save()bypass remains in either compound operationaddCombatantwithCombatantInitContext
docs/agents/research/2026-03-25-combat-state.md(see "Follow-up Analysis" section)