Here's the general process:
This process might be triggered by something like @card.setting(:form).
NOTE: while the two steps above are a good short representation of the process, it's possible we may want a hybrid approach. When we're looking for a given setting, we might only need the strongest pattern, in which case loading the entire pattern list could be overkill. In that case, we might decide to construct only as much of the pattern list at any given time as we need to find a setting. At first glance, that looks unlikely to be worth the effort, especially if a card gets lots of viewings between pattern-precedence-altering events.
A second, important, use case involves performing a WQL search and having it further limited by a certain pattern. The only instance of this we've considered so far is returning only cards that the user has permission to read, which means relying on the read permission setting (see Pattern Cards+permissions ). But we might imagine it coming up again for bulk updates, bulk deletes, etc. One route would be to cache the read permission as we have done, but this is complicated by the new permissions design in that a given card might have multiple parties. Another possibility is that we cache the id of the +*read setting card that governs each card, and for each user we cache ids for all the +*read cards that grant the user permission. Oooh. That's kind of cool. The trick there is that we'd have to be able to update +*read id caches when new settings emerged or pattern precedence shifted. But if we want (a) to be caching permissions and (b) to have a means of updating lots of permissions at once, this is probably a problem we're going to have to face in one form or another. (Needs further discussion).