# Concepts

Source: https://docs.formance.com/v3.2/modules/reconciliation/concepts

Stack: v3.2

Reconciliation organizes continuous financial controls into five client-facing concepts: **rules**, **evaluations**, **alerts**, **evidence**, and **resolutions**.

```mermaid
flowchart LR
  Rule["Rule<br/>what and when to check"] --> Evaluation["Evaluation<br/>one execution"]
  Evaluation -- FAIL --> Alert["Alert<br/>one case per asset and period"]
  Evaluation -- PASS --> Proof["Green proof"]
  Alert --> Timeline["Evidence and<br/>event timeline"]
  Alert --> Resolution["Auto-resolve,<br/>fix, or accept"]
```

## Rules

A **rule** defines the business control. It contains:

- a control template and its configuration;
- an on-demand or cron **schedule**, controlling how often it runs;
- a severity, and a **period length** for grouping its results;
- optional key-value labels copied to alerts and webhook event payloads;
- an enabled state.

Templates keep the public configuration focused on financial intent. You choose a supported comparison and provide its sources, assets, signs, thresholds, or tolerances; the underlying expression is generated and validated by Reconciliation.

Labels are metadata for downstream consumers; Reconciliation does not interpret them or route work by itself. For example, `{ "team": "treasury", "environment": "production" }` lets your webhook consumer send the resulting alert to the treasury queue while retaining the same tags in its audit record.

