A function is a small piece of your own logic a spell step can call: is this address one of ours, which team owns this, how do three verdicts add up to one score. You describe it; the Familiar writes it, tests it, and explains it. Nobody has to read code.
Functions sit under Tools in the menu, beside Forms and Tables. A function takes an input and gives back an answer, and it can read your tables (your lookup tables). It cannot reach the internet, a tool, the clock, or anything else: anything that calls a vendor is a tool action instead.
Ask the Familiar to write one
Tell the Familiar (your AI assistant) what the step should work out: "write a function that says whether an IP is in our VPN ranges table, and which site". It writes the function, says what it takes and gives back, and writes tests for the ordinary cases and the odd ones. If a check fails it fixes the function and tries again, and then it tells you, in words, where it stands.
How a function is checked
Every version is checked on our side, never on the Familiar's say-so. The code itself is checked for anything that could reach outside it. Every test must give exactly the answer it expects. Then the function is handed a fixed set of hostile inputs (missing fields, wrong types, empty input, very long or strange text) and each must either give an answer that fits its contract or refuse cleanly. A version can go further only when every check passes on that exact version; change one character and it is checked again.
Review before a spell can call it
A function that passes its checks is sent for review, and only an approved version can be called by a spell. An admin of your organization approves each one, after the automatic gate has passed: a code check, every test, and hostile inputs run on our servers. Until it is approved it can be tried by hand, but no spell runs it. An approved version is never edited; a change makes a new version that goes through the checks and review again.
Using a function in a spell
Ask the Familiar to build a spell that uses one, and it binds the step to the approved version. The spell keeps calling that version until the spell itself is changed, so approving a newer version never changes what a running spell does by surprise. Each call records which version ran and which version of each table it read, so a run can always be explained later.
A function's page lists the spells that call it and the version each one uses. When a newer version is approved, the page says how many spells are still on an older one and offers to have the Familiar upgrade them; it shows you what changes in each spell before anything is saved, and the spell's own rules for saving apply as they would to any other edit.
The built-in functions
Soarcery ships a set of functions every spell can call without writing anything: checking an address against ranges, checking whether a domain or email is one of yours, making an indicator safe to paste and back again, pulling indicators out of text, decoding text, reading email authentication results, working out time between two moments, and reshaping data. They run in the same sealed-off way as yours.
When one is close to what you need, make an editable copy from its page. The copy becomes a draft of your own, checked at once like anything the Familiar writes, and reviewed before a spell may call it. The built-in itself never changes.
What a function never does
A function works something out; it never acts. It cannot change anything in your tools, and what a spell does with its answer is still judged by your approval rules, with anything they hold for a person waiting on a seal (an approval).
Start with the free tier; Pro adds Cases, Attack Surface and Detections.