> ## Documentation Index
> Fetch the complete documentation index at: https://docs.canary.effectiveai.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Procedures overview

> What procedures do for an operations team, who does what, and how a procedure is written, tested, published and run.

A procedure runs one of your operations the same way every time. It reads from your systems, asks
the right person to approve, waits for the right date, writes to your systems, and keeps a record
of every step. Effective runs it, and your team decides what it does and who signs off.

## What procedures give an operations team

* **The same steps every time.** The procedure is a written document. Your team can read it like an
  operating procedure, and Effective runs exactly what it says.
* **People decide where judgment is needed.** An approval is a step in the procedure. Nothing after
  it runs until the right person answers, and the run records who answered and what they said.
* **Waits for a date.** A run can wait until a set date and time, such as a notice date, and
  keeps its place across restarts and deployments while it waits.
* **A record of every run.** Each run shows what it started with, what each step read and wrote,
  each approval, and the version it ran.
* **Changes are versioned.** Every published version is kept unchanged. A change can be tried as
  a draft first, and runs already under way keep the version they started with.

## Operations that fit

Procedures fit operations that follow fixed steps, touch your own systems, and have to leave a
record. For example:

| Operation | What a procedure does |
| - | - |
| Cancellation with a notice deadline | Works out the return premium, gets the refund approved, then cancels, refunds and sends the notice on the cancellation date |
| Endorsement or reinstatement | Reads the policy and the requested change, asks underwriting to approve, then writes the change and sends the confirmation |
| Payment reconciliation | Compares each processor's daily settlement report with your policy system, fixes what it can explain, and asks finance only about the rest |
| Renewal and nonpayment notices | Starts each day on a schedule, works through the policies whose notices are due, at most 1,000 in one run's `for-each`, and sends each one with a key your mail system uses to refuse a repeat |
| Claim intake | Starts when a claim email arrives, has an agent read it, asks a person to confirm, and acknowledges the claim |

