OK, this is what I suspected.
The approach I took in the code posted upthread basically does that. A speedup is possible by not looking at all the links contained in the text of an annotation document: we can instead take advantage of the fact that DEVONthink provides a list of incoming links to each document in a database. The approach is to look at the incoming links of the annotation document and compare the source record’s annotation
property to the annotation document, and figure out which incoming link document points to the annotation document. Hopefully the number of comparisons will be small in most cases. (In fact, it seems likely that most annotation documents have only one incoming link.)