✅ Execute does not mutate input state
| Category | Ability |
| Status | Passing |
| Test | tests/test_abilities_complex.py::TestCopyOnWrite::test_execute_does_not_mutate_input_state |
All handlers must return new state without mutating input. Copy-on-write is enforced.
Preconditions
-
Focalor in lane 0, Duban (enemy) in lane 1
-
Original state: Duban has 0 damage
Action
- Execute Great Blue Spot
result = execute_ability(state, focalor_p, ability_idx=0, choices={"lane": 1})
duban_in_orig = next(d.damage for d in state.demons if d.unit_id == "001")
Expected Postconditions
-
result.demons[Duban]: fatally wounded (15 Fixed on 6 HP)
-
state.demons[Duban]: 0 damage (original unchanged)
Assertions
assert duban_in_orig == 0, "Input state was mutated — copy-on-write violated"
assert not any(d.unit_id == "001" for d in result.demons), (
"Duban must be removed from result board"
)