kamiazya/scopes

Add Konsist rule to ensure TransactionManager rollback on Either.Left

Ouverte

#182 ouverte le 2 sept. 2025

 (1 commentaire) (0 réaction) (0 personne assignée)Kotlin (3 forks)auto 404
hacktoberfest

Métriques du dépôt

Stars
 (2 étoiles)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

Context

Currently, TransactionManagerAdapter delegates blindly to the platform TransactionManager. When a transactional block returns Either.Left (indicating an error), the transaction is not automatically rolled back.

Problem

This can lead to partial commits when operations fail, violating transactional consistency.

Suggested Solution

  1. Update TransactionManagerAdapter to mark transactions for rollback when the block returns Either.Left:
override suspend fun <E, T> inTransaction(block: suspend () -> Either<E, T>): Either<E, T> =
    platformTransactionManager.inTransaction {
        val result = block()
        if (result.isLeft()) markForRollback()
        result
    }
  1. Add a Konsist test to ensure all TransactionManager implementations follow this pattern

  2. Add integration tests to verify rollback behavior

Benefits

  • Ensures transactional consistency
  • Prevents partial commits on errors
  • Makes error handling more predictable

Related

  • PR #165 (Context View feature)
  • TransactionManagementTest.kt
  • Suggested by AI review

Guide contributeur