internal/db/tx.go holds Beginner, Kind (Plain, ReadCommitted, FirstRuns),
Begin, InTx and IsLockContention, which moves from internal/entitlements
unchanged; its callers import it from internal/db and no forwarder stays.
InTx commits on nil, rolls back on an error or a panic and raises the
panic again, and returns the callback's, begin's and commit's errors
unwrapped.
internal/entitlements/tx.go builds BeginMaterializing and BeginRuleChange on
db.Begin with the Materializing and RuleChange kinds. rendezvous issues the
same two statements with the same wraps ("set lock_timeout: %w", "take
materialization rendezvous: %w"). Both openers keep their signatures; a
non-nil isolation other than READ COMMITTED is still refused. beginRecordTx
opens through db.Begin with db.ReadCommitted.
db.InTx now carries withWorkspaceTx and acknowledgeRequest
(fedwiki/web), FinishLifecycleRequestsActivity (fedwiki/workflows),
createProductWithSet (the product is assigned only on success, so an error
still returns billing.Product{}), recordObligationFailure (Materializing)
and addSeedRule (RuleChange). Statements and their order are unchanged.
Begin and commit errors, before and after: withWorkspaceTx,
acknowledgeRequest, FinishLifecycleRequestsActivity and createProductWithSet
return both as the driver gave them; recordObligationFailure and addSeedRule
return the begin error as the driver gave it for the plain begin, the
rendezvous wraps above for a failed first statement, and the commit error
as the driver gave it. Every path that returned nil committed before and
commits now. A touched function's db variable is renamed database where the
package is used in it.
Tests: TestInTx and its seven subtests are new (nil commits; an error rolls
back and is returned as it is; a panic rolls back and is raised again; a
failing first statement rolls back and skips the callback; first runs before
the callback; a failed begin is returned as it is; Plain reports the session default and
ReadCommitted reports READ COMMITTED, with the session default changed). Four
breaks, each caught: InTx commits on an error, FirstRuns skips first,
ReadCommitted carries no isolation, the rendezvous dropped from Materializing
(TestMaterializingTransactionHoldsRendezvous, old and new). No test name or
result changes.