inside() does have an odd behaviour in relation to other enclosure query terms like
descendedFrom() when it comes to aliases. I tried your test and extended it a bit including trying it in a non-root container. Same problem. But there is a fix. The over-count is other instances within the same container/map of notes on the adornment (whether original or alias).
find() returns a list of paths. So we can do:
The odd behaviour of
inside() is that it returns paths of all instances (originals and aliases) from anywhere of a note what has an instance inside the stated container.
So, if we add another alias of Note 1 and stick it elsewhere in the document, there is now an over-count of one as
.unique is acting on this list:
Got to head to a mtg, but I guess the next step is this which looks - from a quick test - to work:
Of course you could have two original notes called ‘Note 1’ on the same map in which case the count would be off at it would remain at 2. It’s a pain there isn’t a version of
inside() that actually works as the word implies! (It’s been a regular feature suggestion).