Tinderbox Forum

Restricting agent scope to a specific path


(eastgate) #21
  1. I made a new document with two containers, c1 and c2.

  2. A made a note A, and an alias of A. I movedA itself into c1, and its alias into C2.

  3. I made an agent with the query: inside(c1) & inside(c2)

  4. The agent finds one note, A, which is inside both c1 and c2.


(Pat Maddox) #22

ah right, the original has to be inside one of them for it to work

  1. I made a new document with two containers, c1 and c2.
  2. I made a note A, and two aliases of A. I moved one alias into c1, and the other alias into C2.
  3. I made an agent with the query: inside(c1) & inside(c2)
  4. The agent finds nothing, even though aliases of A are inside both c1 and c2.

aliases-inside-but-not-found.tbx (55.7 KB)


(eastgate) #23

Thanks.

The original semantics held that

A note is inside(target) if it’s a child of the target note, or if one of its aliases is a child of the target note.

More precisely, inside() was true if the note was a child of the target, or if this note, an alias, was a child of the target. This, as you observed, is always false for two aliases, since different notes are this in each case.

Starting with b358, we’ll change this slightly:

A note is inside(target) if it’s a child of the target note, or if any of its aliases is a child of the target note.


(Pat Maddox) #24

Cool! I think this change will make the inverse true as well, correct?

A note is not inside(target) if it is not a child of the target note, and if none of its aliases is a child of the target note.

See this document, where inside(c1) & !inside(c2) finds the note, even though one of its aliases is inside c1.*

alias-inside.tbx (56.2 KB)

* I understand why it does that right now (the original and the second alias are both inside not inside c1), but it still trips me up – and other people


(eastgate) #25

Yes: the revised inside() agrees that no notes are inside(c1) & (!inside(c2))


(Mark Anderson) #26

RE descendedFrom() & inside() behaviours it would be much easier if the default was to match only originals in respective scope and use an optional boolean argument to tell the operator to also match where only an alias is in scope (as an original always trumps if both are in scope).

I respect that the original ambiguities go back >15 years to when action query code was a lot less complex (inside() used to be #inside()). Not it is more complex, having clearer demarcation treatment of how aliases matches modify results would IMO help. Also, IIRC the alias-match aspect tended to bite when trying to use a ‘reverse’ containment, i.e. checking not inside/descended from.