journaling.md 6.6 KB

Journaling

Kuatia supports journaling. A committed transfer is a journal entry. The transfer log is the accounting journal: the append-only, ordered book of every committed entry. This page states what that means in practice. It shows a single entry, a compound entry and a multi-asset entry. It also gives the reason a replay can audit the log.

See accounting-mapping.md for the vocabulary mapping. That page separates a journal from a journal entry and from a Book, and it covers the terms that are easy to confuse. See transfers.md for the resolve algorithm and the builder API. See ADR-0013 for the decision record.

What "journaling" means here

In classical bookkeeping:

  • A journal is the book of original entry. It is a chronological, append-only record of every accounting event.
  • A journal entry is one balanced event. Its debits equal its credits.
  • A compound journal entry is one event that touches more than two accounts.

Kuatia gives the same guarantees over a UTXO-style, posting-based model:

Classical accounting Kuatia
Journal (book of original entry) Transfer log (TransferStore of TransferRecords)
Journal entry (one balanced event) Committed Transfer resolved into an Envelope
Compound journal entry Transfer with multiple Movements
Σ debits = Σ credits Per-asset conservation sum(consumed) == sum(created)

The mechanism differs, because Kuatia uses signed postings instead of a mutable balance. The accounting grain is identical: one committed transfer is one journal entry.

A journal entry: one balanced event

A Transfer is a Vec<Movement> that commits atomically. Each Movement carries an amount from one account to another.

On commit, resolve() turns the movements into an Envelope of concrete postings to consume and to create. Validation then enforces per-asset conservation before the ledger writes anything. The whole entry commits, or none of it does.

A minimal two-account entry:

let transfer = TransferBuilder::new()
    .pay(alice, bob, ("50.00", &usd))
    .build()?;

This is one journal entry. 50 USD leaves Alice, 50 USD arrives at Bob, and the resolved envelope balances, so sum(consumed) == sum(created) for USD.

Compound entries: more than two accounts

A compound journal entry is native and not a special case. A Transfer holds a list of movements, so a chain of builder calls collects several legs into one atomic entry.

Classical compound entry, a cash sale with tax:

2026-06-26  Cash sale of goods
  Dr  Cash ................. 115
      Cr  Revenue ..........     100
      Cr  Sales tax payable .      15

The same business effects as one Kuatia transfer:

let transfer = TransferBuilder::new()
    .book(sales_book)
    .pay(customer, revenue, ("100.00", &usd))
    .pay(customer, tax_payable, ("15.00", &usd))
    .build()?;
// One Transfer -> one Envelope -> one TransferRecord in the transfer log.

Both are one balanced event. In the classical entry, Σ Dr (115) = Σ Cr (115). In Kuatia the resolved envelope satisfies per-asset conservation for USD.

The resolve step aggregates the net debit per (account, asset) pair before it selects postings. So several legs that debit the same account share one selection pass. See transfers.md for the aggregation detail. See the note in accounting-mapping.md for the reason this shows business effects rather than a literal translation into debits and credits.

Multi-asset entries

Conservation holds per asset, and each asset is an independent conservation boundary. So one entry can move more than one asset, as long as every asset balances on its own. This is how the ledger records a currency exchange or an FX trade as one journal entry. The USD legs balance against USD, and the EUR legs balance against EUR, inside the same envelope.

A hand-built multi-asset envelope commits through the same path, with ledger.commit_envelope(envelope). Validation returns ConservationViolation { asset, consumed_sum, created_sum } when any single asset fails to balance.

The transfer log is the journal

One entry and the journal differ only in grain:

  • A Transfer or an Envelope is one record, which is one journal entry.
  • The transfer log is the collection of all the records, which is the accounting journal. TransferStore persists each committed envelope as TransferRecord { envelope, receipt, created_at } in append-only order.

A commit of an entry returns a Receipt { transfer_id } that names the committed envelope. The TransferId is content-addressed, as the double-SHA-256 of the canonical envelope bytes. That gives idempotency, because a second commit of the same envelope returns the cached receipt. It also gives tamper evidence, because any edit changes the id.

Kuatia keeps a second append-only sequence, the event log, which is an EventStore of LedgerEvent. It serves lifecycle notifications and projections. It is not the journal. It records that something happened, and the transfer log records exactly which postings moved. See ADR-0010.

Auditability by replay

There is no stored balance that can drift. An account's balance is the sum of its Live postings, and the ledger computes it on demand. A re-apply of every TransferRecord in order reconstructs all the balances exactly.

Each entry balances per asset, and the log is append-only and content-addressed. So the journal is verifiable, because you can recompute any balance. It is also tamper-evident, because any change to a past entry breaks its id.

Not a journal

Two Kuatia concepts are easy to mistake for the journal, and neither one is the journal:

  • Book is a transfer policy scope. It gates which accounts and assets can participate in a transfer. It is not the journal, not a journal entry, not a balance partition, and not a tenancy boundary. See accounting-mapping.md.
  • The event log records lifecycle notifications for a subscriber. The transfer log is the source of truth for balances.

See also

  • accounting-mapping.md: the full vocabulary mapping from classical double-entry to Kuatia.
  • transfers.md: Movement, the resolve algorithm, and the TransferBuilder API.
  • ADR-0013: the decision to model a transfer as a compound journal entry, and the transfer log as the journal.