Class: Assistant::TechnicalSupport::CaseReplayPersistence
- Inherits:
-
Object
- Object
- Assistant::TechnicalSupport::CaseReplayPersistence
- Includes:
- Service
- Defined in:
- app/services/assistant/technical_support/case_replay_persistence.rb
Overview
Persists one completed holdout replay on its existing Sunny conversation.
Article, Publication, catalog, and Brain content remain in their established
systems of record; this snapshot stores stable references and fingerprints so
an auditor can prove exactly which versions informed the replay.
Defined Under Namespace
Classes: PersistenceError, Result
Constant Summary collapse
- SCHEMA_VERSION =
1
Instance Method Summary collapse
-
#call ⇒ Result
Stores the immutable replay contract exactly once.
Methods included from Service
#attributes_used, #build_result, call, #logger
Methods included from Service::Initializer
Instance Method Details
#call ⇒ Result
Stores the immutable replay contract exactly once.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/services/assistant/technical_support/case_replay_persistence.rb', line 31 def call conversation.with_lock do validate_conversation! validate_result! raise PersistenceError, 'This replay conversation already has a persisted result.' if conversation.technical_support_replay_result.present? conversation.update!(technical_support_replay_result: payload) end Result.new(conversation_id: conversation.id, schema_version: SCHEMA_VERSION) rescue ActiveRecord::RecordNotFound raise PersistenceError, "Replay conversation #{conversation_id} was not found." rescue ActiveRecord::RecordInvalid => e raise PersistenceError, "The replay result could not be saved: #{e.record.errors..to_sentence}" end |