CHANGELOG.md 8.9 KB

Changelog

All notable changes to this project are documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

[Unreleased]

Added

  • TransferBuilder::reference(..), which writes a caller-supplied reference under the reserved REFERENCE_KEY metadata key. A transfer's id is the hash of its content, so a transfer that consumes nothing (a deposit, an issuance) cannot distinguish itself from an identical earlier one and the second commit is reported as a replay. Setting a distinct reference makes two real deposits two transfers; repeating one keeps a retry idempotent. See doc/transfers.md.

Changed

  • The ledger no longer has to be held in an Arc. commit, commit_envelope, reverse, the inflight entry points and workflow::run_transfers take &self, so Ledger::new(store) is usable directly; an Arc<Ledger> still derefs, so sharing stays available to callers who want it. (breaking only for code naming the receiver type) (ADR-0026)
  • EnvelopeId is TransferId and EnvelopeRecord is TransferRecord, so the public surface speaks of transfers throughout. Envelope, EnvelopeBuilder and commit_envelope keep their names as the resolved form. Nothing stored changes: no migration, no content address and no dedup key moves. (breaking) (ADR-0026)
  • Ledger::compute_balance is balance_exact, beside balance, so a call site says whether it took the cached read or the authoritative one. (breaking) (ADR-0026)
  • Ledger::with_snapshot_interval and with_projection_grace_ms become one with_projection_config(ProjectionConfig { .. }). (breaking) (ADR-0026)
  • kuatia::saga is now kuatia::workflow, and run_movements is run_transfers, taking the transfers themselves. Its own Movement, PayInput and DepositInput described legs it then rebuilt with TransferBuilder, and that Movement shadowed kuatia_types::Movement. (breaking)
  • ValidationError::OverdraftExceeded no longer carries a floor field. The balance model is binary (an account either permits unbounded overdraft or forbids any negative balance), so the floor was always zero and implied a configurable bound that does not exist. (breaking for callers matching on the variant)

Removed

  • TransferBuilder::movement_ref and pay_ref. Both pushed the same Movement as movement and pay: ADR-0012 meant them for subaccount endpoints, but every endpoint is a full AccountId already. (breaking) (ADR-0026)
  • Ledger::append_cache_point moves to ledger.projection().append_cache_point(..), since it maintains the balance cache rather than reading a balance. (breaking) (ADR-0026)
  • The reservation protocol, which the atomic commit of ADR-0023 had left without a producer. PostingState::Reserved, PostingFilter::{Active, Reserved}, ReservationId and TransitionId are gone, and live_postings.reservation is dropped by migration 012_drop_reservation. A posting is live or spent, with nothing in between. (breaking: PostingState::Active is now Live, which also changes its serde representation, and the dashboard reports a posting's status as "Live" rather than "Active") (ADR-0025)
  • Six Store write methods: reserve_postings, release_postings, deactivate_postings, insert_postings, append_account_version and store_transfer. Nothing called them, and because Ledger::store() returns the trait they were a public route to spend a posting or append a version while skipping the guards the commit transaction enforces. CommitStore is now the only way either is written. (breaking for out-of-tree backends) (ADR-0025)

0.3.0 - 2026-07-30

Added

  • Subaccounts: AccountId gains a subaccount leg ({ id, sub }), 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 operations take the full AccountId; balances are never summed across subaccounts. (ADR-0012)
  • Inflight holds: authorize, confirm, and void value through per-destination holding subaccounts, so an authorization reserves funds without committing them and a void returns them. (ADR-0014)
  • IBAN-style account identifiers: AccountId has a fixed 20-character Display/FromStr form (a base-36 body plus two mod-97 check digits) for presentation and routing, while storage keeps the two integer legs. (ADR-0015)
  • Cached balance projection: an append-only balance snapshot, refreshed lazily off the read path once enough activity accrues, shortens the everyday balance read; the authoritative live-posting sum stays the source of truth. (ADR-0019)
  • SagaStore::get_saga, a keyed read for a single write-ahead record, so recovery no longer scans every pending record.
  • Continuous integration now runs the storage conformance suite against PostgreSQL (exercising the Postgres-only FOR UPDATE and ON CONFLICT paths) and runs the test suite with the i128 Cent backing.

Changed

  • Storage write contract: every Store write method returns the number of affected rows and makes no domain decision. The saga interprets counts and owns idempotency and compensation, with a phase-tracked write-ahead record and roll-forward crash recovery in place of a monolithic commit transaction. (ADR-0003) (breaking for Store implementors)
  • Account balance constraint collapsed to the single DEBIT_MUST_NOT_EXCEED_CREDIT flag; overdraft is allowed by default. (ADR-0018)
  • The SQL schema separates append-only value tables from disposable active/reserved index tables. (ADR-0016, ADR-0017)
  • Intent resolution is pure and preserves typed errors across the saga.
  • Internal structure: the Ledger was split into concern-named submodules; the commit-safety invariant is documented and its double-spend guard named (ADR-0021); the write-ahead recovery record was concentrated into one pending module; balance computation was consolidated into one module.

Removed

  • The vestigial UserData type and the orphaned withdraw saga step. (breaking)

Documentation

  • Document that the ledger supports journaling: a committed transfer is a journal entry, a transfer with multiple movements is a compound journal entry, and the transfer log is the accounting journal. Adds doc/journaling.md and ADR-0013, and notes it in the README overview.

0.2.0 - 2026-07-01

Added

  • kuatia-dashboard: a server-rendered dashboard and REST API for observing a Kuatia ledger over HTTP. Browse accounts, postings, transfers, and the event log; inspect per-account balances computed in Rust.

Changed

  • The SQL backend stores binary identifiers as hex text and structured columns as JSON text instead of opaque blobs, so a ledger can be audited directly with SQL tooling. The SQLite and PostgreSQL schemas were unified into a single 001_init.sql.

0.1.0 - 2026-06-30

Initial release.

Added

  • Append-only, multi-asset, UTXO-style ledger. Value is tracked as signed postings with no mutable balance fields. Transfers atomically consume and create postings, enforcing per-asset conservation (sum(consumed) == sum(created)).
  • Intent API: movements (pay, deposit, withdraw) resolved into concrete postings by the core, committed through a single reserve → finalize saga with automatic retry and LIFO compensation.
  • Content-addressed transfers (double-SHA-256 of canonical bytes) for idempotency and tamper evidence.
  • Account policies: NoOverdraft, CappedOverdraft, UncappedOverdraft, SystemAccount, ExternalAccount, with append-only versioned accounts and snapshot pinning to guard against TOCTOU races.
  • Durable crash recovery via a phase-tracked write-ahead saga record and Ledger::recover() (roll-forward, not rollback).
  • Dumb-storage Store trait split into focused sub-traits, with an in-memory backend and a SQLite/PostgreSQL backend (kuatia-storage-sql).
  • A conformance test suite (store_tests!) applied to every storage backend.
  • Snowflake-style i64 IDs generated in Rust; the database never assigns IDs.
  • Compile-time swappable monetary backing (i64 default, i128 via the i128 feature).

Crates

  • kuatia-money — monetary Cent type with swappable integer backing.
  • kuatia-types — domain types: accounts, postings, transfers, books.
  • kuatia-core — pure, sans-IO logic: validation, hashing, posting selection.
  • kuatia-storage — storage abstraction and conformance suite.
  • kuatia-storage-sql — SQLite/PostgreSQL backend.
  • kuatia — async Ledger resource and saga commit pipeline.