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

# How Lerian STA works

> The two transfer directions — outbound submission and inbound discovery and download — the BACEN protocol state machine, SHA-256 integrity verification, retry budgets and protocol TTL, and the operator actions on a transfer.

Lerian STA moves files in two directions. Every exchange is one **transfer** — a single file moving between the institution and BACEN — tracked by its **protocol number** through BACEN's protocol lifecycle, with the **SHA-256** verified at both ends.

## Outbound submission

***

The institution, or an upstream Lerian product, hands Lerian STA a file for BACEN. Lerian STA then obtains a **protocol number** from BACEN, uploads the file's bytes, and has BACEN validate them against the declared **SHA-256**.

The transfer advances through BACEN's lifecycle:

| State                       | Meaning                                           |
| --------------------------- | ------------------------------------------------- |
| **Protocol generated**      | BACEN has assigned the protocol number.           |
| **Transmitting**            | Lerian STA is uploading the bytes.                |
| **Integrity check**         | BACEN is validating the declared SHA-256.         |
| **Received**                | BACEN has received the file.                      |
| **Delivered**               | BACEN has delivered the file to its destination.  |
| **In processing**           | BACEN is processing the file.                     |
| **Accepted**                | BACEN has accepted the file — a terminal success. |
| **Rejected / Inconsistent** | BACEN has refused the file — a terminal failure.  |

Upload retries within a **bounded budget**; once the budget is exhausted, the transfer is cancelled. Each protocol also carries a bounded wall-clock **TTL** — 44 hours by default — to finish uploading before BACEN expires it.

## Inbound discovery and download

***

Lerian STA polls BACEN per active tenant on a configured cadence for available files. For each file, it matches the file's **BACEN system code** against the tenant's **inbound source configurations**, then downloads the bytes, verifies them against BACEN's reported **SHA-256**, and stores the artefact durably in object storage.

A hash mismatch or a download failure retries within a bounded budget. Once the budget is exhausted, the transfer is **quarantined** to a terminal failure — inconsistent or canceled — rather than delivered to its source product.

## Operator actions

***

An operator can act on a transfer that has not reached a terminal state:

* **Cancel** a non-terminal transfer.
* **Retry** a failed outbound transfer.
* **Mark urgent** to prioritize handling.

Cancellation is also **BACEN-initiated** when a protocol expires.
