Concepts
Duplicate-safe command model
Remember an accepted command and its result in a bounded teaching context; duplicate replay does not repeat the state change.
Formal Syntax & Structure
javascript syntaxjavascript
handle(commandId, validatedPayload)Working Example
Example Snippetjavascript
(async () => {let total=0;const seen=new Map();function add(id,n){if(seen.has(id)){const old=seen.get(id);return old.n===n?old.result:"conflict";}total+=n;seen.set(id,{n,result:total});return total;}console.log(add("A",2),add("A",2),add("A",5),total);})()