Optionalclock?: ClockTime source for postedAt and window math; defaults to wall-clock time.
Optionaldigest?: DigestHash service for chain links; defaults to the deterministic web-standard SHA-256.
Optionallogger?: LoggerOptionalmeter?: MeterOptional runtime ports for the engine's own telemetry (transient-retry pressure). The composition passes the runtime meter and logger; unset emits nothing.
Optionalschema?: "assert" | "skip"Open-path schema policy: 'assert' verifies the schema_meta stamp before the first operation of any kind; 'skip' (the default here) is for the staged open that already asserted on the pool. Migration is applyMysqlSchema or an external migrate job — never an open option.
OptionalvelocityWindowMs?: numberRolling window (ms) the trust store applies when summing a subject's recent spend for the velocity check. Defaults to one hour; the composition passes config.velocityWindowMs.
Storage for the store and outbox/inbox ports this backs.
Build the full MySQL-backed store on a connection pool the caller creates and owns — the
mysql2pool from createMysqlPool, or the pipeliningmariadbpool from@pwngh/economy-lab/engines/mysql-mariadb; both fill the same MysqlPool seam and run the same SQL against the same schema.transaction(work)borrows one connection, wrapsworkin START TRANSACTION ... COMMIT, and rolls back ifworkthrows. Money transactions run at READ COMMITTED (set once per pooled connection); correctness comes from explicitFOR UPDATErow locks plus aGET_LOCKnamed lock per account. A transient InnoDB abort — deadlock, lock-wait timeout, named-lock deadlock, or a stale-head chain fork — committed nothing, so the whole unit of work is re-run in a fresh connection and transaction and callers never see it as an error. Every posting appends to a per-account hash chain, and the schema's triggers enforce conservation and chain continuity on every write. On the way out of a transaction every named lock the connection acquired is released, so a returned connection carries no leftover locks. Anything outside a transaction (plain reads/writes, plus the trust and checkpoint stores) runs directly on the pool and commits on its own.The hash service defaults to the deterministic web-standard SHA-256; the clock defaults to wall-clock time. Pass a fixed clock when reproducible
postedAtvalues matter. The velocity window defaults to one hour.