AppIntents EntityPropertyQuery, how does "Filter Entity where" work?

When you correctly implement EntityPropertyQuery on an AppEntity, Shortcuts will expose a "Find Entity" action that calls into entities(matching:mode:sortedBy:limit:). This is demoed in the "Dive into App Intents" session and works as expected.

However, with this action, you can change the "All Entity" input to a list variable which changes the action text from "Find All Entity" to "Filter Entity where" still giving you the same filter, sort and limit options. This appears to work as expected too. But, what's unexpected is that this filter action does not appear to call any method on my AppEntity code. It doesn't call entities(matching:mode:sortedBy:limit:). One would think there would need to be a filter(entities:matching:mode:sortedBy:limit:) to implement this functionality. But Shortcut just seems to do it all on it's own. I'm mostly wondering, how is this even working?

Here's some example code:

import AppIntents

let books = [
  BookEntity(id: 0, title: "A Family Affair"),
  BookEntity(id: 1, title: "Atlas of the Heart"),
  BookEntity(id: 2, title: "Atomic Habits"),
  BookEntity(id: 3, title: "Memphis"),
  BookEntity(id: 4, title: "Run Rose Run"),
  BookEntity(id: 5, title: "The Maid"),
  BookEntity(id: 6, title: "The Match"),
  BookEntity(id: 7, title: "Where the Crawdads Sing"),
]

struct BookEntity: AppEntity, Identifiable {
  static var typeDisplayRepresentation: TypeDisplayRepresentation = "Book"
  var displayRepresentation: DisplayRepresentation { DisplayRepresentation(title: "\(title)") }
  static var defaultQuery = BookQuery()

  var id: Int

  @Property(title: "Title")
  var title: String

  init(id: Int, title: String) {
    self.id = id
    self.title = title
  }
}

struct BookQuery: EntityQuery {
  func entities(for identifiers: [Int]) async throws -> [BookEntity] {
    return identifiers.map { id in books[id] }
  }
}

extension BookQuery: EntityPropertyQuery {
  static var properties = QueryProperties {
    Property(\BookEntity.$title) {
      EqualToComparator { str in { book in book.title == str } }
      ContainsComparator { str in { book in book.title.contains(str) } }
    }
  }

  static var sortingOptions = SortingOptions {
    SortableBy(\BookEntity.$title)
  }

  func entities(
    matching comparators: [(BookEntity) -> Bool],
    mode: ComparatorMode,
    sortedBy: [Sort<BookEntity>],
    limit: Int?
  ) async throws -> [BookEntity] {
    books.filter { book in comparators.allSatisfy { comparator in comparator(book) } }
  }
}

The example Shortcut first invokes entities(matching:mode:sortedBy:limit:) with comparators=[], sortedBy=[], limit=nil to fetch all Book entities. Next the filter step correctly applies the title contains filter but never calls entities(matching:mode:sortedBy:limit:) or even the body of the ContainsComparator. But the output is correctly filtered.

AppIntents EntityPropertyQuery, how does "Filter Entity where" work?
 
 
Q