0013-journaling-model.md 5.4 KB

Journaling model: a transfer is a journal entry, the transfer log is the journal

  • Status: accepted
  • Authors: Cesar Rodas
  • Date: 2026-07-08
  • Targeted modules: kuatia-types, kuatia-core, kuatia (transfer log), doc
  • Associated tickets/PRs: n/a

Context and Problem Statement

The documents present Kuatia as a double-entry-style ledger. But it has no "journal" type and no "journal entry" type. It has a Book type, and that name invites confusion with an accounting book or a journal.

A user asks whether the ledger supports journaling, and in particular a compound entry that touches more than two accounts. The mechanics exist already. A Transfer is a list of Movements that commits atomically, and TransferStore is an append-only log.

So the open question is what to call these things, and how to present them. In Kuatia's model, what is a journal entry, what is the journal, and what is Book?

Decision Drivers

  • An accountant and an integrator both reason in terms of a journal, a journal entry and a compound entry. The model must map onto those terms, and it must need no new type.
  • The mapping must say exactly what the journal is, and what it is not. Book, the transfer log and the event log are all easy to confuse.
  • Per-asset conservation is the safety invariant. The documents must state it as the equivalent of Σ debits = Σ credits.
  • Add no redundant type. A new type must not duplicate Transfer, Envelope or TransferStore.

Considered Options

Option 1: Model journaling with the existing types, and document the mapping

State three things. A committed Transfer, resolved into an Envelope, is a journal entry. A Transfer with several Movements is a compound journal entry. The transfer log, a TransferStore of EnvelopeRecords, is the accounting journal.

Enforce the balance through the per-asset conservation check that exists. Record the terminology in accounting-mapping.md and in journaling.md.

Pros:

  • Good, because it needs no new type. The intent API (ADR-0005) gives the grain, which is one entry, and the transfer log gives the collection, which is the journal.
  • Good, because a compound entry and a multi-asset entry both come free. A transfer is a list of movements already, and conservation is per asset already.
  • Good, because auditability is structural already. A replay of the log reconstructs the balances, and a content-addressed id gives tamper evidence.

Cons:

  • Bad, because the word "posting" is a noun in Kuatia, a value fragment, and a verb in classical accounting, the act of a record. The documents must name that collision.
  • Bad, because Book keeps a name that suggests an accounting book. The documents must disclaim it again and again.

Option 2: Add explicit Journal and JournalEntry types

Add dedicated types that wrap the transfer log and a committed transfer.

Pros:

  • Good, because the vocabulary sits in the type system and not in prose alone.

Cons:

  • Bad, because it is pure duplication. JournalEntry is a Transfer or an Envelope, and Journal is a TransferStore. Two names for one concept invite drift.
  • Bad, because a dedicated debit or credit line type fights the UTXO model. In that model the primitive is a signed posting and not a one-sided line.

Option 3: Rename Book to something journal-adjacent

Rename Book, to reduce the confusion with an accounting book.

Pros:

  • Good, because it removes one source of confusion in the names.

Cons:

  • Bad, because Book is a transfer policy scope and not a journal. A name close to "journal" makes the confusion worse rather than better. The fix is documentation and not a rename.

Decision Outcome

Chosen option: Option 1. Model journaling with the types that exist, and document the mapping.

A committed Transfer, resolved into an Envelope, is a journal entry. A Transfer with several Movements is a compound journal entry. The transfer log is the accounting journal.

Per-asset conservation is the equivalent of Σ debits = Σ credits. It is sum(consumed) == sum(created), and validate_and_plan enforces it.

Book is a transfer policy scope. It is not the journal, not a journal entry and not a balance partition. The event log (ADR-0010) carries lifecycle notifications, and it is not the journal.

Positive Consequences

  • The ledger supports journaling, and that covers a compound entry and a multi-asset entry. It needs no new type and no schema change.
  • A replay audits the journal, and the journal is tamper-evident by construction.
  • One place documents the traps in the names. Those are Book against the journal, "posting" as a noun against "posting" as a verb, and the transfer log against the event log.

Negative Consequences

  • The vocabulary lives in the documentation and not in the type system. So it depends on journaling.md and accounting-mapping.md, and both must stay accurate.
  • Book keeps a name that needs a disclaimer in every document that uses it.

Links