Brief
Identify stream repetitions and process commands idempotently without discarding a genuine second command.
The control room shows four lines under SUPPLIER-SVC. Voss points to the screen and declares four openings. Imani gives you event IDs E1, E1, E3, E2; Mara adds command IDs OPEN-17, OPEN-17, OPEN-17, OPEN-18. Prepare an answer before the fictional meeting without deleting messages or activating a door. There is no exercise timer.
Your mission
- Count messages, distinct event IDs, and distinct command IDs.
- Identify the exact replay and the new delivery of an old action.
- Name the commands to apply once each.
- Explain why SUPPLIER-SVC cannot identify a person.
How to check your work
- 4 messages, 3 event IDs, 2 command IDs.
- Second line repeats E1; third has new E3 but OPEN-17 was already requested.
- OPEN-17 then OPEN-18, once each.
- A technical identity alone is insufficient to attribute human action.
Course example
messages = [
{"event_id": "E1", "command_id": "OPEN-17", "credential": "SUPPLIER-SVC"},
{"event_id": "E1", "command_id": "OPEN-17", "credential": "SUPPLIER-SVC"},
{"event_id": "E3", "command_id": "OPEN-17", "credential": "SUPPLIER-SVC"},
{"event_id": "E2", "command_id": "OPEN-18", "credential": "SUPPLIER-SVC"},
]
seen_events, applied_commands = set(), set()
for message in messages:
seen_events.add(message["event_id"])
if message["command_id"] not in applied_commands:
applied_commands.add(message["command_id"])
print("apply", message["command_id"])
print("messages", len(messages))
print("unique_events", len(seen_events))
print("unique_commands", len(applied_commands))