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.
Movement,
Posting, NewPosting and BalanceProjection each hold one Amount
instead of an AssetId beside a value, and an amount serializes with its
asset's definition, so a stored record decodes with no registry to consult.
The content address is unchanged: it still hashes the asset's id and the
value, and a golden vector in kuatia-core asserts it. The amount columns
are unchanged too, so ADR-0024's exact sums and indexes still work; a posting
read left-joins the registry to rebuild the amount, and fails loudly rather
than dropping a row if an asset is missing. Cent no longer appears in any
public signature: an Amount gives up Display, checked arithmetic that
refuses two assets, and minor_units() -> i128, and the other crates reach
the integer through kuatia_types::internals. AssetId stays public as the
name of an asset. (breaking throughout) (ADR-0029)Two notes for an upgrade. Register every asset already in use first, or reads of postings in unregistered assets fail. And an inflight authorization opened before this cannot be confirmed after it: the leg table is CBOR inside a transfer's metadata and its shape moved.
Amount that carries its asset. Asset { id, code,
symbol, decimals } is a row written once and never updated; AssetStore
adds create_asset/get_asset/list_assets and migration 014_assets.
Amount pairs a Cent with the Arc<Asset> it is denominated in, built
only by conversion: an integer is minor units, a string is the written form
parsed at the asset's own scale, so (500, usd) and ("5.00", usd) are the
same amount and ("5.001", usd) is refused. balance, balance_exact,
balance_as_of and SubAccountBalance now hand back an Amount, so two
balances in different assets cannot be added by the caller holding them, and
InsufficientFunds names the asset that fell short. A commit refuses an
unregistered asset, and a balance read of one fails: an unregistered asset
has no precision to report at. Each conversion also takes a reference to the
asset (("100.00", &usd)), and Denominate gives the same conversions from
the asset's side (usd.amount("100.00")?), so one handle serves several
movements without cloning. Arc<Asset> stops at the public API, so
nothing stored moves and CANONICAL_VERSION stays at 6. (breaking: every
balance read, and any caller matching on InsufficientFunds) (ADR-0028)Cent: TryFrom<i128>, the range-checked conversion that previously existed
only inside the canonical and storage byte decoders.Ledger::balance_as_of(account, asset, as_of), the balance as it stood at a
past commit instant: the newest cache point at or before as_of plus the
transfers committed up to it. as_of is commit time in unix milliseconds and
never a value date, because the cache points a read folds against are
watermarked by the commit clock. A past balance cannot be taken from the
postings, which carry no timestamp, so the read folds transfers; with no cache
point below as_of it folds the whole history up to it. An as-of read appends
no cache point. No new storage method and no decision of its own: the storage
lookup already took an as_of (ADR-0019).TransferBuilder::value_date(..) and the ValueDate calendar-day type, for an
entry booked on a different day than it belongs to: a correction, a late
settlement, a future-dated order. TransferQuery gains from_value_date and
to_value_date, so a period report groups by the day an entry takes effect
rather than by the clock it was typed on. The value date is part of the
content address, so two entries differing only in that day are two transfers,
and CANONICAL_VERSION moves to 6: content addresses computed under an
earlier version do not reproduce. created_at is unchanged and still not
caller-supplied. Migration 013_value_date. (ADR-0027)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.Ledger::asset(code, symbol, decimals) registers an asset on first sight and
returns its handle, so naming money takes one line and no invented id:
ledger.asset("EUR", "\u{20ac}", 2). Idempotent, so setup code calls it
unconditionally; a code already registered at another precision is
AssetRedefined rather than either definition quietly winning. The id is
minted in Rust as an account's or a book's is, code is unique (migration
015_asset_code_unique), and AssetStore gains get_asset_by_code. The
by-id lookup is now asset_by_id, and create_asset stays for a caller that
wants to choose the id. (breaking: Ledger::asset has a new meaning)
(ADR-0030)impl Into<AssetId>: BookBuilder::allow_asset
and the Ledger reads (asset, balance, balance_exact, balance_as_of,
balances). An Asset, an Arc<Asset>, a reference to either, or the id
itself all work, so a caller holding a handle stops writing .id to get four
bytes back out of it. The Store trait keeps &AssetId, since it is used
behind Arc<dyn Store> and a generic method would cost object safety.(500, usd), ("5.00", usd),
(500, &usd). The asset-first spelling is gone, because one order is enough
and this one reads the way the money does.Denominate covers Asset as well as Arc<Asset>, so asset.amount(500)?
works on a row from list_assets and not only on a handle from asset. It
is a trait, so it has to be in scope; the prelude brings it.Asset::scale is no longer public. It returned a Scale, which this cycle
took off the public surface, so a caller could call it and not name what came
back. An amount formats and parses itself."--5" used to strip one sign, parse
the rest with another, and come back as a positive five. One sign is allowed,
of either kind, and a digit or a point has to follow it.Ledger::asset reports AssetNotFound only for an absent row. A store
failure used to arrive as the same error, so a dropped connection told a
caller to register an asset it had registered already.TransferBuilder's verbs take one amount in place of an asset beside a
value: .pay(from, to, amount), .deposit(to, amount, external),
.withdraw(from, amount, external), .movement(from, to, amount), where
amount is anything convertible into an Amount. A failed conversion is
held until build, which now returns Result<Transfer, AmountError>. That
retires deposit's mid-chain Result, which was the one verb that broke the
fluent chain. (breaking for every builder call site) (ADR-0028)kuatia_money::Amount is Scale and ParseAmountError is
ParseDecimalError. The old name described a decimal-place count that parsed
and formatted and was never stored, and it is the name the asset-carrying
value wants. An asset's scale is reachable as asset.scale(). (breaking)
(ADR-0028)SubAccountBalance::value is amount, and carries an Amount. (breaking)/api/overview issued
figures serialize under value rather than issued.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)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)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)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)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)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)SagaStore::get_saga, a keyed read for a single write-ahead record, so
recovery no longer scans every pending record.FOR UPDATE and ON CONFLICT paths)
and runs the test suite with the i128 Cent backing.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)DEBIT_MUST_NOT_EXCEED_CREDIT flag; overdraft is allowed by default. (ADR-0018)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.UserData type and the orphaned withdraw saga step. (breaking)doc/journaling.md and ADR-0013, and notes it in the README overview.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.001_init.sql.Initial release.
sum(consumed) ==
sum(created)).pay, deposit, withdraw) resolved into concrete
postings by the core, committed through a single reserve → finalize saga
with automatic retry and LIFO compensation.NoOverdraft, CappedOverdraft, UncappedOverdraft,
SystemAccount, ExternalAccount, with append-only versioned accounts and
snapshot pinning to guard against TOCTOU races.Ledger::recover() (roll-forward, not rollback).Store trait split into focused sub-traits, with an in-memory
backend and a SQLite/PostgreSQL backend (kuatia-storage-sql).store_tests!) applied to every storage backend.i64 IDs generated in Rust; the database never assigns IDs.i64 default, i128 via the
i128 feature).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.