OP you have described virtual partner which has been around for a decade or so. If you ride somewhere and save it as a course, either using the device or a computer it will record the timings and use this to create a virtual opponent against whom you can race. If you beat it, it uses the new fastest time next time
But you have to select to follow the course, it won’t automatically recognise you are on a stored course.
However if you create a route on a computer and save it as a course, the software you use will have to make up the timing data according to some algorithm; Tracklogs uses extended Naismith, but bikehike just uses average speed I think.
If you save a route as a track rather than a course, there is no timing data, iirc.