Unlike collection(), the function uri-collection() makes no attempt at parsing the document it finds in its collection (since Saxon 9.7); it simply just lists all of the URI's in the collection: https://www.saxonica.com/html/documentation/sourcedocs/collections.html.
So we could list ALL URIs in the project from the outset and then just resolve paths to see whether or not the thing exists.