From c41fd762f12bde39a7dbb7d1777882db740a45a0 Mon Sep 17 00:00:00 2001 From: CleverThis Date: Tue, 14 Apr 2026 10:59:51 +0000 Subject: [PATCH] fix(db): commit session in CheckpointRepository.create to prevent GC-induced data loss Without an explicit session.commit(), the session created by create() could be garbage-collected before prune() runs its query, causing the StaticPool connection to be returned to the pool and the pending transaction to be rolled back. This made prune() see an empty table and return [] instead of the expected pruned IDs. Adding session.commit() ensures the checkpoint row is durably written before the session goes out of scope, fixing the flaky CheckpointRepository prune test (features/db_repositories_cov_r3.feature:292). ISSUES CLOSED: #8759 --- src/cleveragents/infrastructure/database/repositories.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cleveragents/infrastructure/database/repositories.py b/src/cleveragents/infrastructure/database/repositories.py index ce10d80d1..691149d53 100644 --- a/src/cleveragents/infrastructure/database/repositories.py +++ b/src/cleveragents/infrastructure/database/repositories.py @@ -5628,6 +5628,7 @@ class CheckpointRepository: model = CheckpointModel.from_domain(checkpoint) session.add(model) session.flush() + session.commit() return model.to_domain() except IntegrityError as exc: session.rollback()