cached resolution: Fixes #1711, #1716, #1719

To fix #1711, cached resolution started creating artificial `DependencyDescriptor`s recently (like 4 days ago) af9e520e2817f7bf38cbc3bb474bce4a310a04af, and went out as RC-3.
There are some issues with the implementation, which are reported as #1716 and #1719.
This PR adds scripted test that reproduces those issues and fixes for them, hopefully fixing all three issues.