Use a shared session in test setup so that data flushed (but not committed) by LLMTraceRepository.save() remains visible to subsequent read operations within the same test scenario. This matches the production UnitOfWork pattern where a single session is shared across repository calls.
Also fixes ruff format violations (single quotes, string concatenation) that caused the CI lint gate to fail.
ISSUES CLOSED: #10034
Removed type: ignore[method-assign] comments from spy function assignments in test code.
Replaced direct method assignment with object.__setattr__ to properly handle method replacement without type suppression, maintaining code quality standards.
Refactor: replace session.commit() with session.flush() in LLMTraceRepository.save()
to ensure changes are persisted within the UnitOfWork without prematurely committing
the database transaction.
- Updated LLMTraceRepository.save() to call session.flush() instead of session.commit()
in src/cleveragents/infrastructure/database/llm_trace_repository.py.
- Added two new BDD scenarios to features/llm_trace.feature:
- 'Repository save() calls flush not commit' to verify save() uses flush not commit.
- 'LLM trace rolled back when UnitOfWork transaction rolls back' to verify rollback.
- Added corresponding step definitions to features/steps/llm_trace_steps.py.
ISSUES CLOSED: #10034