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

> The settlement pipeline — canonical intake, ASLC file build, custody-delegated signing, transmission and return correlation — the credit, debit, anticipation and cancellation flows, the IF Domicílio inbound and clearing flows, and the operation lifecycle.

Lerian SLC runs a single settlement pipeline for every card operation: it takes an operation in, builds the ASLC file for it, has it signed under the client's custody, transmits it to Nuclea, and correlates the returns — advancing the operation through its lifecycle by the NUliquid.

## Intake

***

Operations enter Lerian SLC through two canonical modes:

* **Canonical API** — a REST/JSONL intake carrying operations in Lerian's canonical shape, idempotent by `external_id` so a retried submission never double-settles.
* **Direct ASLC XML** — an upload of ready ASLC XML for callers that already produce it.

An **audited pass-through** mode also accepts client-pre-signed artifacts and forwards them under audit.

The operation types are **CREDIT**, **DEBIT**, **CANCELLATION**, **ANTICIPATION**, and **SWEEP**.

## Build, sign, transmit, correlate

***

Each operation flows through one pipeline:

1. **Validate** the operation against Nuclea's XSDs.
2. **Build** the ASLC file — UTF-16BE, no BOM, up to **50,000** records per file, with automatic splitting when the count exceeds the limit.
3. **Sign** the file under the client's custody (see [Signing orchestration](#signing-orchestration) below), then apply **GZIP** and the **SPB security envelope**.
4. **Transmit** the file to Nuclea over **REST**, secured by **mTLS** and a **per-request JWS** signature.
5. **Correlate** Nuclea's returns — the **PRO / ERR / RET** file returns and the **ASLC028** status message — back to the file and its operations **by file name**.

## Message families

***

| Flow                    | Message family                                            |
| ----------------------- | --------------------------------------------------------- |
| Credit settlement       | ASLC027 / ASLC028                                         |
| Debit settlement        | ASLC029 / ASLC030                                         |
| Anticipation            | ASLC031 / ASLC034                                         |
| Returns and devolutions | ASLC041 / ASLC042 / ASLC043                               |
| Cancellation            | ASLC060–ASLC067                                           |
| Domicile inbound        | ASLC022 / ASLC023 / ASLC024 / ASLC025 / ASLC032 / ASLC033 |

## Settlement flows

***

* **Credit (acquirer).** Operations enter through the canonical intake, Lerian SLC builds the credit file (**ASLC027**), signs and transmits it, and correlates the **ASLC028** status and the PRO/ERR/RET returns, advancing each operation through its NUliquid lifecycle.
* **Debit and anticipation.** The same intake-build-sign-transmit pipeline runs with the debit (**ASLC029 / ASLC030**) and anticipation (**ASLC031 / ASLC034**) families; status returns and NUliquid tracking mirror the credit flow.
* **Cancellation.** The acquirer informs a cancellation (credit **ASLC060**, debit **ASLC064**); Lerian SLC relays it to the **IF Domicílio** (**ASLC061**), receives the domicile's processing return (**ASLC062**), returns the outcome to the acquirer (**ASLC063 / ASLC067**), and emits a cancellation-confirmed-by-domicile event carrying the NUliquid.

## IF Domicílio inbound

***

Acting as the domicile institution, Lerian SLC receives credit and debit settlement notices (**ASLC022 / ASLC024 / ASLC032**), confirms them (**ASLC023 / ASLC025 / ASLC033**), and issues returns and devolutions (**ASLC041 / ASLC042 / ASLC043**). A webhook keyed by the NUliquid signals the credit to the merchant and carries the return evidence.

## Clearing and funding for the IF Liquidante

***

For the settling institution, Lerian SLC consumes the inbound clearing preview and final (**SLC0001**), the **SLC0002** message, and operational status (**PAG0101**) over the RSFN, builds the **clearing position per settlement cycle**, and detects **D0-versus-D+1** value divergence. It raises events for preview-available, final-available, deposit-required, and deposit-deadline-approaching.

## Operation lifecycle

***

Every operation advances through an **11-state** lifecycle, tracked by its NUliquid.

| State             | Meaning                                                       |
| ----------------- | ------------------------------------------------------------- |
| **CREATED**       | The operation has been accepted into Lerian SLC.              |
| **QUEUED**        | It is queued for the next file build.                         |
| **SENT**          | Its file has been transmitted to Nuclea.                      |
| **ACKNOWLEDGED**  | Nuclea has acknowledged receipt.                              |
| **ACCEPTED**      | Nuclea has accepted the operation.                            |
| **REJECTED**      | Nuclea has rejected the operation.                            |
| **FORWARDED**     | The settlement notice has been forwarded to the IF Domicílio. |
| **CONFIRMED**     | The domicile has confirmed.                                   |
| **SETTLED**       | The operation has settled.                                    |
| **D1\_CONFIRMED** | Settlement is confirmed on D+1.                               |
| **CANCELLED**     | The operation has been cancelled.                             |

Files carry their own **10-state** lifecycle, tracked per file from build through transmission and return correlation.

## Signing orchestration

***

Lerian SLC materializes the unsigned ASLC XML and then **delegates signing to a custody backend chosen per tenant**. The private key never leaves the client's custody, and Lerian never signs on the client's behalf.

| Custody backend  | Where the key lives                              |
| ---------------- | ------------------------------------------------ |
| **Software key** | A software-held key in the client's environment. |
| **PKCS#11 HSM**  | A hardware security module.                      |
| **Cloud KMS**    | A cloud key-management service.                  |
| **Vault**        | A secrets vault, per certificate.                |

In SaaS deployments, custody is locked to cloud KMS via **client-side-wrapped key import**: the client wraps and imports its own key, and the service stores only the public certificate and a key reference — never the private material.

## Transport

***

Operations and files are submitted to Nuclea over **REST**, secured by **mTLS** and a **per-request JWS** signature (the SLC0908 / SLC0912 / SLC0915 / SLC0999 online series). The inbound returns are polled and acknowledged over the same REST channel.
