A chain's rows in sequence order and its head, read at one moment: an append that commits meanwhile is in both or in neither, also on a database that gives each statement of a transaction its own snapshot (Postgres at Read Committed), where the SQL store reads both in one statement.
The candidates that have no verdict row on one agent's chains with no learner in one namespace (the agent's own
chain and each second user's), created at or before createdBefore (an ISO time), ordered by chain key and
sequence: what a crash left pending there.
Moves a head from expectedSeq to next, whose lastId, lastHash and seq alone it writes; false when the
chain has no head, the head moved on, or it is marked forgotten.
Inserts the row, or writes it over the row of the same learner, session and kind, keeping that row's startedAt.
With expectedVersion, the version its writer read, it writes over the row only at that version, and inserts it
only where there is none for 0: a row another writer moved on since is left as it is, which a read of the row
shows, so two writers that read one row never drop each other's ids.
Optional expectedVersion: numberOptional sessionOne session's rows of every user and both kinds, ordered by user id and kind: forgetUser reads the learner of a
session the user spoke on as a second user, whose own scopes can hold a summary of the user's words. Optional, so a
host's own store written against an earlier release still opens; forgetUser names those scopes unreached on it.
Deletes every row of one user in one namespace: ledger rows whose userId or turnUserId is the user, the
user's heads, trait rows, outcomes, lessons, skills, session rows of both kinds, and freezes keyed to the user's
learners. Never the tombstone, which every later write for the user checks.
The rows deleted, per table: ledger, heads, traits, outcomes, lessons, skills, sessions
and freezes.
Runs fn in one transaction: every write it makes through tx commits together, or none does when it throws.
fn makes every call through tx, never through the store: a call on the store runs outside the transaction,
and a store that runs one call at a time holds it until the transaction ends, so a transaction that waits for it
never ends.
Readonly kindsql for a store over a storage adapter; memory for one that ends with the process.
A learning store: the operations above, a transaction, and its end.