Axis 08 · Confluence: Does the order inputs arrive in matter?

Two people editing a shared list. It should not matter who adds their item first: the final list should be the same. A result is confluent when the order of the inputs does not change it.

The result was taken from the first line, so adding the same lines in another order gave another result. Two rebuilds of the same inputs published different output, depending only on the order a directory listing happened to return them.

public static readonly Constraint<Order> LabelIgnoresLineOrder = Constraints<Order>.OrderIndependent(
	o => o.Lines,
	(o, lines) => o with { Lines = lines },
	o => o.Label);
		
  1. the items
  2. how to rebuild with them in another order
  3. the result that must not change

It takes many orders, lists their items in a different order each time, and compares the result. When it finds a difference it shrinks the reordering to the smallest one that still changes the result. It checks that some order had at least two items, since one item has no other order.

Confluence failed.

Rule broken first-sku-is-the-label: the result depends on the order the items are listed in. Started from Order { Lines = [OrderLine { Sku = "pear", Quantity = 3, Price = 17 }, OrderLine { Sku = "apple", Quantity = 5, Price = 16 }], Status = Pending, Version = 2, Total = 131, Label = "apple,pear" } Items reordered as [1, 0] (positions in the original list) Result different from the original order's

Law The order things arrive in does not change the result. Consequence Two runs over the same inputs publish different outputs depending only on the order they were listed in.

Smallest case found, after 2 shrinks. To run this case again: .Seed("dsRrQRlF6jV2")

How to read this:

  • Started from is the order. Items reordered as [1, 0] means the second item moved to the front.
  • Result says it differs from the original order's result.

A scenario test lists items in the order the author typed them. The bug only shows when someone lists them another way.

In docs-builder, merging release-note bundles and building the version index are both tested to give the same result whatever order the inputs arrive in.


Previous: 07 Liveness · Next: 09 Vacancy · All nine axes