The [Cancel a policy](https://docs.canary.effectiveai.app/procedures/tutorials/cancel-a-policy.md) and
[Reconcile payments](https://docs.canary.effectiveai.app/procedures/tutorials/reconcile-payments.md) tutorials build the first and third
in full. The other rows are combinations of the same building blocks.

## What you control, what Effective guarantees, what your systems must do

**You control:**

* the steps, the rules and the order they run in;
* who approves each decision, and who can publish, run and see the procedure;
* which version is live. A new version with the same inputs and output goes live as soon as it's
  published, so review a change before you publish it, or pin callers to an exact version;
* the credentials each step uses, and what each step may reach.

**Effective guarantees:**

* a run keeps its place across restarts and deployments, and on its own never repeats a step whose result it
  has recorded. A code step that was still in progress can run again under its retry policy;
* a published version never changes, and each run records the version it ran;
* only a task's assignees can answer it, and an answer that doesn't fit its form is refused;
* credentials are set in Effective, not in the source. Effective never writes a secret's value to
  the source, the version or the run record. Code that reads a secret must not return it in a
  step's result, because results are recorded.

**Your systems must:**

* be reachable from the public internet over HTTPS, and authenticate each request. Procedure code
  can't reach private networks;
* honour the idempotency key on every write, so a repeated request isn't applied twice. An
  **idempotency key** is a value sent with a write so that the receiving system can recognize a
  repeat of it. Effective doesn't guarantee that a write happens exactly once. See
  [Writes to your systems](https://docs.canary.effectiveai.app/procedures/concepts/writes-to-your-systems.md);
* refuse requests they can't accept with a clear error, so the procedure can stop instead of
  retrying;
* keep their own record of each write, with the ID the procedure can return.

[Safety for regulated operations](https://docs.canary.effectiveai.app/procedures/concepts/operational-safety.md) covers approvals, the
audit trail, deadlines, failures, change control and access in more detail.

## Who does what

| Who | Does |
| - | - |
| Operations owner | Decides what the operation does, its rules, deadlines and approvers. Reviews the procedure document before it's published. Watches runs and their outcomes |
| Developer or coding agent | Writes the procedure and the code that calls your systems, keeps it in source control, tries it as a draft, and publishes it |
| Approver | Answers the procedure's tasks in Effective, such as approving a refund. The answer and who gave it are recorded with the run |
| Effective | Runs each procedure, holds its waits, retries steps under their policy, checks access and answers, and records every run |

Procedures are not a drag-and-drop builder. A procedure is a text file: Markdown that people read,
with small blocks of YAML and TypeScript that say exactly what runs. Effective supplies the parts a
developer would otherwise build: waits that last for days, the inbox where approvers answer, the
record of every step, and versioning and pinning. Developers and coding agents, including the
[Effective agent](https://docs.canary.effectiveai.app/getting-started/using-with-agents.md), write it with the tools they already use,
and review it like any other code. Business owners review the same document, because
its headings and paragraphs describe each step in plain words, and approve individual operations
through tasks.
Rules that must always give the same answer, such as a return premium, are code in the document.

## How a procedure works

A procedure is a document that Effective runs for your organization. It reads like a written
operating procedure: headings and short paragraphs say what each step does and why. Under each
heading, small YAML blocks called **nodes** say exactly what runs: read a policy from your system,
ask a person to approve a refund, wait until a notice date, return a result whose shape the
procedure declares.

Effective runs each procedure durably: a run keeps its place across restarts and deployments,
records what every step returned, and doesn't repeat a step whose result it has recorded. Every
version you publish is kept unchanged, and every run records which version it ran.

## What a procedure looks like

This procedure acknowledges a new claim. The front matter, the block between the `---` lines,
declares its inputs and output. The `complete` node returns the result, and the `schema` block
describes the result's shape.

````markdown claim-acknowledgement.procedure.md theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
---
kind: procedure@v0
id: claim-acknowledgement

inputs:
  claim_number: { type: string }
  policy_number: { type: string }
outputs:
  acknowledgement: { schema: acknowledgement }
---

# Claim acknowledgement

Acknowledge a new claim against its policy.

## Acknowledge

Return the claim and policy numbers with a received flag.

```yaml complete id=acknowledge
output: acknowledgement
value:
  claimNumber: $inputs.claim_number
  policyNumber: $inputs.policy_number
  received: true
```

## Resources

```yaml schema id=acknowledgement
type: object
additionalProperties: false
required: [claimNumber, policyNumber, received]
properties:
  claimNumber: { type: string }
  policyNumber: { type: string }
  received: { type: boolean }
```
````

Nodes run in document order. Declarations, such as `schema` blocks and code declarations, can sit
anywhere in the document. See [Procedure document](https://docs.canary.effectiveai.app/procedures/reference/document.md) for the full
file format.

## The building blocks

Each node type has its own reference page with its syntax, fields, examples, and what happens when
a step is retried or a run resumes. The [cheat sheet](https://docs.canary.effectiveai.app/procedures/reference/cheat-sheet.md) shows them
all on one page.

| Group | Nodes | Use them to |
| - | - | - |
| Do work | [`call`](https://docs.canary.effectiveai.app/procedures/reference/nodes/call), [`invoke`](https://docs.canary.effectiveai.app/procedures/reference/nodes/invoke), [`agent`](https://docs.canary.effectiveai.app/procedures/reference/nodes/agent), [`task`](https://docs.canary.effectiveai.app/procedures/reference/nodes/task), [`value`](https://docs.canary.effectiveai.app/procedures/reference/nodes/value) | Run your code or an Effective operation, start another procedure, hand work to an agent or a person, or compute a value |
| Control flow | [`choice`](https://docs.canary.effectiveai.app/procedures/reference/nodes/choice), [`repeat`](https://docs.canary.effectiveai.app/procedures/reference/nodes/repeat), [`for-each`](https://docs.canary.effectiveai.app/procedures/reference/nodes/for-each), [`parallel`](https://docs.canary.effectiveai.app/procedures/reference/nodes/parallel) | Branch, loop until a condition holds, process each item in a list, or run branches at the same time |
| Wait and finish | [`wait`](https://docs.canary.effectiveai.app/procedures/reference/nodes/wait), [`complete`](https://docs.canary.effectiveai.app/procedures/reference/nodes/complete) | Wait for a time, a condition, a task or an [RSL](https://docs.canary.effectiveai.app/rsl/overview.md) program's decision, and return the procedure's result |
| Declarations | [`schema`](https://docs.canary.effectiveai.app/procedures/reference/nodes/schema), [`secret`](https://docs.canary.effectiveai.app/procedures/reference/nodes/secret), [functions and effects](https://docs.canary.effectiveai.app/procedures/reference/nodes/function-and-effect.md), [`retry`](https://docs.canary.effectiveai.app/procedures/reference/nodes/retry), [includes](https://docs.canary.effectiveai.app/procedures/reference/nodes/include.md) | Describe data, declare credentials, write the code a `call` runs, set a retry policy, and share sections across documents |

## How you work with procedures

1. **Write.** Ask the [Effective agent](https://docs.canary.effectiveai.app/getting-started/using-with-agents.md) to write one, or write
   the file yourself and keep it in source control.
2. **Try it.** Start a draft run from the source before you publish anything. Only you can see a
   draft unless you share it. See [Try a draft](https://docs.canary.effectiveai.app/guides/procedures.md#try-a-draft).
3. **Publish.** Each publish creates the next immutable version. A version whose inputs and output
   match the live version becomes live automatically.
4. **Run.** Start runs from the Effective app, from a [trigger](https://docs.canary.effectiveai.app/procedures/reference/triggers.md), or
   from your own system through the [API](https://docs.canary.effectiveai.app/guides/procedures.md).
5. **Inspect.** Every run shows each step's inputs, outputs and status, the tasks it created, and
   the version it ran.

## Where to go next

* [Safety for regulated operations](https://docs.canary.effectiveai.app/procedures/concepts/operational-safety.md): approvals, the audit
  trail, deadlines, failures, change control and access, in one place.
* [Runs and versions](https://docs.canary.effectiveai.app/procedures/concepts/runs-and-versions.md): how a run keeps its place, and how
  versions and the live version work.
* [Writes to your systems](https://docs.canary.effectiveai.app/procedures/concepts/writes-to-your-systems.md): retries, idempotency keys,
  and how to keep a refund from being paid twice.
* [People and agents](https://docs.canary.effectiveai.app/procedures/concepts/people-and-agents.md): approvals, agent steps, and what each
  can see and do.
* Tutorials: [Cancel a policy](https://docs.canary.effectiveai.app/procedures/tutorials/cancel-a-policy.md) and
  [Reconcile payments](https://docs.canary.effectiveai.app/procedures/tutorials/reconcile-payments.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.