I was sitting here reading the paper ‘Impossibility of Distributed Consensus with One Faulty Process‘ and came upon this lemma:
Lemma: Suppose that from some configuration C, the schedules µ1 and µ2 lead to configurations C1, C2, respectively. If the set of processes taking steps in µ1 and µ2, respectively, are disjoint, then µ2 can be applied to C1 and µ1 can be applied to C2, and both lead to the same configuration C3.
Proof: The result follows at once from the system definition, since µ1 and µ2 does not interact.
I realized this could be rewritten with CQRS vocab:
Call all events resulting from applying a command onto an entity, a schedule.
Suppose that from some initial state of an aggregate C, the schedules µ1 and µ2 lead to states C1, C2, respectively. If the commands resulting in schedules µ1 and µ2, respectively, are disjoint, then µ2 can be applied to an aggregate in state C1 and µ1 can be applied to an aggregate in state C2, and both lead to the same final aggregate state, C3.
This gives us the vocabulary for reasoning about when commands cause the same end state, no matter their ordering – they are then disjoint! We can start writing code like this (pseudo):
could simply hash all fields and compare the hash.
There would also need to be a method for specifying what commands require previously sent commands to be applied, filtering out those 2-variations of commands which don’t share common initial states from previously applied schedules.
Would this hold? Comments?