> ## 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 SPB works

> The onboarding sequence, transfer and lifecycle flows, liquidity operations, and asynchronous queries that make up the STR message surface.

Lerian SPB exposes the STR message surface as a set of typed operations. Each flow persists its work before dispatch, returns an accepted-but-not-settled state, and reconciles against BACEN's asynchronous reply.

## Onboarding

***

Onboarding runs in a mandatory order, and each step is its own resource. A submit attempted before readiness passes is refused.

1. **Rotate** the ICP-Brasil signing certificate.
2. **Activate** it to BACEN (GEN0006, confirmed by GEN0006R1).
3. Confirm the rail reports **`READY`**.
4. Pass a **connectivity echo test** (GEN0001, answered by GEN0001R1).
5. Submits are now permitted.

## Bank transfers

***

You declare the typed sender and recipient parties; the platform derives the STR transfer code (STR0004, STR0005, STR0006, STR0007, or STR0008), persists the operation and the outbound work, and only then dispatches. The response is `SUBMITTED` — dispatch was accepted, not settled. BACEN confirms asynchronously, and the operation moves to `SETTLED` or `REJECTED`.

## Returns and cancellations

***

A return and a cancellation are both sub-resources of a parent operation and are structurally tied to it by the parent's id in the request path.

* A **return** requires the parent to be `SETTLED` (STR0010 pipeline).
* A **cancellation** requires the parent to still admit one (STR0011 pipeline).

A request against the wrong parent state is refused.

## IBS repasse

***

An **IBS repasse** (STR0053) transfers IBS settlement values from the reserve account to the managing committee. The request is translated to the STR0053 message, persisted, dispatched, and confirmed asynchronously.

## Conta PI liquidity

***

Two operations move liquidity between an institution's reserve/settlement account and its Conta PI:

* **Aporte** (LPI0001) funds the Conta PI from the reserve account.
* **Resgate** (LPI0003) recalls funds back to the reserve account.

Both return `PENDING`. The inbound settlement reply (LPI0001R1 / LPI0003R1) moves the operation to `SETTLED` or `REJECTED`, projected verbatim. An aporte submitted outside the operating window is rejected.

## Automatic-transfer policy

***

You declare the STR automatic-transfer rule for an account class (emitting LPI0005). BACEN acknowledges it (LPI0005R1) and later reports each automatic transfer it performs (LPI0006). Reported values are forwarded verbatim; Lerian SPB performs no arithmetic on them.

## Approval queue for high-value emissions

***

Each emission is checked against a configured value band. A submit whose amount exceeds its band parks in `PENDING_APPROVAL` and appears in the approval queue; it dispatches only once the approval quorum is met. An amount below the band goes straight to `SUBMITTED`. Queued emissions can be signed or denied.

## Curated message compose

***

A catalog-gated compose surface builds an allowlisted STR message type (STR0004, STR0005, STR0006, STR0007, STR0008, or STR0053). The chosen type must resolve in the capability catalog and be publicly submittable; otherwise the request is refused.

## Asynchronous single-party queries

***

Reserve-position and schedule reads return a correlation id and `PENDING`; BACEN's reply arrives asynchronously and is read back by that id. Lerian SPB projects what BACEN sends and computes no position of its own.

| Query                       | STR code | Returns                                                        |
| --------------------------- | -------- | -------------------------------------------------------------- |
| Reserve-account balance     | STR0013  | Correlation id + `PENDING`, then the balance BACEN reports     |
| Reserve statement (extrato) | STR0014  | Correlation id + `PENDING`, then the statement in message mode |
| STR operating schedule      | STR0001  | Correlation id + `PENDING`, then the operating-window grades   |

## Inbound notices and roster

***

* **Notices** (GEN0001, GEN0004, GEN0005) are logged verbatim.
* **Schedule broadcasts** (GEN0021) update the operating-window grades — the last announcement wins.
* The participant's full **responsável roster** is announced by full replacement (GEN0019).

## Reconciliation and recovery

***

Settlement discrepancies open reconciliation cases. Operators record `ACKNOWLEDGE`, `RESOLVE`, `DISMISS`, or `INVESTIGATE` actions against a case, and terminal cases are locked. A cross-rail stuck-operations view lists items needing attention, exposing only the actions the rail can actually perform.