Rules are enabled by default. Disabling a rule stops scheduled and on-demand evaluations without deleting its existing evidence or alerts; see [Pause or resume a rule](https://docs.formance.com/v3.2/modules/reconciliation/getting-started#6-pause-or-resume-a-rule) for the operational effects.

See [Control Templates](https://docs.formance.com/v3.2/modules/reconciliation/controls) for the available controls.

## Evaluations

An **evaluation** is one execution of a rule. It is always persisted and has one of three results:

| Result  | Meaning                                                                                    |
| ------- | ------------------------------------------------------------------------------------------ |
| `PASS`  | Every checked asset satisfied the control.                                                 |
| `FAIL`  | At least one asset fell outside the control.                                               |
| `ERROR` | Reconciliation could not complete the check, for example because a source was unavailable. |

For each asset, a passing result stores a compact proof containing the observed balances and predicate inputs needed to verify the result after a rule edit. A failing result stores a fuller evidence breakdown, including the observed values, calculated difference, configured tolerance, and the generated expression used to explain the check. Amount comparisons use arbitrary-precision integers, so large financial values remain exact.

### Point-in-time reads

Each balance source is read at an explicit point in time. By default, Reconciliation subtracts a 30-second **safety margin** from `at`. For example, an evaluation requested at `10:00:00` reads the sources at `09:59:30`.

The margin avoids evaluating the newest edge of the data, where a Ledger write, connector poll, or balance update may still be reaching one source but not another. It reduces false discrepancies caused by ingestion timing; it does not change or delay the underlying financial activity.

Omit `safetyMargin` to use the 30-second default. Set it explicitly to `"0s"` to read exactly at `at`; this explicit zero is preserved on scheduled rules and is not replaced by the default. It is useful for deterministic tests, demos, and historical evaluations where you control the data and need the exact requested instant. You can also override the effective timestamp for an individual source when systems settle on different cycles.

After resolving the balances, Reconciliation evaluates immutable per-asset snapshots without reading the sources again. The resolved timestamps are stored in `pitPerSource` on the evaluation. Together with the frozen proof or evidence, this records the financial state that produced the verdict.

If you omit `at`, Reconciliation asks Payments for its latest known balance. Payments returns the balance but not the time at which that snapshot became effective, so Reconciliation can record only when it fetched the value. Replaying a historical query at that fetch time may therefore return a different snapshot. For a reproducible run, provide a past `at` or an explicit Payments timestamp in `sourcePITs`; regardless of the read mode, the values stored in the evaluation remain unchanged.

## Alerts

A failed evaluation opens an **alert** for each failing fingerprint. In the current templates, the fingerprint is the asset, such as `asset:USD/2`. A USD discrepancy and a EUR discrepancy therefore become separate cases that can resolve independently.

Alerts have three statuses:

```mermaid
stateDiagram-v2
  [*] --> OPEN: first failure
  OPEN --> ACKNOWLEDGED: operator acknowledges
  OPEN --> RESOLVED: passes, fixed, or accepted
  ACKNOWLEDGED --> OPEN: later failure resurfaces
  ACKNOWLEDGED --> RESOLVED: passes, fixed, or accepted
  RESOLVED --> OPEN: fails again in the same period
```

The alert row represents the current state. Its event timeline records every evaluation that touched it and every acknowledgement, snooze, resolution, acceptance, or reopen.

## Reconciliation periods

Each rule groups its results into **reconciliation periods**.

The `periodType` field sets how long a period is: `daily`, `weekly`, `monthly`, or `continuous` for no boundary at all.

`periodType` sets the length of a period, not how often the rule runs — that is its [schedule](#rules), a separate field. A rule with an hourly schedule and a `monthly` `periodType` runs hundreds of times in July, and those runs are grouped into one period, `2026-07`, rather than into hundreds of separate ones.

Grouping uses the effective read timestamp rather than the moment the rule fired, so the [safety margin](#point-in-time-reads) decides which side of a boundary a run falls on. With the 30-second default, a run at `2026-07-01T00:00:00Z` reads at `2026-06-30T23:59:30Z` and is therefore grouped under `2026-06`.

**Renamed in 2.5.0.** This field was called `cadence` in earlier versions. Nothing breaks: both names are accepted when creating a rule, and both are returned, so existing integrations keep working untouched.

Sending both is rejected with a `400` unless the two values are equal — rather than silently picking one. `cadence` is deprecated and will be removed in a future major version, so prefer `periodType` in new code.

| Period type  | Period                                              | Example period id |
| ------------ | --------------------------------------------------- | ----------------- |
| `continuous` | One ongoing case per asset, with no period boundary | `continuous`      |
| `daily`      | Each UTC day, certified separately                  | `2026-07-21`      |
| `weekly`     | Each ISO week                                       | `2026-W30`        |
| `monthly`    | Each calendar month, for period-end certification   | `2026-07`         |

Within a period, the same asset reuses its alert. A failure in a new daily, weekly, or monthly period creates a new alert, preserving earlier periods as independent records.

This is what the period length buys you: an hourly rule that keeps failing all month produces one `monthly` alert with a rising `occurrenceCount`, not hundreds of separate cases.

### How period boundaries are drawn

Boundaries are fixed UTC calendar buckets. They are not configurable, and there is no way to define a period by hand.

|           | Boundary                                                                                                                                                                                                                     |
| --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `daily`   | The UTC calendar day, midnight to midnight. Always exactly 24 hours: UTC has no daylight saving, so a period is never 23 or 25 hours long.                                                                                   |
| `weekly`  | The **ISO 8601** week, which starts on **Monday**, not Sunday. The year in the id is the ISO year, which for a few days around 1 January differs from the calendar year — a run on 1 January 2027 can file under `2026-W53`. |
| `monthly` | The Gregorian calendar month, so the length follows the calendar: 28, 29, 30, or 31 days. Nothing assumes a fixed 30.                                                                                                        |

Three things this does **not** support today:

- **A local or per-tenant timezone.** A `daily` period is a UTC day, not your business day. For a team at UTC-5, period `2026-03-15` runs from 19:00 on 14 March to 19:00 on 15 March local time.
- **A period starting anywhere other than midnight.** There is no business-day offset.
- **A fiscal calendar.** No 4-4-5, no 13-period year, and no fiscal year that starts on a date other than 1 January.

`schedule.tz` does **not** move period boundaries. It sets the timezone the cron expression fires in — that is, when the rule _runs_. A rule with `tz: "America/New_York"` runs on New York time and still files its results into UTC periods.

To choose the period a result lands in — backfilling a close, or replaying a past date — evaluate on demand and pass `at`. The period is derived from that instant, less the [safety margin](#point-in-time-reads), so `at` selects the bucket. It must be in the past. Scheduled runs derive their own instant and have no equivalent override.

A period is operationally green when it has no `OPEN` or `ACKNOWLEDGED` alerts. Resolved and accepted cases remain available for audit.

## Resolutions

An alert can close in three ways:

| Resolution             | When to use it                                                   | Recorded context                                            |
| ---------------------- | ---------------------------------------------------------------- | ----------------------------------------------------------- |
| `auto`                 | A later evaluation passes.                                       | System attribution and timestamp.                           |
| `fixed_by_booking`     | Your team made a corrective booking.                             | Author, optional note, and optional transaction references. |
| `accepted_by_business` | The discrepancy is understood and approved without a correction. | Author, required note, and a frozen evidence snapshot.      |

If the control fails again within the same period, the alert reopens and its current resolution is cleared. The previous resolution remains in the append-only timeline.

## Data discrepancies and execution errors

Financial failures create asset alerts. Failures to execute a rule create a separate `engine.error` alert so operational problems do not look like balance discrepancies. Use the alert labels and fingerprint to route these two classes to different teams.
