|
@@ -7,8 +7,53 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
|
|
|
|
|
## [Unreleased]
|
|
## [Unreleased]
|
|
|
|
|
|
|
|
|
|
+## [0.4.0] - 2026-12-02
|
|
|
|
|
+
|
|
|
|
|
+### Upgrading to 0.4.0
|
|
|
|
|
+
|
|
|
|
|
+In this order, before the first commit against an upgraded database:
|
|
|
|
|
+
|
|
|
|
|
+1. **Register every asset already in use**, with the precision it was always
|
|
|
|
|
+ recorded at. A posting now rebuilds its amount by joining the registry, so a
|
|
|
|
|
+ posting in an unregistered asset fails its read loudly rather than coming
|
|
|
|
|
+ back at the wrong scale.
|
|
|
|
|
+2. **Settle any two assets sharing a code** before migration `015` adds its
|
|
|
|
|
+ unique index, or the migration fails on them. Two assets under one code
|
|
|
|
|
+ split every balance held in it, which is the condition the index exists to
|
|
|
|
|
+ prevent, and only a human knows which row is the real one.
|
|
|
|
|
+3. **Drain inflight authorizations.** An authorization opened before the
|
|
|
|
|
+ upgrade cannot be confirmed after it: the leg table is CBOR inside a
|
|
|
|
|
+ transfer's metadata and its shape moved twice this cycle.
|
|
|
|
|
+
|
|
|
|
|
+Stored transfer ids from 0.3.0 do not reproduce. The content-address preimage
|
|
|
|
|
+moved twice: `payer` left it and `value_date` joined it, and
|
|
|
|
|
+`CANONICAL_VERSION` is now 6. The recorded ids are untouched and still verify
|
|
|
|
|
+against the bytes that produced them, so the audit trail is intact; recomputing
|
|
|
|
|
+one from its transfer under this version gives a different id.
|
|
|
|
|
+
|
|
|
### Added
|
|
### Added
|
|
|
|
|
|
|
|
|
|
+- `Ledger::authorize_until(transfer, expires_at)`, an authorization with a
|
|
|
|
|
+ deadline, plus `expire(inflight, now)` and `expire_due(now)` to return its
|
|
|
|
|
+ funds once that deadline has passed. An authorize with nobody to settle it
|
|
|
|
|
+ used to park its funders' money indefinitely. The deadline is written onto
|
|
|
|
|
+ the holding account at creation, where it cannot drift, and expiring runs the
|
|
|
|
|
+ existing void path, so an expired authorization returns exactly what a void
|
|
|
|
|
+ returns: each posting to the account that funded it, only the remainder when
|
|
|
|
|
+ some legs were confirmed, and confirmations left alone. Nothing expires on
|
|
|
|
|
+ its own: `expire_due` takes the clock and is a method a caller schedules.
|
|
|
|
|
+ `authorize` is unchanged and records no deadline. See
|
|
|
|
|
+ [doc/inflight.md](doc/inflight.md#expiry).
|
|
|
|
|
+- `Ledger::holdings(account)`, every asset one account holds, with what it
|
|
|
|
|
+ holds of each. A balance read answered for one account and one asset, so
|
|
|
|
|
+ asking what an account held at all meant the caller keeping its own list of
|
|
|
|
|
+ the assets to ask about. Assets the account has no live posting of are
|
|
|
|
|
+ absent rather than reported as zero.
|
|
|
|
|
+
|
|
|
|
|
+ No read aggregates across accounts, so a trial balance, a balance sheet and
|
|
|
|
|
+ a P&L are the application's to build, off the event stream where they can be
|
|
|
|
|
+ cached (ADR-0031). `holdings` and `balances` are bounded by one account,
|
|
|
|
|
+ which is what lets the store be sharded on it later.
|
|
|
- Amounts are what the ledger stores and what it hands back. `Movement`,
|
|
- Amounts are what the ledger stores and what it hands back. `Movement`,
|
|
|
`Posting`, `NewPosting` and `BalanceProjection` each hold one `Amount`
|
|
`Posting`, `NewPosting` and `BalanceProjection` each hold one `Amount`
|
|
|
instead of an `AssetId` beside a value, and an amount serializes with its
|
|
instead of an `AssetId` beside a value, and an amount serializes with its
|
|
@@ -22,11 +67,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
refuses two assets, and `minor_units() -> i128`, and the other crates reach
|
|
refuses two assets, and `minor_units() -> i128`, and the other crates reach
|
|
|
the integer through `kuatia_types::internals`. `AssetId` stays public as the
|
|
the integer through `kuatia_types::internals`. `AssetId` stays public as the
|
|
|
name of an asset. *(breaking throughout)* (ADR-0029)
|
|
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.
|
|
|
|
|
- An asset registry, and an `Amount` that carries its asset. `Asset { id, code,
|
|
- An asset registry, and an `Amount` that carries its asset. `Asset { id, code,
|
|
|
symbol, decimals }` is a row written once and never updated; `AssetStore`
|
|
symbol, decimals }` is a row written once and never updated; `AssetStore`
|
|
|
adds `create_asset`/`get_asset`/`list_assets` and migration `014_assets`.
|
|
adds `create_asset`/`get_asset`/`list_assets` and migration `014_assets`.
|
|
@@ -74,6 +114,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
|
|
|
|
|
### Changed
|
|
### Changed
|
|
|
|
|
|
|
|
|
|
+- A transfer commits in one store transaction. `CommitStore::commit_envelope`
|
|
|
|
|
+ spends the consumed postings, inserts the created ones, records the transfer
|
|
|
|
|
+ and appends its event together, so a crash leaves nothing half applied and
|
|
|
|
|
+ there is nothing to recover: the write-ahead record and its machinery
|
|
|
|
|
+ (`SagaStore`, `PendingSaga`, `Ledger::recover`, the reserve/finalize phases)
|
|
|
|
|
+ are gone and migration `010_drop_sagas` drops the table. The guards that used
|
|
|
|
|
+ to be checked before the write are re-checked inside that transaction and are
|
|
|
|
|
+ now strict rather than best-effort: double-spend (the delete's affected count
|
|
|
|
|
+ is the atomic single-winner claim), freeze and close, and the no-overdraft
|
|
|
|
|
+ floor. Multi-transfer composition is a plain LIFO runner over `commit` and
|
|
|
|
|
+ `reverse` instead of a saga interpreter. *(breaking for `Store`
|
|
|
|
|
+ implementors, and `Ledger::recover` is gone)* (ADR-0023)
|
|
|
|
|
+- Amount columns are native integers the database can add up exactly:
|
|
|
|
|
+ `NUMERIC(39,0)` on PostgreSQL and a 16-byte order-preserving `BLOB` on
|
|
|
|
|
+ SQLite, through migrations `011`. An amount used to be stored in a form only
|
|
|
|
|
+ Rust could interpret, so every aggregate had to be folded in the process that
|
|
|
|
|
+ asked, and the commit transaction could not check a balance without shipping
|
|
|
|
|
+ the rows out of the database. The floor check and the live-balance read are
|
|
|
|
|
+ now one exact aggregate inside the transaction, `SUM()` on Postgres and a
|
|
|
|
|
+ registered `kuatia_i128_sum` on SQLite, both of which raise on overflow
|
|
|
|
|
+ instead of wrapping. Ordering and range predicates work on the column
|
|
|
|
|
+ directly. No floating point goes near an amount, and everything that is not
|
|
|
|
|
+ an exact aggregate over one of these columns is still computed in Rust with
|
|
|
|
|
+ checked arithmetic. *(on-disk format change)* (ADR-0024)
|
|
|
|
|
+- `payer` is provenance and no longer part of a transfer's identity, so it left
|
|
|
|
|
+ the content-address preimage. Two transfers that differ only in who paid are
|
|
|
|
|
+ now one transfer and the second commit is reported as a replay, which is the
|
|
|
|
|
+ point: the payer is a record of where the funds came from, not a way to make
|
|
|
|
|
+ an otherwise identical transfer distinct. *(breaking: a transfer id computed
|
|
|
|
|
+ under 0.3.0 does not reproduce)*
|
|
|
- `Ledger::asset(code, symbol, decimals)` registers an asset on first sight and
|
|
- `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:
|
|
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
|
|
`ledger.asset("EUR", "\u{20ac}", 2)`. Idempotent, so setup code calls it
|
|
@@ -271,8 +341,9 @@ Initial release.
|
|
|
- `kuatia-core` — pure, sans-IO logic: validation, hashing, posting selection.
|
|
- `kuatia-core` — pure, sans-IO logic: validation, hashing, posting selection.
|
|
|
- `kuatia-storage` — storage abstraction and conformance suite.
|
|
- `kuatia-storage` — storage abstraction and conformance suite.
|
|
|
- `kuatia-storage-sql` — SQLite/PostgreSQL backend.
|
|
- `kuatia-storage-sql` — SQLite/PostgreSQL backend.
|
|
|
-- `kuatia` — async `Ledger` resource and saga commit pipeline.
|
|
|
|
|
|
|
+- `kuatia` — async `Ledger` resource and the atomic commit path.
|
|
|
|
|
|
|
|
|
|
+[0.4.0]: https://github.com/crodas/kuatia/releases/tag/v0.4.0
|
|
|
[0.3.0]: https://github.com/crodas/kuatia/releases/tag/v0.3.0
|
|
[0.3.0]: https://github.com/crodas/kuatia/releases/tag/v0.3.0
|
|
|
[0.2.0]: https://github.com/crodas/kuatia/releases/tag/v0.2.0
|
|
[0.2.0]: https://github.com/crodas/kuatia/releases/tag/v0.2.0
|
|
|
[0.1.0]: https://github.com/crodas/kuatia/releases/tag/v0.1.0
|
|
[0.1.0]: https://github.com/crodas/kuatia/releases/tag/v0.1.0
|