Rule composition

Added · Last updated · Seed

The actor wants the system to pick out cases by criteria of their own. Sometimes the criteria narrow what is shown right now: a smart playlist, a saved search, a segment of customers, an issue list filtered three ways. Sometimes they stand as a rule the system acts on while the actor is away: a mail rule that files messages, an automation that turns the heating down, an agent’s standing instruction about what not to touch. Rule composition is how the actor writes or changes the condition in either case. The condition is shown as one statement in plain language, built from parts the system offers, and the actor edits it in place.

Songs where genre is “country” and rating is at least 4 stars and last played is not in the last 2 weeks.

When an email arrives and it is not from someone in my contacts and it contains the phrase “Canadian Pharmacy”, label it “likely spam” and move it to the trash.

The first narrows a library the actor can see. The second does the same work over mail that has not arrived yet, with an action attached. The composing surface is the same in both; what differs is the set of parts on offer and what the actor has to do to check the result.

Selecting and acting

The test that separates the two kinds is whether the actor can see the matched set right now.

  • A selecting rule narrows a collection that is in front of the actor. The result updates as parts are changed, so a wrong condition shows itself at once and costs nothing to fix. The rule may be saved and re-run, and because the collection changes, the result changes with it. Query builders, segment builders, smart folders and saved searches are all this kind.
  • An acting rule attaches an action to the condition and runs it on cases that have not arrived. The actor is not there when it fires, the mistake happens to real things, and the rule runs alongside the other rules already in place. Mail rules, home automations, trigger–action recipes and an agent’s standing limits are this kind.

Many surfaces carry both halves. A mail filter is a search with “do this” attached, and the search link in the filter dialog is the selecting half used to check the acting half. Compose the condition the same way in both kinds, and treat the action clause as the thing that turns a selection into a rule. What changes between them is the checking, which is a move of its own: dry run.

Forces

  • Reading vs. structure — a condition needs and, or and not, but a sentence reads in one line. Flat lists of conditions read fine. Nested groups do not, and grouping is where people make mistakes.
  • Everyday words vs. logic — the sentence form borrows “and”, “or” and “not” from English, where they do not mean what the logic needs. “The blue ones and the green ones” is a union to most people, and how far a “not” reaches depends on what follows it. The words that make the statement readable are the words people misread.
  • Exactness vs. the actor’s words — the condition has to use fields the system has, and the actor’s reason for wanting it usually does not map onto them.
  • One rule vs. the list — an acting rule is written on its own but runs alongside the others. People hold specific wrong beliefs about how rules combine: that two rules with opposite actions cancel out, that rules run in the order listed, that a condition on one rule limits the others. A selecting rule has no list to run against.

Solution

Show the whole condition as one plain statement and let the actor edit it in place: each field, operator and value is a part that can be changed, and parts can be added and removed from the sentence. When the rule acts, keep the action in the same sentence as the condition. Splitting them hides what the rule does.

A flat run of restrictions on one thing can join with “and”, as the examples above do, and people read that as intended. The moment a group holds alternatives, or mixes the two, stop letting the bare word carry the logic. Name how the parts combine once, at the head of the group: “all of the following” or “any of the following”. Attach “not” to the single part it negates, as an operator on that part (“is not”, “does not contain”), never as a word in front of a group. The one place a join word is safe inside a line is a list of values under an operator that names the quantifier: “status is any of Done or Cancelled”, “label includes all of Audit and Design”. People read a list of values as a list, and the operator carries the logic.

When a condition needs grouping that one line cannot hold, break the sentence into lines, one per group, indented, with the head word of each group on its own line. A tree of conditions or a row of chips can show the same thing, but reads worse for the common flat case, and most cases are flat.

Events and states

Acting rules bring a distinction selecting rules never need:

  • Trigger — something that happens at a moment. “When a file is added to the folder.”
  • Condition — something that is true for a while. “While the project is archived.”
  • Action — what the system does when the trigger fires and the conditions hold.

People confuse events with states, and the interface causes much of it: “if this, then that” uses the same wording for a moment and for a period. A sentence can keep the two apart with different words: “when” for the event, “while” or “and it is” for the state, then the action. Giving the two kinds of clause different words is an interface fix for what looks like a comprehension problem.

Research on this pattern

Consequences

  • the condition is visible as a statement whose parts can be read, changed, added and removed, so the actor can inspect what the system matches instead of only noticing it
  • reading the statement does not tell the actor what it matches or does; a selecting rule shows its result on the collection at once, an acting rule shows nothing until it fires
  • the words on offer are the system's, not the actor's, so a wish the parts cannot express gets approximated, and the approximation is what runs
  • when the rule acts, it runs alongside the rules already in place and together they decide the outcome; rules pile up, and past a certain size the actor can no longer keep the list in mind

Resources & references

Appears in

Assistance escalation

  • Adjusting the level of help, step 3 — within Hand the recurring procedure over: each condition is written as clauses the actor can read, edit, and check before the procedure runs

Delegating work

  • Correcting the result, step 2 — within Turn a repeated correction into a standing rule: the rule is written as conditions the actor can read, edit, and check against the record before it takes effect

Governing autonomy

  • Setting the limits, step 1 — within Set limits on what the agent may do: beyond the simplest case, the limits are several rules combined, and the actor reviews them together

Related patterns

Precedes

  • Dry run — reading the statement does not tell the actor what it matches or does; a selecting rule shows its result on the collection at once, an acting rule shows nothing until it fires

Enables

  • Workflow — a trigger–action rule list is a list of composed rules; the workflow is the procedure, the rule is its unit
  • AI tuning — the tuning that survives the session is written as a rule, which is the form the correction takes

Enacts

  • Malleability — what the system matches or does becomes an artifact the actor edits, at a scale below the whole procedure
  • Formality — pushes the actor's intent into the elements the system offers, and what does not fit is lost at the edge

Complements

  • Bounded autonomy — scope, spend and time bounds are composed the same way — clauses on what the system may do, rather than on when it acts
  • Good defaults — a generated starting rule beats the empty statement, and most composition is editing rather than authoring
  • Filtering — a filter is the selecting rule over a visible collection, where the result updates as each part changes and checking the rule needs no separate step

Related to

  • Prompt scaffolding — both give an unstructured intent a structure to be composed in; the scaffold shapes one request, rule composition shapes a condition that stands
  • Form — the statement borrows the form's machinery — constrained values, validation — but reads as a sentence rather than a field list, and the set of parts is open to the actor

Enabled by

  • Bounded choice — bounded choice supplies each adjustable part of the statement — the field, the operator, and the value, all picked from sets the actor did not author