Picolab / pico-engine

An implementation of the pico-engine hosted on node.js
http://picolabs.io/
MIT License
43 stars 8 forks source link

How to deal with collisions among rulesets? #613

Open b1conrad opened 2 years ago

b1conrad commented 2 years ago

There are some dimensions of potential collision, as we have picos with more and more rulesets (I'm looking at you, pico with 28 rulesets and 62 channels).

  1. RIDs. I pico can have only one ruleset with a given identifier, and this is mostly dealt with by a naming convention like that of Java classes, using a controlled domain name in reverse order followed by an identifier meaningful to the purpose of a ruleset. This "convention makes globally unique RID choice easier." (quoted from Grammar, section Ruleset identifier (RID)).
  2. Channel tags. Any ruleset can create channels within a pico. Each channel is identified internally with a globally unique identifier assigned by the pico engine. However, in practice it is identified by its "tags" which are assigned by the programmer who writes the ruleset. Collisions here could be troublesome (any ruleset can delete any channel of the pico). A possible enhancement might be to include the RID of the creating ruleset as an attribute of each channel; that data point could allow disambiguation, and prevent removal if the RIDs don't match.
  3. Event domains. When an event comes in on one of the pico's channels, all rulesets are consulted to see if they have rules that need to react to the event (see Event Loop Introduction for more details). This makes it possible for one ruleset to "eavesdrop" on events that other rulesets use. This can be very useful (see Multiple rulesets to layer functionality for more details), but can also cause problems.