The problem is cased by this patch:
https://commits.kde.org/krita/d5418bb57535a3719e4de8565e439e03fd0f6002
DeferredUseStore::checkPendingUse() issues a shape in a place, where the source of the use happens, not at the point of <use> tag itself. That effectively reorders the shapes and they are not in the ''document order'' any more.
The solution: the shape added by DeferredUseStore::checkPendingUse() should be added at the point where the <use> tag was preset, not at the place of the shape itself