Learn · Rulebooks
Write a logic rulebook
The document shape, the four parts of a check, and what happens when one matches.
Checked against the product on · written for people writing code
A logic rulebook is one document holding an ordered list of checks. Each check has an id, a match, and what to do when the match holds.
| Part | What it holds | Required |
|---|---|---|
| id | A name for this check, unique in the rulebook. It appears in the logbook when the check fires. | Yes |
| match | The test. One check, or several joined with all / any / none / one-of. | Yes |
| build-up | Weight, half-life and the bands that turn repeated weak matches into an escalation. | No |
| on a match | What to do: write it down, gate the action, or raise a warning label. | Yes |
| on no match | The same, for the times the check does not hold. | No |
Build-up catches the quiet one
A plain threshold catches the loud event and misses the quiet recurring one: the link that drops for two seconds every hour, the account moving money in amounts each under every limit.
Build-up handles those. Each watched thing carries a score for the check. A match adds weight; between matches the score fades on the half-life you set. Crossing a band decides who hears about it: write it down, gate the action, or bring in a person.
| Setting | Example | What it means |
|---|---|---|
| weight | 1.0 | How much one match adds to the score. |
| half-life | 30m | How long the score takes to fade by half with no further match. |
| band: write it down | 3 | At a score of 3, the logbook gets an entry. |
| band: gate the action | 6 | At 6, the thing in flight is held or stopped. |
| band: bring in a person | 10 | At 10, a person is asked to look. |
Write and publish one
Write the checks as one document, each with an id and a match.
Order matters when two checks could both apply. The first match wins.
Publish the version.
The whole document is checked at this moment. A bad pattern, a check nested too deep, or too many checks fails here.
Install it into the work area that should run it.
Install requires the same account that wrote it.
Watch the logbook for the ids you named.
Every firing writes one entry naming the check that fired.
/v1/logic-canons/{id}/versionsPublish a version of a logic rulebook. The document is compiled and validated here; an invalid one is refused with the reason.
| Field | Type | Required | What it is |
|---|---|---|---|
| id | string | requiredYes | The logic rulebook this version belongs to. |