Interfaces
How does the confirm-cancellation contract distinguish a retry from a new intent?
The load profile now applies to the confirm-cancellation command. Its payload contains the operating day, train service, source version and cancellation reason. An idempotency key recognises the same intent after a response is lost; an aggregate version protects the business state against concurrent changes.
Starting point Test a hotspot on a single train service separately.
Assumptions for the example case
Original fictional design: a regional rail line with dated services, stops and manually confirmed cancellations. An actual-status report is current at age < 90 seconds; at 90 seconds its timestamp is marked stale. All figures and test targets are illustrative assumptions.
Commands, retries and current state
Command and historical result
The key binds the full content; identical repetition provides the stored receipt.
Proposed API for this example
- POST
/bahnstoerung/{id}/commandsConfirm cancellation
- Input
- Operating day, train service, source version and cancellation reason; expected aggregate version, authorised role and stable command key.
- Result
- Durably stored business result and new version; version or content conflicts produce no partial effects. An accepted external request receives an open status.
- Retry behaviour
- The key is scoped to the actor, operation and business object. After authentication, first compare the existing result and canonical content: identical content returns the stored evidence; changed content produces a conflict. Only new keys trigger validation of the current version.
- GET
/bahnstoerung/{id}Read the current business state and reason for investigation.
- Input
- Authorised identity and business object.
- Result
- Train service with its current version, evidence and reason for pending work.
- Retry behaviour
- Repeating a read creates no business change; access is checked again.
Additional state changes
| Operation | Input | Result and protection |
|---|---|---|
| Accept an actual-status report | Source, operating day, train service, source version and timestamps | Accept the newer report; changed content under the same source key produces a conflict. |
| Correct a cancellation | Authorised dispatch role, train service and operating day, expected current aggregate version, newer evidenced source version, new status geplant or verspätet, correction reason and idempotency key | Only the explicit correction command reverses ausgefallen and returns a new status version with correction evidence. An ordinary delay report preserves the cancellation. Missing permission is rejected; a stale version or archived service produces a conflict; identical replay returns the same record. |
| Archive the operating day | Dispatch, end time and documented post-service reconciliation | Close the current status; retain late reports in history and investigate discrepancies. |
Accept an actual-status report
- Input
- Source, operating day, train service, source version and timestamps
- Result and protection
- Accept the newer report; changed content under the same source key produces a conflict.
Correct a cancellation
- Input
- Authorised dispatch role, train service and operating day, expected current aggregate version, newer evidenced source version, new status geplant or verspätet, correction reason and idempotency key
- Result and protection
- Only the explicit correction command reverses ausgefallen and returns a new status version with correction evidence. An ordinary delay report preserves the cancellation. Missing permission is rejected; a stale version or archived service produces a conflict; identical replay returns the same record.
Archive the operating day
- Input
- Dispatch, end time and documented post-service reconciliation
- Result and protection
- Close the current status; retain late reports in history and investigate discrepancies.
Messages across the external boundary
- Source contract
- GTFS distinguishes timetable references, real-time updates and timestamps. The cancellation and archiving rules in this case are our own assumptions.
- System responsibility
- Publication fails after the cancellation commit. Feed processing rereads the stored publication job and updates the display using the status version. An older report arriving late cannot reduce that version.
Source versions take precedence over arrival order
Source versions take precedence over arrival order.
A confirm-cancellation command may arrive again after a response is lost.
The operating day, train service, source version and cancellation reason must remain identical on replay. The exercise specifies the input and expected result.
- Alternative considered
- A key stored only in volatile memory loses its evidence on restart.
- Trade-off
- The confirm-cancellation journal requires durable retention and protected access.
- Reassess
- The documented retry window and journal volume determine the future archiving strategy.
Try it yourself
Predict the results of an identical confirm-cancellation retry, the same key with a different cancellation reason, and a new key with an old version.
A hint for your attempt
Retry identity and current state require separate checks.
Compare with a possible solution
- Identical
- The stored result for train service F-24 is returned; its effect is not repeated.
- Changed
- The same key with altered canonical content results in conflict.
- New intent with a stale version
- A new key with a stale version is rejected before any business change. The interface reloads the current state and asks the user to confirm the decision again.
Apply to your project
Which input fields make two change intentions different in your project?