Summary
TraceRepository.add_event() persists events but never updates SessionModel.errors when the event type is EventType.ERROR. As a result, get_session() always returns errors=0 even after error events have been added.
Reproduction
repo = TraceRepository(db_session, tenant_id="local")
session = Session(id="s1", ...)
await repo.create_session(session)
await repo.add_event(TraceEvent(session_id="s1", event_type=EventType.ERROR, ...))
await repo.add_event(TraceEvent(session_id="s1", event_type=EventType.ERROR, ...))
fetched = await repo.get_session("s1")
assert fetched.errors == 2 # FAILS — always 0
Expected behaviour
session.errors reflects the count of EventType.ERROR events in the session. Adding an error event should atomically increment the counter.
Current behaviour
session.errors stays at 0 unless explicitly set via update_session(session_id, errors=N).
Affected files
storage/repositories/event_repo.py — add_event / add_events_batch
storage/repository.py — facade add_event / add_events_batch
Tracked by
Reproduction test: tests/test_issue_seed_data_quality.py::test_failure_count_populated_for_sessions_with_errors (currently xfail).
Summary
TraceRepository.add_event()persists events but never updatesSessionModel.errorswhen the event type isEventType.ERROR. As a result,get_session()always returnserrors=0even after error events have been added.Reproduction
Expected behaviour
session.errorsreflects the count ofEventType.ERRORevents in the session. Adding an error event should atomically increment the counter.Current behaviour
session.errorsstays at 0 unless explicitly set viaupdate_session(session_id, errors=N).Affected files
storage/repositories/event_repo.py—add_event/add_events_batchstorage/repository.py— facadeadd_event/add_events_batchTracked by
Reproduction test:
tests/test_issue_seed_data_quality.py::test_failure_count_populated_for_sessions_with_errors(currentlyxfail).