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

***

Certificate rotation and GEN0006 activation are operational guidance, as is a GEN0001 connectivity echo; they are not code-mandated gates for submitting commands.

Before side effects, a command checks rail readiness. `READY` and `DEGRADED` admit commands; `PENDING_CONFIGURATION` and `UNAVAILABLE` block them. Readiness evaluates channel configuration and certificate state. It does not require a GEN0006 acknowledgement or a GEN0001 echo.

## Bank transfers

***

You declare the typed sender and recipient parties. The platform derives the STR transfer code — STR0004, STR0005, STR0006, STR0007, or STR0008. It persists the operation and the outbound work, and only then dispatches. The rail returns the status `ACCEPTED` — it accepted the request, but BACEN did not settle it yet. BACEN confirms the transfer asynchronously, and the operation moves to `CONFIRMED` or `REJECTED`.

## Returns and cancellations

***

A return and a cancellation are both sub-resources of a parent operation. The parent's id in the request path ties each one to that parent.

* A **return** requires a parent in a settled-outbound state: `SENT`, `CONFIRMED`, or `DELIVERED` (STR0010 pipeline).
* A **cancellation** requires a parent that still admits one (STR0011 pipeline).

The rail refuses a request against the wrong parent state.

## IBS repasse

***

An **IBS repasse** (STR0053) transfers IBS settlement values from the reserve account to the managing committee. The rail translates the request to the STR0053 message, persists it, and dispatches it. BACEN confirms it 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`. Lerian SPB projects the reply value verbatim. GEN0021 operating-window grades are persisted and queryable; they do not impose a generic rejection of every submit outside an operating window. The explicit schedule-related admission rule is RLPI0007: during the additional-aporte window, an aporte to a foreign Conta PI is rejected. Aportes to the institution's own Conta PI and resgates remain allowed.

## Automatic-transfer policy

***

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

## Approval queue for high-value emissions

***

The rail classifies each declared amount against half-open configured bands and can apply an override for a specific message type. The selected rule determines the state: `requiredSignatures` of `0` sends the emission to `SUBMITTED`; a nonzero value sends it to `PENDING_APPROVAL`. At a band ceiling, the next band applies; above all ceilings, the top-tier requirement applies. An operator can sign or deny a queued emission. Governance configuration hot-reloads through Systemplane.

## 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 rail refuses the request.

## Asynchronous single-party queries

***

Reserve-position and schedule reads return a correlation id with `PENDING`. BACEN's reply arrives asynchronously. You read it back by that correlation 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

***

* The rail records **notices** (GEN0001, GEN0004, GEN0005) to a queryable notice log.
* **Schedule broadcasts** (GEN0021) update the operating-window grades — the last announcement wins.
* A **responsável roster** submission (GEN0019) fully replaces the participant's roster.

## Reconciliation and recovery

***

Settlement discrepancies open reconciliation cases. Operators record `ACKNOWLEDGE`, `RESOLVE`, `DISMISS`, or `INVESTIGATE` actions against a case. The rail locks a terminal case. A cross-rail stuck-operations view lists the items that need attention. It exposes only the actions the rail can perform.
