> ## 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.

# Runs and versions

> How a procedure run keeps its place, what a version and the live version are, how many runs work at once, what a run costs, and how child runs, pausing and cancelling work.

A **version** is one published, unchangeable copy of a procedure. A **run** is one execution of
one version, or of a draft. This page explains what you can rely on for each, and how many runs
work side by side. For a summary aimed at regulated operations, see
[Safety for regulated operations](https://docs.canary.effectiveai.app/procedures/concepts/operational-safety.md).

## Versions never change

Each publish compiles your source and stores it as the procedure's next version: 1, 2, 3, and so
on. Effective assigns the number; your source doesn't declare one. A published version is never
edited or replaced. To change a procedure, publish a new version.

Publishing never runs your procedure's code. It checks the source, the declared capabilities and
the declared secrets, and refuses source that doesn't compile.

## The live version

Each procedure has one **live** version. A run that doesn't name a version starts the live one,
and so does an [`invoke`](https://docs.canary.effectiveai.app/procedures/reference/nodes/invoke) that names the procedure's live
route.

A new version becomes live automatically only when its inputs and output are the same as the
live version's. If they differ, it is published but held, so systems that start runs keep working
against the inputs they know. You make it live yourself when they're ready. See
[Publish a new version](https://docs.canary.effectiveai.app/guides/procedures.md#publish-a-new-version). A
[trigger](https://docs.canary.effectiveai.app/procedures/reference/triggers.md#spec) that runs `live` keeps its fixed `inputs`, so
replace them when you make such a version live.

Name an exact version when a run must reproduce a known version, or when a caller must never move
to a newer one without a change on its side.

## A run pins its version

When a run starts, it resolves the version once and keeps it. Making another version live later
doesn't change runs that already started. Each run's details show the version it ran.

## A run keeps its place

A run records the result of each step as it finishes. If the run is interrupted, for example by a
restart or a deployment, it resumes from where it was. Steps that already finished aren't run
again: the run uses the result it recorded. A code step that was in progress when the run was
interrupted may run again, under its [retry policy](https://docs.canary.effectiveai.app/procedures/reference/nodes/retry.md). That's
why writes to your systems need care; see
[Writes to your systems](https://docs.canary.effectiveai.app/procedures/concepts/writes-to-your-systems.md).

A run can also wait for a long time without losing its place: days for a person to answer a
[task](https://docs.canary.effectiveai.app/procedures/reference/nodes/task.md) or for a date to arrive in a
[`wait`](https://docs.canary.effectiveai.app/procedures/reference/nodes/wait) node.

## Child runs

An [`invoke`](https://docs.canary.effectiveai.app/procedures/reference/nodes/invoke) node starts another procedure as a child run
and waits for its typed result. The child run is linked to its parent in both directions, so you
can move between them when you inspect a run.

* The child's version is resolved once for each `invoke` and reused if the step is retried.
* The child runs as the same person as the parent.
* If the child fails, the `invoke` fails. A business outcome such as "rejected" belongs in the
  child's typed result, not in a failure.
* Cancelling the parent cancels its child runs and stops their open tasks and agent sessions.

## Many runs at once

Each run is separate. It has its own inputs, record, version and status, and runs don't share
values. To handle many requests, start one run for each:

* **From your system.** Each start request starts one run. Use an `Idempotency-Key` built from
  your own request, such as the cancellation request ID: a retried start returns the run it already
  started. See [Start a run](https://docs.canary.effectiveai.app/guides/procedures.md#start-a-run).
* **From triggers.** A [trigger](https://docs.canary.effectiveai.app/procedures/reference/triggers.md#how-firings-behave) starts at most
  one run for each firing. Folder and event triggers start a run for each file or event, even while
  earlier runs are still active. A schedule trigger skips a firing while its previous run is still
  active, and fires at most hourly.

Inside one run, these nodes decide how much work runs at once:

| Node | What runs at the same time |
| - | - |
| [`for-each`](https://docs.canary.effectiveai.app/procedures/reference/nodes/for-each) | The same steps for each item of a list. `concurrency` sets how many items run at once; the default `1` runs them one after another. A list over 1,000 items fails the run with `for_each_limit`. Results come back in item order |
| [`parallel`](https://docs.canary.effectiveai.app/procedures/reference/nodes/parallel) | A fixed set of different branches, all at once. The run continues when every branch has finished; the first branch to fail fails the run |
| [`invoke`](https://docs.canary.effectiveai.app/procedures/reference/nodes/invoke) | One child run. The parent waits for it. A chain of child runs can be at most eight levels deep |

Items and branches can't see or overwrite each other's values. Tasks, agent steps and waits are
allowed in them, so several can be waiting at once. Split a batch larger than 1,000 items, for
example into one run per batch or one run per policy.

Running items at the same time also sends requests to your systems at the same time. Set
`concurrency` to what those systems accept. When an effect throws an ordinary error on a `429`
answer, as the tutorials' effects do, the step's [retry policy](https://docs.canary.effectiveai.app/procedures/reference/nodes/retry.md)
tries again after a wait.

This documentation doesn't state throughput or latency figures. Ask Effective about the volumes
you plan to run.

### Limits

| What | Limit |
| - | - |
| Items in one `for-each` | 1,000 |
| Rounds of one `repeat` | 500 (`max_rounds`) |
| Depth of child runs from `invoke` | Eight levels |
| Schedule trigger | Up to ten cron expressions, each firing at most once an hour |
| Retries of a function or effect | By default three attempts, 1s before the first retry, doubling up to 10s |
| Time for one attempt of an effect | 30s by default, at most 2m |
| Fragments a source includes | 128 |
| Size of one document | 1 MiB for the root and for each fragment, and 64 KiB for one node |
| Trigger request body | 256 KiB on create or replace |

See [Limits](https://docs.canary.effectiveai.app/procedures/reference/document.md#limits) for the rest of the file limits, and
[Default policy](https://docs.canary.effectiveai.app/procedures/reference/nodes/retry.md#default-policy) for retries.

## What a run costs

A run is charged for its runtime: once for the run, once for each step and event, and for the CPU
time its code uses. Each retry of a step counts as another step. An `invoke` counts as a step in the
parent, and its child run counts as a run of its own. Waiting is free: the days a run spends waiting
for a task answer or a `wait` cost nothing beyond the step or event that starts the wait and the
event that ends it. Agent sessions, model calls and other metered calls a run makes use credits at
their own prices. See [Procedures in Usage and billing](https://docs.canary.effectiveai.app/getting-started/billing.md#procedures) for
the prices and an example.

## Pause, resume and cancel

You can pause and resume a run from its page in the Effective app. A paused run keeps its state
and continues from the same place when it is resumed; while it is paused, reading it through the
API shows `paused: true`. The API can't pause or resume a run, but it can cancel one. Cancelling is
final. Cancelling a run that already finished changes nothing, so it is safe to retry. Only the
person a run runs as and workspace administrators can control a run; access to the procedure
or to one of its tasks isn't enough. To cancel from your system, see
[Cancel a run](https://docs.canary.effectiveai.app/guides/procedures.md#cancel-a-run).

## Drafts

A draft run starts from source you send instead of a published version. Use it to try a change
before you publish it. A draft isn't a version, and triggers never start drafts. A draft can't
declare secrets. See [Try a draft](https://docs.canary.effectiveai.app/guides/procedures.md#try-a-draft).

## Who can see a run

Runs are shared with everyone who can run the procedure. You can start a private run that only you
can see. A run in a Project also needs view access to that Project. Inspecting a run shows its
inputs, each step's inputs and outputs, its tasks and agent sessions, and its output. 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.


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