When a State Transition Can Be Repeated

An idempotent transition reaches the same intended state when the same operation is applied again.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Compare two commands
  2. Include external observations
  3. Trace what survives a repeated action
  4. Include notification and audit effects in the guarantee

Compare two commands

Setting a reminder to disabled twice leaves it disabled. Toggling twice returns it to its starting state. The goal of each command belongs in the transition table, where the repeated input can be tested in the new state.

Include external observations

A command may keep the reminder disabled and still emit a duplicate notification. Decide whether notifications are part of the command's observable behavior and test for them. Return values and observable effects help specify what repeat safety actually promises.[1][2]

Trace what survives a repeated action

A setting operation can assign a reminder's enabled field to false. Starting at true, the first call makes it false. Another identical call leaves it false. A toggle from true goes to false and a second toggle returns to true, so a retry would behave differently. In a transition table, write the result of the same event from the already updated state. See state transitions for modeling the complete before and after.

Include notification and audit effects in the guarantee

The setting can stay false while the operation sends a second notification. If the feature promises one notification per actual change, only emit that effect for a qualifying transition or coordinate deliveries using a documented request identity. An ambiguous timeout can leave the original caller unsure whether the action finished. Retried operations explains why that case matters.

Test two identical requests after starting in three states: enabled, already disabled, and absent. Check both the stored field and any emitted records. A repeated delivery of one intent and a distinct new action can require different outcomes under the interface.

References

  1. Python Software Foundation, Python Tutorial: Control Flow ↩
  2. Python Software Foundation, Python Language Reference: Expressions ↩