# Glossary > Coming from classical accounting? See > [accounting-mapping.md](accounting-mapping.md) for how journals, entries, and > ledgers map onto Kuatia's transfers, postings, and books. ## Terms ### Posting A signed amount of one asset owned by one account. The fundamental unit of value in the ledger. Postings are immutable once created. A consumed posting leaves the live index but is never deleted from the record. - **Positive posting**: value controlled by the account. - **Negative posting**: an offset position, allowed on any account that permits overdraft (the `DEBIT_MUST_NOT_EXCEED_CREDIT` flag is not set). It represents issuance, external flow, boundary/system balancing, or an overdraft. An account that forbids overdraft may not hold one. State: `Live` (unspent) → `Spent` (consumed by a committed transfer), derived from live-index membership rather than stored. **Balance** sums the live postings; there is nothing between the two states, so what an account holds and what it can spend are the same set. ### Account A versioned entity that owns postings. Balance is never stored. It is always the sum of the live postings for a given (account, asset) pair. Accounts have **flags** (lifecycle, the `DEBIT_MUST_NOT_EXCEED_CREDIT` balance constraint, and user-defined bits) and a **book** assignment. They carry no accounting class, so a class lives in metadata or a user flag bit: see [accounts carry no accounting class](accounts.md#accounts-carry-no-accounting-class). An account is identified by `AccountId { id: i64, sub: i64 }`: a base `id` plus a **subaccount**. `sub = 0` is the main account; a non-zero `sub` is a subaccount of the same base id, and each `(id, sub)` is a full account record with its own flags and lifecycle. Balances are reported per subaccount and never summed across them. See the Subaccount entry and [adr/0012-subaccounts.md](adr/0012-subaccounts.md). ### Subaccount A partition of one owner's holdings under a shared base id. `AccountId::with_sub(id, sub)` names one; `AccountId::base()` returns the main account of an id. A base account does not roll up its subaccounts, so several independent balances live under one owner, each individually addressable, drained, and closed. Aggregate reads take a base `id` plus an optional subaccount filter; exact entity operations take the full `AccountId`. Subaccounts let one account hold many concurrent inflights (a hold is a subaccount of its destination). `AccountId` also has an IBAN-style string view via `Display` / `FromStr`: a fixed 20 characters, an 18-char base-36 body of the packed legs then two mod-97 check digits (no country code), e.g. `FK9RA6QALU15JZ7DZM81` for `{ id: 5, sub: 7 }` (grouped: `FK9R A6QA LU15 JZ7D ZM81`, five groups of four). Parsing validates the checksum, rejecting mistyped ids. It is a presentation/routing form (the dashboard URLs); storage keeps the two `i64` legs. See ADR-0015. ### Asset A unit of value: a currency, a product, a token. Each asset is an independent conservation boundary, so the sum of consumed postings must equal the sum of created postings *per asset* in every transfer. A caller names one by its code: `ledger.asset("EUR", "\u{20ac}", 2)` registers it on first sight and hands back the handle, and a code already registered at another precision is refused rather than quietly returned (ADR-0030). `AssetId(u32)` identifies one, minted by the ledger, and an `Asset` or an `Arc` converts into its id, so anything taking an asset accepts whichever a caller holds. `Asset { id, code, symbol, decimals }` is its registry row, written once and never updated, and `decimals` is the scale a written amount of it parses at. An unregistered asset has no amount: a [transfer](transfers.md) in one is rejected and a balance read of one fails, because nothing could say what the number means (ADR-0028). ### Amount A [`Cent`](crates.md) with the asset it is denominated in. The type exists so that two balances in different assets cannot be added: a `Cent` on its own compares and adds with any other. Built only by conversion, in whichever form the caller has. An integer is minor units and a string is the written form at the asset's own scale, so `(500, usd)` and `("5.00", usd)` are the same amount of a two-decimal asset, and `("5.001", usd)` is refused rather than rounded. A fraction shorter than the scale is padded, so `"100.0"` of a two-decimal asset is ten thousand minor units. The value comes first, the way the money reads aloud. Three spellings reach the same conversion: the handle (`(500, usd)`), a reference to it (`(500, &usd)`, which is what a caller with one asset and several movements writes), and the asset's own side (`usd.amount(500)?`, the `Denominate` trait, which works on an `Asset` or an `Arc` and has to be in scope). What comes back out is the amount itself: `Display` renders it at its asset's scale, `checked_add` and its siblings refuse two assets, and `minor_units()` gives the plain integer for a caller formatting its own layout. The money type underneath is not public (ADR-0029). ### Movement The intent layer's building block: an [amount](#amount) moving from one account to another. Movements express *what* should happen, and the ledger resolves them into concrete postings. A caller states one as `(from, to, amount)`, and the stored `Movement` holds exactly that. So does a [`Posting`](#posting): the asset and the value do not travel separately anywhere above the database columns (ADR-0029). ### Transfer One or more movements to execute atomically. Built via `TransferBuilder`, committed via `ledger.commit(transfer)`. ### Envelope The resolved, concrete form of a transfer: which postings to consume and which to create. Produced by the resolve step (`commit`), or built directly and committed via `commit_envelope(envelope)`. ### Atomic commit The design where a whole transfer commits in one store transaction (`CommitStore::commit_envelope`). The pure core validates first; the transaction re-checks the stateful guards inside it (double-spend, freeze/close, overdraft floor) and applies the effects all-or-nothing. A crash leaves no half-applied state, so there is no write-ahead log and no recovery. See ADR-0023 (superseding ADR-0003). The remaining posting/account write methods stay dumb: each applies one update and returns the number of affected rows, never interpreting it. ### Double-spend guard The concurrency-control mechanism for consumed postings: inside the atomic commit, deleting a consumed live posting is a single atomic conditional update, so two commits cannot both spend it. The loser sees the row gone and is rejected with `DoubleSpend`. This (not a global validation snapshot) is what prevents double-spend. ### Book A **Book is a transfer policy scope**: it gates which accounts and assets may participate in a transfer. Note what it is *not*: - It is **not** the classical accounting journal (the chronological book of entries). That role is played by the append-only transfer log itself. - It does **not** partition balances. Accounts and their balances are global; a Book only gates *who can transact with whom in what context*. A book is `{ id, name, policy }`, where the `policy` (`BookPolicy`) holds: - `allowed_assets`: if non-empty, only these assets may appear in movements. - `allowed_flags`: if non-empty, accounts with ANY of these flags may participate. - `allowed_accounts`: if non-empty, these specific accounts may participate (in addition to flag matches). An empty policy (no restrictions) allows any account and any asset. ### Conservation For every transfer, for each asset: `sum(consumed) == sum(created)`. This is the double-entry-style safety invariant (the UTXO-model equivalent of `Σ debits = Σ credits`), enforced at the type level. No value is created or destroyed. It only moves. ### AutoId Snowflake-inspired `i64` identifier: `[0 sign bit][40-bit ms timestamp][23-bit counter or CRC32]`. The timestamp counts milliseconds since `KUATIA_EPOCH_MS` (2026-01-01T00:00:00Z), giving ~34.8 years of range going forward. Generated in Rust. The database never assigns IDs. --- ## Usage examples The worked examples moved to their own section: [overdraft](examples/overdraft.md), [currency exchange](examples/exchange.md), [retail point of sale](examples/retail.md), and the [runnable programs](examples/runnable.md). --- ## Book Design ### When to use books - **Always**: even if you only have one flow, defining a book documents what assets and accounts are expected. - **Multiple flows**: separate books for sales, payments, inventory, banking. Prevents cross-contamination. - **Multi-tenant**: one book per tenant, with `allowed_accounts` naming that tenant's accounts, records and gates which accounts may transact together. It does not isolate one tenant from another: see [books are not a tenancy boundary](#books-are-not-a-tenancy-boundary). ### Book scoping rules | Field | Empty | Non-empty | |-------|-------|-----------| | `allowed_assets` | Any asset allowed | Only listed assets | | `allowed_flags` | Flag check skipped | Accounts with ANY matching flag pass | | `allowed_accounts` | Account check skipped | Listed accounts always pass (even without matching flags) | An account passes the book check if: 1. It matches `allowed_flags` (any flag in common), OR 2. It is explicitly listed in `allowed_accounts`, OR 3. Both lists are empty (unrestricted book). ### Books do NOT partition balances An account's balance is the sum of all its live postings across ALL books. If Alice receives 100 USD via the `deposits` book and spends 50 USD via the `trading` book, her balance is 50 USD, not 100 in one book and -50 in another. This is intentional: books scope *access*, not *state*. ### Books are not a tenancy boundary A book gates which accounts and assets may appear in one transfer. It is not an isolation boundary, and what follows from that is not obvious from the name: - Balances are global, as above. - No read is restricted by book. `TransferQuery::book` is a filter a caller may pass, and `list_accounts`, `history` and the posting reads take no book at all, so nothing stops a query from returning another tenant's rows. - The gate is per transfer and the caller picks it. A transfer naming the default book when no such book is stored commits with no policy applied at all, so a book cannot be relied on to hold a caller in. Isolation is a deployment choice instead: give each tenant its own `Store`, meaning its own database or schema. A ledger over that store needs no cross-tenant check, because the store holds nothing belonging to another tenant.