Rules
What a rule is, what is public about it, and why rules never contain code.
A rule is an Arkiv entity of type trg.rule, created by your wallet. Arkiv records your wallet as its
$creator, which is how listRules({ creator }) finds your rules and how anyone can tell who made one.
It has two halves:
- Attributes, which workers query: the trigger (
on,targetorfireat,offset), theaction, whichworkermay fire it, theapp, and the format versionv. - A JSON payload with the rest:
name,message,url,chat(sealed),extendDays,retries.
The split follows Arkiv's limits: attribute values are short (128 bytes for strings) and only attributes can be queried, so anything long or not searched goes in the payload. See Entities for every field.
Public by design
Every rule is readable by anyone. That is what lets any worker fire it and anyone audit it. It also means a rule must never hold a secret or personal data. The SDK enforces what it can:
- A Telegram chat ID is accepted only sealed to a worker (
sealed:v1:…). - A webhook URL that looks like it contains a secret raises a warning.
- Webhook URLs must be
https://.
No code, ever
A rule names one action from a fixed menu: telegram, webhook, receipt, extend. Workers run
those and nothing else. If rules could carry code, anyone could make a public worker run anything.
Custom code belongs on a worker you run yourself (onFire).
Who fires it
The worker attribute is any (any public worker may fire it) or one worker's address (only that
worker may). Arkiv itself decides nothing; workers read the attribute and skip rules that are not theirs.
Lifetime
A rule expires a week after its deadline, at least one day after it was written. It cleans itself up, and its receipts (which live 30 days) can be read next to it in the meantime.