kuatia-types (value_date, transfer, envelope,
canonical), kuatia-core (posting_resolution), kuatia-storage,
kuatia-storage-sql, kuatia (ledger)Every transfer was stamped with now_millis() at commit and nothing else, so the ledger knew when an entry was recorded and never when it takes effect. Banks and fintechs need both: an entry booked today can be valued last week (a correction, a late settlement) or next week (a future-dated standing order), and a period report asks for the entries valued in that period, not the ones typed in it. Transfer queries filtered only on the commit clock, so period-correct reporting was not expressible.
The obvious shape, letting a caller set created_at, is unsafe here. created_at is the clock the balance cache folds its tail against: balance reads the closest cache point and adds every transfer committed after its watermark. A backdated created_at would place a transfer behind an existing watermark, so the cached balance would silently omit it while balance_exact included it, breaking the invariant 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 is bumped and content addresses computed under an earlier version do not reproduce.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, not an instant, because a value date is a business fact: an entry valued 20 November is valued 20 November wherever it is read, and an instant would make that depend on a reader's timezone. ValueDate::new rejects a date that does not exist, so TransferBuilder::value_date stays infallible and does not repeat the mid-chain Result that deposit has.
None means the entry takes effect the day it was committed, and is tagged in the preimage rather than omitted, so "no value date" and "valued on day zero" cannot encode identically.
A reversal carries the original's value date, so the period an entry landed in is the period it is undone in. A compensating entry valued later would leave the first period still reporting the amount it is meant to cancel. A caller who wants it dated otherwise builds the envelope and commits that.
TransferQuery gains from_value_date and to_value_date, kept apart from from_ts and to_ts because a report asks for one clock or the other, never both at once. An entry with no value date falls outside an explicit window rather than inside every one.
Migration 013 adds a nullable transfers.value_date column with an index. It is a filterable projection of the envelope's field, written at commit and never read back, so the database can answer a period query without loading every candidate row. The book column is the same arrangement.
created_at still means the instant the ledger committed the entry.CANONICAL_VERSION moves to 6, so every content address changes. Acceptable in an unreleased cycle that has already changed them once, and the version byte exists to gate exactly this.book already makes for the same reason.