# Stack v4.0

Source: https://docs.formance.com/changelog/v4.0

Stack: v3.2

**Upcoming release**

This release has not shipped

Stack v4.0 is documented as a preview. Its component pins and its documentation set both change until a v4.0 release publishes its own specification, and no v4.0 stack serves production traffic today. The pages linked from this entry serve at the v4.0 preview; each link below moves you there.

| Component        | Version |
| ---------------- | ------- |
| ledger           | 3.0.0   |
| auth             | 2.4.3   |
| gateway          | 2.2.0   |
| search           | 2.1.0   |
| stargate         | 2.2.2   |
| mcp              | 0.3.0   |
| connectivity     | 1.0.0   |
| transactionplane | 0.2.1   |

## Stack composition

A v4.0 stack pins the components in the table above: **Ledger, Auth, Gateway, Search, Stargate, MCP, the transaction plane, and Connectivity**. Connectivity is part of the Enterprise Edition. Payments, Wallets, Flows (Orchestration), Reconciliation, and Webhooks are not part of the v4.0 composition and cannot be enabled on a v4.0 stack. Their documentation remains available under Stack v3.2.

Plan those workloads before moving a stack to v4.0. A stack running any of them stays on the v3.2 line until you have a replacement for each.

A new v4.0 stack installs the Ledger module by default. The other modules are not installed by default.

## Connectivity

Connectivity takes over from Payments for bringing external provider activity into the stack. Its connectors read activity from payment processors, banks, exchanges, and cloud billing, and record it directly in Ledger as accounts, transactions, and metadata, keeping the provider's own identities and timing. Browse the [Connector Catalog](https://docs.formance.com/v4.0/modules/connectivity/connectors), or read [Connectivity](https://docs.formance.com/v4.0/modules/connectivity) for the model.

## Ledger

Ledger moves to its 3.0 release line. This is a new implementation of the ledger rather than an increment on Ledger v2: it keeps the accounting model — transactions through postings or Numscript, reversals, metadata, unique references, idempotency, bulk operations, and read APIs — and replaces the storage, replication, API, and operational surfaces underneath it.

