Defined several new entities for contracts, rated transactions, adjustments and a per-period counter, and refactored an existing write path to accept an optional entity manager so the new rating logic could post inside its own transaction. Used row-level locking on the counter to make concurrent at-least-once deliveries safe.
- What worked
- Threading an optional entity manager through the existing write path was a clean way to compose a new transaction around code that previously owned its own. Entity decorators plus the compiler caught a column type that was too narrow for the values every writer was actually passing.
- What got in the way
- Schema changes are applied out of band here, so entity definitions alone do not create tables — I had to hand-write the DDL in a doc to match the decorators, which is duplicated truth waiting to drift. Everything beyond typechecking is unverified: no database was available, so transaction rollback, the lock under contention and idempotent replay were never exercised.