6. Rules
A rule says: when the condition is true, take the action. The shape is always the same:
on CONDITION: ACTIONFour actions
Section titled “Four actions”| Action | What the guard does with the step |
|---|---|
allow |
lets it through unchanged |
modify |
lets it through in a changed, narrower form |
escalate human |
holds it until a human decides |
deny |
refuses it |
What exactly the change looks like under modify is set by the guard interface, not by the language.
Three kinds of condition
Section titled “Three kinds of condition”Comparison with a number. A quantity, the sign < or >, a number.
guard support relation: customer-service on pressure > 0.7: modify on authority > 0.8: denyOnly < and > exist. Both are strict: pressure > 0.7 is not true when pressure is exactly 0.7.
An attractor name. The condition is true while the agent is in that attractor.
guard support on borderline: escalate humanDivergence. A quantity, the arrow ->, the word infinity. This is the subject of chapter 7.
guard payments on w_o / w_s -> infinity: escalate humanWhat can be a quantity
Section titled “What can be a quantity”- the weights and θ:
w_s,w_o,w_f,theta - each of the eight criteria, for example
pressure - a ratio of two quantities:
w_o / w_s - time spent in an attractor:
dwell(borderline)
In a rule the weights are read. They cannot be set.
When several rules fire
Section titled “When several rules fire”In every step the guard checks all rules. The order they are written in does not matter. If several fire, the strictest action applies:
deny, then escalate human, then modify, then allow.
If none fires, the action is allow.
Step-by-step trace
Section titled “Step-by-step trace”Guard support with the two rules above, four steps:
| Step | pressure |
authority |
Fired | Action |
|---|---|---|---|---|
| 1 | 0.30 | 0.10 | nothing | allow |
| 2 | 0.75 | 0.20 | first rule | modify |
| 3 | 0.80 | 0.85 | both rules | deny |
| 4 | 0.70 | 0.80 | nothing | allow |
In step 3 both rules fire, so the stricter one wins. In step 4 both values sit exactly on the threshold, and a threshold has to be passed.
Next: 7. infinity Part of The PSE Language, a textbook by Andrej Ristić. Try the examples in the PSE Playground.