package sqlite import "context" // UnitOfWork wraps a set of repository operations in a single serialized // database transaction. The transaction is injected into the context; // [Provider.GetExecutor] returns it automatically so repository code requires // no changes to participate. // // Write transactions are serialized through a mutex to prevent SQLITE_BUSY // errors. Pass the result of [New] to [NewUnitOfWork] to enable serialization. type UnitOfWork interface { // Do begins a transaction, calls fn with the enriched context, and commits // on success or rolls back on error. The original fn error is always returned // when fn fails, regardless of the rollback outcome. Do(ctx context.Context, fn func(ctx context.Context) error) error }