Skip to main content
Rules live beside the imported spec in <data_dir>/apis/<sandbox>.rules.json and load with it. These commands edit that file, validate every change against the spec, and apply it to a running sandbox at once. See Rules for what a rule can say.

rule list

One row per rule in file order, which is the order they are consulted. VERSION is the set version the rule was first saved in. An empty set prints no rules on <sandbox>.

rule add

The file is YAML or JSON holding one rule or rules: [...]. Every rule is validated against the spec before anything is written: the route must be declared, an emit event must be declared, an example status must have an example, and ids must be unique. A refusal names the rule and writes nothing.
When pikopod up is serving the sandbox, the new set is pushed to it and the last line reads applied to the running sandbox examplepay. A rule the spec cannot honour is refused by name with exit 2:
provenance defaults to manual when the file omits it.

rule drop

An unknown id is refused by name.

rule promote

Turns a behaviour_divergence event into a rule on the sandbox linked to the event’s upstream. The recorded request’s features become when: a tokenized identifier becomes exists_in_store on that field, a readable value becomes equals, a dropped value is left out and named. The provider’s recorded status and body become respond. Provenance is promoted:<fingerprint>. Prints the divergence, the redacted request, the provider’s response and the rule, then asks “Is this the provider’s behaviour, not this integration’s payload?” and “Does it hold for every caller?”. Either answered no writes nothing. --yes skips both. After writing, it replays the recorded traffic through a fork with and without the rule and prints both statuses. See Promoting a divergence. Exits 2 when the fingerprint is not a divergence (an incident is reproduced, a shape change is pinned) or when every feature was dropped before disk, in which case it says to write the rule by hand.

rule check

Reports rules that shadow the operation unconditionally, and rules that can never fire: a rule behind an unconditional one on the same operation, a rule with the same conditions as an earlier one, or a state condition on a resource type no operation stores. Exit 0 when clean, 1 when there is anything to report, 2 when the set cannot load.