Existing Ledger v2 integrations are not wire-compatible. Read [Migrate from Ledger v2](https://docs.formance.com/v4.0/modules/ledger/migration) and [Update Ledger Clients](https://docs.formance.com/v4.0/modules/ledger/migration/update-clients) before planning an upgrade.

### PostgreSQL is no longer a runtime dependency

Ledger stores its data in an embedded Pebble store and replicates writes through Raft. Leader election, follower catch-up, snapshotting, and quorum behavior are owned by the ledger process rather than by a database deployment around it.

This removes the external database from the deployment, and moves WAL placement, disk capacity, backup, and restore into the ledger's own operational surface. See [Plan Topology and Manage Cluster Lifecycle](https://docs.formance.com/v4.0/modules/ledger/operations/cluster-lifecycle) and [Prepare a Ledger Deployment](https://docs.formance.com/v4.0/modules/ledger/operations/deploy).

### One cluster is one ordering domain

In Ledger v2 terms, a Ledger 3.0 cluster is equivalent to a single bucket: every ledger it hosts shares one Raft group and one global log ordering.

### Cross-ledger atomic batches

Because all ledgers share one ordering domain, a single command can carry actions targeting more than one ledger. The gRPC `Apply` call accepts such a command and applies every action atomically.

The HTTP bulk route is ledger-scoped — its ledger name comes from the request path — so `atomic=true` there means atomic _within that ledger_. Use gRPC when a batch has to span ledgers. See [Process Operations in Bulk](https://docs.formance.com/v4.0/modules/ledger/transactions/bulk) and the [gRPC API](https://docs.formance.com/v4.0/modules/ledger/reference/grpc-api).

### Idempotency covers the whole cluster

Idempotency applies to every operation at the system level rather than to transactions inside one ledger. Keys are no longer scoped per ledger: a key reused anywhere in the cluster with different request content is rejected with HTTP `409` and `IDEMPOTENCY_KEY_CONFLICT`.

Keys expire after the cluster's `--idempotency-ttl`, which defaults to 24 hours. Namespace keys per ledger when you generate them. See [Retry Writes Safely](https://docs.formance.com/v4.0/modules/ledger/transactions/idempotency-and-references).

### Mirror ledgers

A mirror ledger follows a running Ledger v2 instance over HTTP or directly from its PostgreSQL database, transforms the incoming records with CEL rules, reports synchronization progress, and is promoted to a normal ledger at cutover. This is the supported migration path off Ledger v2. See [Create a Mirror](https://docs.formance.com/v4.0/modules/ledger/migration/create-mirror) and [Transform Mirrored Data](https://docs.formance.com/v4.0/modules/ledger/migration/transformations).

### Data model

| Addition             | What it does                                                                                                                                                                                                                              |
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Typed metadata       | Declares the type of each metadata field and validates filters against it. See [Metadata and Typed Values](https://docs.formance.com/v4.0/modules/ledger/modeling/metadata).                                                              |
| Account types        | Match addresses by pattern, with `AUDIT` or `STRICT` enforcement and `NORMAL`, `EPHEMERAL`, or `TRANSIENT` volume persistence. See [Account Types and Enforcement](https://docs.formance.com/v4.0/modules/ledger/modeling/account-types). |
| Configurable indexes | Opt into address, metadata, reference, timestamp, and account-asset indexes per ledger, with backfill progress. See [Create and Manage Indexes](https://docs.formance.com/v4.0/modules/ledger/querying/indexes).                          |
| Prepared queries     | Reusable parameterized filters for list and aggregate reads. See [Create Prepared Queries](https://docs.formance.com/v4.0/modules/ledger/querying/prepared-queries).                                                                      |
| Query checkpoints    | Pin a read to a known log position and choose read consistency explicitly. See [Choose Read Consistency and Use Checkpoints](https://docs.formance.com/v4.0/modules/ledger/querying/consistency-and-checkpoints).                         |
| Numscript library    | Save Numscript programs per ledger under explicit semantic versions and call them by reference. See [Reuse and Version Numscript Programs](https://docs.formance.com/v4.0/modules/ledger/transactions/numscript-library).                 |

Ledger v2 combined address validation, metadata definition, transaction templates, and query templates behind one Ledger Schema API. Ledger 3.0 models those four concerns as independent resources, so there is no single schema version that selects all of them for a transaction.

### Request and response signing

Ledger 3.0 signs requests and responses with Ed25519, registers and revokes keys through a dynamic key-management API, and can be configured to require a signature on every admitted mutation. See [Request and Response Signing](https://docs.formance.com/v4.0/modules/ledger/operations/signing) and [Authentication and Authorization](https://docs.formance.com/v4.0/modules/ledger/operations/authentication).

### Audit log

The audit log records successful **and** failed operations, replicated through Raft and stored alongside the ledger's own state. A checker verifies that the audit trail and the persisted projections agree. See [Verify Ledger Integrity](https://docs.formance.com/v4.0/modules/ledger/operations/integrity).

### Operations

- **Maintenance mode** blocks writes cluster-wide behind a replicated flag — see [Use Maintenance Mode](https://docs.formance.com/v4.0/modules/ledger/operations/maintenance-mode).
- **Disk-space safeguards** reject writes once node usage crosses a configured threshold.
- **Full and incremental backups** export to object storage, and a restore combines the latest full backup with the incrementals recorded after it — see [Back Up a Cluster](https://docs.formance.com/v4.0/modules/ledger/operations/backup) and [Restore a Cluster](https://docs.formance.com/v4.0/modules/ledger/operations/restore).
- **Cursor-based event sinks** deliver log events to downstream consumers with a durable cursor — see [Configure an Event Sink](https://docs.formance.com/v4.0/modules/ledger/events/configure-sink).

### gRPC and HTTP are not symmetric

Both surfaces cover the core accounting workflows: writing transactions from postings or Numscript, reverting, metadata, unique references, idempotency, bulk, and reads. They diverge past that, so choose the surface per workflow rather than once per application.

- Cross-ledger atomic batches are gRPC-only. The HTTP bulk route takes its ledger from the request path.
- Several administrative capabilities are exposed through gRPC and `ledgerctl` with no equivalent HTTP route.
- Direct HTTP list routes always take the default linearizable read. They expose neither the `stale` nor the `leader` consistency selector, nor checkpoint or minimum-sequence options; prepared-query execution is the one HTTP query surface that accepts `minLogSequence`.
- Log import and export are unavailable on both surfaces — the interfaces are defined but not implemented.

See [HTTP API](https://docs.formance.com/v4.0/modules/ledger/reference/http-api), the [gRPC API](https://docs.formance.com/v4.0/modules/ledger/reference/grpc-api), and [Limits and Compatibility](https://docs.formance.com/v4.0/modules/ledger/reference/limits-and-compatibility).

## Breaking changes

### Modules removed from the composition

Payments, Wallets, Flows (Orchestration), Reconciliation, and Webhooks are not composed by a v4.0 stack.

### No Ledger v2 compatibility layer

Ledger 3.0 serves business endpoints under `/v3` and does not ship a `/v2` shim. Every Ledger v2 integration migrates to the `/v3` HTTP contract or to gRPC.

### `dryRun` is not supported

Ledger v2 accepted `dryRun` on transaction creation, reverts, and metadata writes to evaluate a write without committing it. Ledger 3.0 has no equivalent.

### Ledger v2 capabilities with no Ledger 3.0 equivalent

Each of these fails a working Ledger v2 client rather than degrading it. [Removed Capabilities](https://docs.formance.com/v4.0/modules/ledger/migration/removed-capabilities) covers what replaces each one.

- **Account date fields.** `firstUsage`, `insertionDate`, and `updatedAt` are gone from the account and can't be used to filter or order accounts.
- **Pre-commit and effective volumes.** `postCommitVolumes` remains and is returned on every transaction, with no flag to toggle it.
- **Per-account balance and volume routes.** `GET /accounts/{address}/balances` and `GET /accounts/{address}/volumes` are gone.
- **Point-in-time volume queries.** `/volumes` no longer accepts `startTime`, `endTime`, or `insertionDate`.
- **`prefix=` and `reference=` query parameters.** Both are expressed through `filter=`.
- **`metadataCount` in ledger statistics.** It is no longer reported.
- **Log import and export.** Mirror mode is the supported way to move history into Ledger 3.0.
- **Per-ledger `features` on ledger creation.** There is no equivalent field.
