kuatia-types (value_date, transfer, envelope,
canonical), kuatia-core (posting_resolution), kuatia-storage,
kuatia-storage-sql, kuatia (ledger)A commit stamped every transfer with now_millis() and nothing else. So the
ledger knew when it recorded an entry, and never knew when that entry takes
effect.
A bank and a fintech both need both dates. An entry that the ledger books today can be valued last week, as a correction or a late settlement. It can be valued next week, as a standing order with a future date. A report for a period asks for the entries valued in that period, and not the entries that someone typed in it.
A transfer query filtered on the commit clock alone. So nothing could express a report that is correct for a period.
The obvious shape is unsafe here, and that shape is a created_at that the
caller sets. created_at is the clock that the balance cache folds its tail
against. balance reads the closest cache point, then adds every transfer that
committed after that point's watermark.
A backdated created_at would place a transfer behind a watermark that exists.
The cached balance would then leave that transfer out without a word, and
balance_exact would include it. That breaks the invariant which the projection
suite exists to assert.
created_atPros:
Cons:
value_date, outside the content addressPros:
Cons:
value_date, inside the content address (chosen)Pros:
Cons:
CANONICAL_VERSION moves up, and a
content address that something computed under an earlier version does not come
back the same.Chosen option: a separate ValueDate on Transfer and Envelope, inside the
content address.
ValueDate is a calendar day, held as days since 1970-01-01, and it is not an
instant. A value date is a business fact. An entry valued 20 November is valued
20 November wherever a reader reads it, and an instant would tie that to the
reader's timezone.
ValueDate::new rejects a date that does not exist. So
TransferBuilder::value_date stays infallible, and it does not repeat the
Result that sits mid-chain on deposit.
None means the entry takes effect on the day of its commit. The preimage tags
that case rather than leaves it out. So "no value date" and "valued on day zero"
cannot encode to the same bytes.
A reversal carries the value date of the original. So the period an entry landed in is the period of its reversal. A compensating entry with a later value would leave the first period with a report of the amount that the entry is meant to cancel. A caller that wants another date builds the envelope and commits that.
TransferQuery gains from_value_date and to_value_date. They stay apart
from from_ts and to_ts, because a report asks for one clock or the other and
never for both at once. An entry with no value date falls outside an explicit
window, rather than inside every window.
Migration 013 adds a nullable transfers.value_date column, with an index. It
is a projection of the envelope's field that a filter can use. A commit writes
it, and nothing reads it back. So the database can answer a query for a period
and load no candidate row. The book column is the same arrangement.
created_at still means the instant
at which the ledger committed the entry.CANONICAL_VERSION moves to 6, so every content address changes. That is
acceptable in a cycle that has not shipped, and which already changed them
once. The version byte exists to gate exactly this.book already makes
the same compromise, for the same reason.reference closed the
trap of a duplicate transfer, and this record extends that to a dated entry.