Suppose we want to traverse a spec that caused some spec error, from the root spec embedded in the explain-data to a leaf of the pred that was the actual cause of the error.
We can usually use ath info in the explain-data for such a purpose:
If we traverse the spec tree along the ath, we can eventually reach the leaf pred that raised the spec error.
In some cases, however, it doesn't hold since some specs such as s/merge, s/and and s/& don't put any clue into ath that tells which subspec actually raised the error:
To achieve our purpose even in those cases, we have to make a nondeterministic choice: that is, choose a subspec arbitrarily and try traversing it down, and if something is wrong along the way, then backtrack to another subspec and so on.
From my experience that I implemented that backtracking algorithm in a library I'm working on (repo), I think it's much harder to implement correctly than necessary. In fact, my implementation is probably broken in some corner cases, and I don't even know if it's possible in theory to implement it completely correctly.
To make it easier to implement the spec traversal, this ticket proposes adding the index into ath that indicates which subspec raised the spec error for s/merge, s/and and s/&, as follows:
The enhancement, though it is indeed a breaking change, should reduce radically the effort needed to write the code traversing specs along the ath.