Handle duplicate events and retries deliberately
Reading estimate uses 200 words per minute and excludes exercises, self-review and optional book descriptions. Earlier lesson checks are kept; revisit the expanded text if you completed the short edition.
Design an operation ledger and bounded retry policy that distinguishes duplicate events, attempts, known failure and unknown external outcomes without claiming exactly-once execution.
An event can arrive twice, and an authorised action can finish without its caller receiving a timely response. These are ordinary design cases, not reasons to assume that repeating everything is harmless. This lesson builds a fictional article publisher's operation ledger and retry policy. The classroom process remains on paper: no endpoint is called and no article is published. The aim is to distinguish duplicate notifications, repeated attempts and genuinely new intentions while preserving unknown outcomes until evidence supports the next transition.
In this lesson · 12 sections
- Separate an event, an intention and an attempt
- Define the logical operation record
- Use states that preserve what is known
- Explain the limited purpose of idempotency
- Walk a duplicate event before any attempt
- Handle an in-progress duplicate without starting over
- Treat timeout as missing timely evidence
- Reconcile using appropriate evidence
- Define retry eligibility and limits
- Handle parameter changes and identifier lifetime
- Test five histories rather than one happy path
- Deliver the publisher retry policy
1. Separate an event, an intention and an attempt
An event says something happened, such as article approved. An intention is the bounded business action proposed, such as publish draft D3 to destination S. An attempt is one effort to execute that intention. Two notifications about the same approval need not mean two intentions. Two attempts after a network problem need not mean two articles should exist. Naming these objects separately prevents the workflow from treating every received message as fresh permission to act.
Create a paper example: event E1 reports approval A7 for D3 at S. The workflow associates that with operation O9. If E1 is delivered again, the record should lead back to O9 rather than automatically create O10. A later approved revision D4 may represent a new intention under the publication policy, but that decision must be explicit. The identifier design should reflect the actual business meaning. A timestamp alone can make every duplicate look new, while an overly broad article title can merge actions that were genuinely different.
2. Define the logical operation record
For O9, record the action type, target, approved artefact version, approval reference, request parameters, current status and evidence of outcomes. Add attempts with their own times and response details. The operation record answers what was intended; the attempt records answer what was tried. Keep both so a later investigation can reconstruct the path instead of seeing only the final green or red label.
A stable key is useful only when the system actually enforces its meaning. A model remembering O9 in a prompt does not create durable duplicate protection across restarts or workers. A real design would need appropriate storage, uniqueness and coordination around the operation and, where relevant, a documented destination idempotency contract. The classroom ledger describes those requirements without claiming they are implemented. Write any unverified capability as a requirement to check before live connection, not as a reassuring assumption that an identifier by itself makes repeated external actions safe.
3. Use states that preserve what is known
The paper ledger uses not started, claimed or in progress, succeeded, known failed and outcome unknown. Define each. Not started means no recorded attempt has begun under the design's rules. In progress means an attempt is being handled. Succeeded requires appropriate completion evidence. Known failed requires evidence supporting failure. Outcome unknown means the available observations do not establish success or failure.
These states describe knowledge and process conditions, not merely how long the screen has waited. A timeout can move an attempt into unknown when the destination might already have accepted it. Do not assign known failed just to make the queue easier to clear. Also record whether the operation remains authorised and current. An unknown outcome does not preserve permission forever if the underlying approval has become invalid. Recovery needs to consider both what may already have happened and what actions are currently permitted, rather than treating retry as a purely technical response to a missing acknowledgement.
4. Explain the limited purpose of idempotency
Idempotency concerns the effect of repeating an operation under a defined contract. It is not a promise that every surrounding workflow executes exactly once. A destination may support a client request identifier with stated scope, parameter rules and retention period; another destination may not. AWS's Builders' Library discusses request identifiers and parameter validation as part of making retries safer. That source describes specific design principles, not a guarantee for the fictional publisher.
For the classroom policy, the same logical intention keeps the same operation identity across attempts. A new identifier should not be created merely because the previous response was slow. Equally, a changed destination or materially different payload must not be smuggled under an old key as though it were the same action. Record the intended parameters so the system can detect a mismatch. The precise enforcement mechanism depends on the implementation and destination contract. Until those are checked, describe the paper policy as a requirement rather than claiming duplicate publication is impossible.
5. Walk a duplicate event before any attempt
Suppose E1 arrives twice before O9 is started. The expected design behaviour is to recognise the same approved intention and keep one operation record. The second notification can be recorded as a duplicate observation without creating another external action. A durable uniqueness or equivalent coordination rule must enforce that behaviour in a real system; two workers each checking an empty list independently would not be enough.
Use this case to test the difference between a lookup and an atomic decision. If both workers can see not started and proceed without coordination, the paper rule has not specified how competing claims are resolved. Identify the required claim mechanism and the evidence it must preserve, while leaving its exact implementation for technical review. The lesson is not that a particular database feature solves every failure mode. It is that the design must explain why concurrent or repeated events cannot both obtain unintended permission to execute the same logical action.
6. Handle an in-progress duplicate without starting over
Now imagine O9 is already in progress when another copy of E1 appears. The expected route is to attach the observation to the existing operation and inspect its status, not begin another publication immediately. The workflow may return an existing progress response or wait under its documented rules. Whatever the interface displays, it should not mistake the arrival of a second event for evidence that the first attempt stopped.
An in-progress state also needs a recovery rule for abandoned work. A worker might stop before completing its record. A simple timer expiring does not establish whether an external side effect occurred. The recovery path must examine recorded attempts and available destination evidence before deciding what can be retried. If a lease or claim mechanism is used in an implementation, its expiration coordinates ownership of work; it does not erase the possibility that the previous owner already acted. Preserve that distinction in the paper walkthrough so recovery does not become another path to duplicate effects.
7. Treat timeout as missing timely evidence
In the central fictional case, O9's publication request reaches destination S, but the caller times out before receiving the response. Two histories fit the observation: S may have accepted the article, or the action may not have completed. The timeout alone does not choose between them. Record the attempt and move to outcome unknown with the unresolved question attached.
Do not automatically issue a new operation identifier to obtain a clean attempt. That can bypass any duplicate handling tied to the original intention. Also do not display a failure message that invites a user to click publish again without showing the unknown status. The user interface should preserve the uncertainty and direct the authorised operator towards reconciliation. This is a concrete example of why operational truth cannot be inferred from a caller's emotional experience of waiting. A slow or missing response is frustrating, but it is not evidence that the external world remained unchanged.
8. Reconcile using appropriate evidence
Define what the operator would inspect if the necessary authorised tools existed: the durable operation record, destination records associated with the operation or content version, and documented responses from the attempt. Evidence must be specific enough to distinguish the intended publication from another article with a similar title. A matching title alone may be insufficient if several drafts share it.
If evidence establishes that D3 was published at S under O9, record success and do not repeat the publication. If evidence establishes that no action occurred and the retry contract permits another attempt, proceed under the same logical intention and current authorisation. If evidence remains ambiguous, keep the unknown state and escalate to the named owner. The classroom policy does not invent a universal query that every destination supports. It states what evidence is needed and identifies the capability that must be verified before live use. Recovery should be constrained by what can actually be established.
9. Define retry eligibility and limits
Not every failure is helped by repetition. Invalid parameters or rejected authority usually require correction or a new decision, not another identical request. A temporary service issue may permit a retry under the destination's contract. Define eligible conditions, delay policy, maximum attempts and the owner after those limits are reached. Avoid a loop that treats every non-success as permission to try forever.
Separate the decision to retry from the waiting interval. A delayed repetition can still be wrong if the previous outcome is unknown and the destination lacks an appropriate idempotency mechanism. Conversely, a known safe retry should preserve the operation identity and parameters rather than disguising the same intention as new work. Keep the exact timing values as design choices to validate for the specific system. This lesson does not prescribe a universal delay schedule. Its requirement is that retries are deliberate, bounded and supported by the operation's current state, authorisation and documented external behaviour.
10. Handle parameter changes and identifier lifetime
Suppose an operator changes D3 to D4 while O9 remains unknown. The system cannot simply overwrite O9's parameters and retry. It must first preserve the uncertainty about the earlier action, then decide whether the new approved intention requires a separate operation or a specific revision route. Otherwise the ledger loses the ability to say which content may already exist at the destination.
A destination's duplicate-protection record may also have a limited lifetime. If an operation key is no longer recognised after that period, resending it may no longer have the effect the workflow expects. Verify that contract rather than assuming identifiers provide permanent protection. A local operation ledger can preserve history beyond the destination's window, but it cannot magically make an unsupported external operation idempotent. The design should state when human reconciliation is required and which claims remain unverified. This keeps a useful engineering technique from being presented as an exactly-once guarantee for the whole business process.
11. Test five histories rather than one happy path
Create a duplicate-before-start case, a duplicate-during-progress case, a confirmed success with a late response, a known failure eligible for retry and an unknown outcome without sufficient evidence. Add a parameter-mismatch variation to ensure the same key cannot silently authorise different work. Write expected records and routes before walking through the cases. These are fictional tests of the design, not live executions.
Inspect whether each history remains reconstructable. Can another reader see why a second event did not cause a second action? Can they tell which attempt timed out and what evidence later resolved it? Can they identify when the process must wait rather than retry? A one-success screenshot cannot answer these questions. The value of the test pack is that it challenges the assumptions most likely to disappear during an impressive demonstration: repeated delivery, competing workers, changed parameters and uncertainty about the external result. Preserve failed or unresolved test outcomes instead of editing the history to look clean.
12. Deliver the publisher retry policy
The final policy contains event identity, logical operation identity, parameter record, durable enforcement requirements, attempt history, states, retry eligibility, reconciliation evidence, limits and exception ownership. State explicitly which destination capabilities still need verification. No sentence in a prompt should be credited with enforcing uniqueness or proving an external result. Those are system properties that require appropriate implementation and testing.
Walk O9 through the central timeout case one last time. The correct conclusion is unknown until evidence supports success or known failure. If the destination already accepted D3, the recovery route records that result without another publication. If evidence is insufficient, the owner receives a specific unresolved operation rather than a generic failed task. The next lesson examines access scope: even a well-designed retry path should not have permission to inspect or change unrelated records. Reliable repetition and limited authority are complementary parts of a business workflow, not substitutes for one another.
Fictional publication O9 targets D3 at destination S. The destination may accept it before the caller times out, so the record becomes outcome unknown. A second event points to O9 rather than automatically creating a new publication. Reconciliation checks appropriate destination and durable-operation evidence; a stable key needs actual enforcement and a verified external contract to support safe repetition.
Write the fictional publisher retry policy with event and operation identities, parameters, states, durable-enforcement requirements and check-before-retry rules. Walk duplicate-before-start, in-progress duplicate, known-success, known-failure and unknown-outcome cases. Include a parameter mismatch and identify what evidence and owner are required when the result cannot be established.
Notes stay in this browser. Avoid sensitive personal information.
Compare your answer · Self-review guide
A strong policy preserves one logical intention across attempts, records parameters and outcomes durably and uses verified destination behaviour rather than prompt memory. It does not treat a timeout as failure, retry rejected authority or claim that an idempotency key guarantees exactly-once workflow execution. Ambiguity has a reconciliation owner and bounded next steps.
This is an indicative answer, not an automatic assessment of your written work. Check your reasoning, units and assumptions.
What does a timeout prove?
The source document that tried to take control
Separate source material, permission to publish and an uncertain external outcome.
Work through the fictional case →Continue beyond the lesson

Decision
Gabriel Nicolaev — CyGuru
Uncertainty after a timeout
CyGuru’s examination of hesitation, choosing and the consequences of postponement across work and personal life. Use it as a reflection companion while preserving the evidence and uncertainty in your Academy decision records.
The retry decision must distinguish missing confirmation from failure. The companion question concerns acting under uncertainty; the technical reconciliation policy comes from the workflow design.
What do you actually know about the external action’s outcome?
Specify checks for succeeded, failed and unknown outcomes before allowing a repeated action.
Add your response to the lesson notes ↑How to use this companion
A planning and judgement companion for this AI exercise. The book is not an AI implementation manual; technical behaviour, access and integrations must be checked against the relevant documentation.
An editorial pairing by theme, not a book chapter summary. Your lesson and exercise remain available independently of the book.
Sources & further study
Original Academy explanations, fictional examples and exercises. The primary sources below support the lesson concepts; they are not sources for every teaching scenario.
Reviewed 6 November 2026.
An academy practice exercise. Adapt it to your circumstances.
