Plans did change. The end solution (seen at [check-in 74aec5dd1df95b56](src:/info/74aec5dd1df95b56)) was to refactor the logic that figures out which query in a cascade of nested and correlated queries a particular aggregate function belongs too. The new logic does not depend on subquery cursor numbers being greater than outer query cursor numbers. That constraint is no longer on the parse tree, and so no new assert() logic to check is was required. Should be working now.