Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(call): ai summary (#2848)
Will Hutchinson20afb21a756a
diff --git a/infra/stacks/cloud-storage-service/Pulumi.dev.yaml b/infra/stacks/cloud-storage-service/Pulumi.dev.yamlindex 4d10700e0d..5a0f1d792a 100644--- a/infra/stacks/cloud-storage-service/Pulumi.dev.yaml+++ b/infra/stacks/cloud-storage-service/Pulumi.dev.yaml@@ -27,3 +27,4 @@ config:cloud-storage-service:cal_event_type_content_names_key: cal-event-metadata-devcloud-storage-service:meta_pixel_id: "639142540393286"cloud-storage-service:meta_access_token: meta-access-token+ cloud-storage-service:anthropic_api_key: anthropic-api-key-devdiff --git a/infra/stacks/cloud-storage-service/Pulumi.prod.yaml b/infra/stacks/cloud-storage-service/Pulumi.prod.yamlindex e8437b3329..d0e3681cec 100644--- a/infra/stacks/cloud-storage-service/Pulumi.prod.yaml+++ b/infra/stacks/cloud-storage-service/Pulumi.prod.yaml@@ -27,3 +27,4 @@ config:cloud-storage-service:cal_event_type_content_names_key: cal-event-metadata-prodcloud-storage-service:meta_pixel_id: "639142540393286"cloud-storage-service:meta_access_token: meta-access-token+ cloud-storage-service:anthropic_api_key: anthropic-api-keydiff --git a/infra/stacks/cloud-storage-service/index.ts b/infra/stacks/cloud-storage-service/index.tsindex 0401a38c3a..f445ce9749 100644--- a/infra/stacks/cloud-storage-service/index.ts+++ b/infra/stacks/cloud-storage-service/index.ts@@ -281,6 +281,14 @@ const INTERNAL_CALL_SECRET = aws.secretsmanager.getSecretVersionOutput({ secretId: config.require('call_internal_secret') }).apply((secret) => secret.secretString);+const ANTHROPIC_API_KEY = aws.secretsmanager+ .getSecretVersionOutput({+ secretId: config.get('anthropic_api_key') ?? '',+ })+ .apply((secret) => {+ return secret.secretString;+ });+// Cal.com webhook — HMAC secret, resolved at runtime via Secrets Manager.const CAL_WEBHOOK_SECRET_KEY = config.require('cal_webhook_secret_key');const calWebhookSecretKeyArn: pulumi.Output<string> = aws.secretsmanager@@ -390,6 +398,10 @@ const cloudStorageService = new CloudStorageService(name: 'INTERNAL_CALL_SECRET',value: pulumi.interpolate`${INTERNAL_CALL_SECRET}`,},+ {+ name: 'ANTHROPIC_API_KEY',+ value: pulumi.interpolate`${ANTHROPIC_API_KEY}`,+ },{name: 'LIVEKIT_SERVER_URL',value: pulumi.interpolate`${LIVEKIT_SERVER_URL}`,diff --git a/rust/cloud-storage/call/.sqlx/query-4264fcdaec0d80ff28c8ff6e2443f685b084283f4fb1cc683330b7c7875ca312.json b/rust/cloud-storage/call/.sqlx/query-4264fcdaec0d80ff28c8ff6e2443f685b084283f4fb1cc683330b7c7875ca312.jsonnew file mode 100644index 0000000000..7b86d66efe--- /dev/null+++ b/rust/cloud-storage/call/.sqlx/query-4264fcdaec0d80ff28c8ff6e2443f685b084283f4fb1cc683330b7c7875ca312.json@@ -0,0 +1,15 @@+{+ "db_name": "PostgreSQL",+ "query": "\n UPDATE call_records SET summary = $2 WHERE id = $1\n ",+ "describe": {+ "columns": [],+ "parameters": {+ "Left": [+ "Uuid",+ "Text"+ ]+ },+ "nullable": []+ },+ "hash": "4264fcdaec0d80ff28c8ff6e2443f685b084283f4fb1cc683330b7c7875ca312"+}diff --git a/rust/cloud-storage/call/Cargo.toml b/rust/cloud-storage/call/Cargo.tomlindex 4ff795cd87..ded953beb4 100644--- a/rust/cloud-storage/call/Cargo.toml+++ b/rust/cloud-storage/call/Cargo.toml@@ -16,6 +16,7 @@ inbound = ["ports",]outbound = [+ "dep:ai","dep:aws-sdk-s3","dep:entity_access_db_utils","dep:livekit-api",diff --git a/rust/cloud-storage/call/src/domain/ports.rs b/rust/cloud-storage/call/src/domain/ports.rsindex 08fc08f857..38ca76845a 100644--- a/rust/cloud-storage/call/src/domain/ports.rs+++ b/rust/cloud-storage/call/src/domain/ports.rs@@ -15,9 +15,9 @@ use crate::domain::models::EditCallRecordRequest;use super::models::{AddParticipantError, Call, CallActiveResponse, CallError, CallParticipant, CallRecord,- CallRecordPreview, CallTokenResponse, CallWebhookEvent, EgressS3Config,- GetBatchCallRecordPreviewRequest, GetBatchCallRecordPreviewResponse, GetCallRecordsRequest,- LeaveCallResponse, TranscriptSegmentRequest,+ CallRecordPreview, CallRecordTranscriptSegment, CallTokenResponse, CallWebhookEvent,+ EgressS3Config, GetBatchCallRecordPreviewRequest, GetBatchCallRecordPreviewResponse,+ GetCallRecordsRequest, LeaveCallResponse, TranscriptSegmentRequest,};/// Repository port for persisting call state to the database.@@ -218,6 +218,17 @@ pub trait CallRepository: Send + Sync + 'static {call_record_id: &Uuid,request: &EditCallRecordRequest,) -> impl Future<Output = Result<(), Self::Err>> + Send;++ /// Persist the AI-generated summary text on the archived call record.+ ///+ /// Tolerates unknown `call_id` (no row matches): the summarization flow+ /// can race with the record being deleted, so this is an idempotent no-op+ /// when the target row is gone.+ fn insert_call_summary(+ &self,+ call_id: &Uuid,+ summary: &str,+ ) -> impl Future<Output = Result<(), Self::Err>> + Send;}/// Storage port for generating presigned recording URLs.@@ -259,6 +270,28 @@ impl<T: RecordingStorage> RecordingStorage for Option<T> {}}+/// Summarizer port for generating an AI summary of a finished call.+///+/// Implementations are expected to produce a natural-language summary of+/// the call given its finalized transcript. The returned [`String`] is the+/// summary text that will be persisted on the corresponding `call_records`+/// row (see the `insert_call_summary` repository operation).+#[cfg_attr(test, mockall::automock(type Err = anyhow::Error;))]+pub trait CallSummarizer: Send + Sync + 'static {+ /// The error type returned by summarization operations.+ type Err: Into<anyhow::Error> + Send + Debug;++ /// Produce a summary for the call identified by `call_id` using the+ /// supplied finalized `transcript` segments. The segments are expected+ /// to be ordered by `sequence_num` ascending (matching what is stored+ /// in a [`CallRecord`]).+ fn summarize_call(+ &self,+ call_id: &Uuid,+ transcript: Vec<CallRecordTranscriptSegment>,+ ) -> impl Future<Output = Result<String, Self::Err>> + Send;+}+/// RTC client port for interacting with the real-time communication service (e.g., LiveKit).#[cfg_attr(test, mockall::automock)]pub trait CallRtcClient: Send + Sync + 'static {@@ -396,6 +429,16 @@ pub trait CallService: Send + Sync + 'static {request: GetBatchCallRecordPreviewRequest,user_id: MacroUserIdStr<'a>,) -> impl Future<Output = Result<GetBatchCallRecordPreviewResponse, CallError>> + Send;++ /// Generate and persist an AI summary for a finished call.+ ///+ /// Loads the [`CallRecord`] for `call_id`, passes its finalized transcript+ /// to the configured [`CallSummarizer`], and persists the resulting+ /// summary via [`CallRepository::insert_call_summary`]. If no summarizer+ /// is configured, this is a no-op. Missing records (e.g. deleted mid-flow)+ /// and empty transcripts are also no-ops — no AI call is made in those+ /// cases.+ fn summarize_call(&self, call_id: &Uuid) -> impl Future<Output = Result<(), CallError>> + Send;}/// Lightweight read-only port for querying call records in Soup.diff --git a/rust/cloud-storage/call/src/domain/service.rs b/rust/cloud-storage/call/src/domain/service.rsindex e0582b313d..daa5e53d58 100644--- a/rust/cloud-storage/call/src/domain/service.rs+++ b/rust/cloud-storage/call/src/domain/service.rs@@ -24,12 +24,14 @@ use uuid::Uuid;use crate::domain::models::EditCallRecordRequest;use super::models::{- AddParticipantError, CallActiveResponse, CallError, CallRecord, CallTokenResponse,- EgressS3Config, GetBatchCallRecordPreviewRequest, GetBatchCallRecordPreviewResponse,- GetCallRecordsRequest, LeaveCallResponse, TranscriptSegmentRequest,+ AddParticipantError, CallActiveResponse, CallError, CallRecord, CallRecordTranscriptSegment,+ CallTokenResponse, EgressS3Config, GetBatchCallRecordPreviewRequest,+ GetBatchCallRecordPreviewResponse, GetCallRecordsRequest, LeaveCallResponse,+ TranscriptSegmentRequest,};use super::ports::{- CallRecordQueryService, CallRepository, CallRtcClient, CallService, RecordingStorage,+ CallRecordQueryService, CallRepository, CallRtcClient, CallService, CallSummarizer,+ RecordingStorage,};/// The concrete call service implementation.@@ -40,6 +42,7 @@ pub struct CallServiceImpl<E: EntityAccessService,N: NotificationIngress,S: RecordingStorage,+ Sm: CallSummarizer = NoopCallSummarizer,> {repo: R,rtc_client: C,@@ -50,6 +53,7 @@ pub struct CallServiceImpl<server_url: String,egress_s3_config: Option<EgressS3Config>,internal_call_secret: Option<String>,+ summarizer: Option<Sm>,}impl<@@ -59,7 +63,8 @@ impl<E: EntityAccessService,N: NotificationIngress,S: RecordingStorage,-> CallServiceImpl<R, C, Cn, E, N, S>+ Sm: CallSummarizer,+> CallServiceImpl<R, C, Cn, E, N, S, Sm>{/// Create a new call service.pub fn new(@@ -81,6 +86,7 @@ impl<server_url: server_url.into(),egress_s3_config: None,internal_call_secret: None,+ summarizer: None,}}@@ -96,6 +102,13 @@ impl<self}+ /// Enable AI call summarization with the given [`CallSummarizer`]+ /// implementation. When unset, calls are never summarized.+ pub fn with_summarizer(mut self, summarizer: Sm) -> Self {+ self.summarizer = Some(summarizer);+ self+ }+/// Send a call event to all channel members (best-effort).async fn send_call_event(&self,@@ -224,13 +237,14 @@ impl NotificationExtIos for CallStartedNotification {}impl<- R: CallRepository,+ R: CallRepository + Clone,C: CallRtcClient,Cn: ConnectionService,E: EntityAccessService,N: NotificationIngress,S: RecordingStorage,-> CallService for CallServiceImpl<R, C, Cn, E, N, S>+ Sm: CallSummarizer + Clone,+> CallService for CallServiceImpl<R, C, Cn, E, N, S, Sm>{fn validate_internal_call(&self, token: &str) -> bool {self.internal_call_secret@@ -512,6 +526,10 @@ impl<.await.map_err(|e| CallError::Internal(e.into()))?;+ // Fire-and-forget summarization now that the+ // `call_records` row is persisted.+ self.spawn_summarize_call(call.id);+self.send_call_event(&channel_id,"call_ended",@@ -613,6 +631,10 @@ impl<.await.map_err(|e| CallError::Internal(e.into()))?;+ // Fire-and-forget summarization now that the+ // `call_records` row is persisted.+ self.spawn_summarize_call(call.id);+// Stop egress explicitly before deleting the room. DeleteRoom// is expected to cascade-stop egress, but a failed or slow// DeleteRoom can leave egress running and billing. Doing it@@ -873,6 +895,101 @@ impl<.map_err(|e| CallError::Internal(e.into()))?;Ok(GetBatchCallRecordPreviewResponse { previews })}++ #[tracing::instrument(err, skip(self))]+ async fn summarize_call(&self, call_id: &Uuid) -> Result<(), CallError> {+ // No summarizer configured — feature is off, silently succeed.+ let Some(summarizer) = self.summarizer.as_ref() else {+ return Ok(());+ };++ // Load the finalized call record. May race with deletion, in which+ // case there's nothing to summarize — log and move on.+ let Some(record) = self+ .repo+ .get_call_record_by_call_id(call_id)+ .await+ .inspect_err(|e| tracing::error!(error=?e, %call_id, "failed to load call record for summarization"))+ .map_err(|e| CallError::Internal(e.into()))?+ else {+ tracing::warn!(%call_id, "call record not found for summarization; skipping");+ return Ok(());+ };++ if record.transcript.is_empty() {+ tracing::info!(%call_id, "call has empty transcript; skipping summarization");+ return Ok(());+ }++ let summary = summarizer+ .summarize_call(call_id, record.transcript)+ .await+ .inspect_err(|e| tracing::error!(error=?e, %call_id, "call summarizer failed"))+ .map_err(|e| CallError::Internal(e.into()))?;++ self.repo+ .insert_call_summary(call_id, &summary)+ .await+ .inspect_err(|e| tracing::error!(error=?e, %call_id, "failed to persist call summary"))+ .map_err(|e| CallError::Internal(e.into()))?;++ Ok(())+ }+}++impl<+ R: CallRepository + Clone,+ C: CallRtcClient,+ Cn: ConnectionService,+ E: EntityAccessService,+ N: NotificationIngress,+ S: RecordingStorage,+ Sm: CallSummarizer + Clone,+> CallServiceImpl<R, C, Cn, E, N, S, Sm>+{+ /// Fire-and-forget spawn of [`CallService::summarize_call`] for `call_id`.+ ///+ /// Called after the `call_records` row is persisted so that summarization+ /// can run off the request path without blocking call completion. The+ /// spawned task owns cloned handles to `repo` and `summarizer`; errors+ /// are logged, never propagated. When no summarizer is configured this is+ /// a no-op and no task is spawned.+ fn spawn_summarize_call(&self, call_id: Uuid) {+ let Some(summarizer) = self.summarizer.clone() else {+ return;+ };+ let repo = self.repo.clone();+ tokio::spawn(async move {+ let record = match repo.get_call_record_by_call_id(&call_id).await {+ Ok(Some(record)) => record,+ Ok(None) => {+ tracing::warn!(%call_id, "call record not found for summarization; skipping");+ return;+ }+ Err(e) => {+ tracing::error!(error=?e, %call_id, "failed to load call record for summarization");+ return;+ }+ };++ if record.transcript.is_empty() {+ tracing::info!(%call_id, "call has empty transcript; skipping summarization");+ return;+ }++ let summary = match summarizer.summarize_call(&call_id, record.transcript).await {+ Ok(summary) => summary,+ Err(e) => {+ tracing::error!(error=?e, %call_id, "failed to summarize call on completion");+ return;+ }+ };++ if let Err(e) = repo.insert_call_summary(&call_id, &summary).await {+ tracing::error!(error=?e, %call_id, "failed to persist call summary");+ }+ });+ }}/// Extract the recording key from a full S3 URL.@@ -887,6 +1004,34 @@ fn extract_recording_key(file_url: &str) -> &str {.unwrap_or(file_url)}+/// Zero-sized placeholder implementation of [`CallSummarizer`].+///+/// [`CallServiceImpl`]'s summarizer generic defaults to this type so callers+/// that do not wire an AI summarizer can simply leave the `summarizer` field+/// as `None`. The implementation itself is never executed — [`CallServiceImpl`]+/// only invokes `summarize_call` when `summarizer.is_some()`, and this+/// placeholder is exclusively used as the type parameter when the field is+/// `None`. If it is ever called, that is a programming error.+#[derive(Debug, Default, Clone, Copy)]+pub struct NoopCallSummarizer;++impl CallSummarizer for NoopCallSummarizer {+ type Err = anyhow::Error;++ async fn summarize_call(+ &self,+ _call_id: &Uuid,+ _transcript: Vec<CallRecordTranscriptSegment>,+ ) -> Result<String, Self::Err> {+ // Type-placeholder only — [`CallServiceImpl`] must never invoke this+ // when `summarizer` is `None`, and [`NoopCallSummarizer`] is never a+ // `Some(_)` value in practice.+ unreachable!(+ "NoopCallSummarizer::summarize_call invoked; it exists only as a type placeholder when the optional summarizer is None"+ )+ }+}+/// Lightweight implementation of [`CallRecordQueryService`] for read-only/// call record queries. Unlike [`CallServiceImpl`], this only requires a/// repository — no RTC client, notifications, or entity access.diff --git a/rust/cloud-storage/call/src/outbound/ai_call_summarizer.rs b/rust/cloud-storage/call/src/outbound/ai_call_summarizer.rsnew file mode 100644index 0000000000..6f1933f075--- /dev/null+++ b/rust/cloud-storage/call/src/outbound/ai_call_summarizer.rs@@ -0,0 +1,106 @@+//! AI-backed implementation of [`CallSummarizer`](crate::domain::ports::CallSummarizer).+//!+//! Wraps the [`ai`] crate's `get_chat_completion` entry point to generate a+//! natural-language summary of a finished call from its finalized transcript.+//! No external client handle is required — [`ai::chat_completion::get_chat_completion`]+//! internally constructs its own provider client (see the `memory` crate's+//! `judge_memory` for the same pattern this mirrors).++use std::fmt::Write as _;++use ai::chat_completion::get_chat_completion;+use ai::types::{Model, RequestBuilder};+use uuid::Uuid;++use crate::domain::models::CallRecordTranscriptSegment;+use crate::domain::ports::CallSummarizer;++/// Default model used when summarizing a call transcript.+const SUMMARIZATION_MODEL: Model = Model::Claude46Sonnet;++/// System prompt framing the LLM's task: produce a concise, factual call summary.+const SUMMARIZATION_SYSTEM_PROMPT: &str = "\+You are a meeting-notes assistant. Given the transcript of a voice or video \+call, write a concise, factual summary that captures:+- The main topics discussed.+- Key decisions that were made.+- Action items or follow-ups, including who owns them when stated.+- Any notable context that would help someone who missed the call catch up.++Rules:+- Write in plain prose, using short paragraphs or bullet points where \+ appropriate. No markdown headings.+- Do not speculate or invent content that is not in the transcript.+- If the transcript is empty or uninformative, say so briefly rather than \+ fabricating content.+- Respond with only the summary text — no preamble, no sign-off.";++/// AI-powered [`CallSummarizer`] that delegates to+/// [`ai::chat_completion::get_chat_completion`].+///+/// Stateless on purpose: the underlying `ai` crate builds its provider client+/// per request, so this adapter does not need to cache one. Construct once at+/// service startup and share via the [`CallSummarizer`] trait.+#[derive(Debug, Default, Clone, Copy)]+pub struct AiCallSummarizer;++impl AiCallSummarizer {+ /// Create a new [`AiCallSummarizer`].+ pub fn new() -> Self {+ Self+ }+}++impl CallSummarizer for AiCallSummarizer {+ type Err = anyhow::Error;++ #[tracing::instrument(skip(self, transcript), fields(segment_count = transcript.len()), err)]+ async fn summarize_call(+ &self,+ call_id: &Uuid,+ transcript: Vec<CallRecordTranscriptSegment>,+ ) -> Result<String, Self::Err> {+ let user_message = format_transcript_prompt(call_id, &transcript);++ let request = RequestBuilder::new()+ .model(SUMMARIZATION_MODEL)+ .system_prompt(SUMMARIZATION_SYSTEM_PROMPT)+ .user_message(user_message)+ .build();++ get_chat_completion(request)+ .await+ .map_err(|e| anyhow::anyhow!(e))+ .inspect_err(|e| {+ tracing::error!(error = ?e, %call_id, "ai call summarization failed");+ })+ }+}++/// Render the transcript as a chronological, speaker-labeled block suitable+/// for inclusion in an LLM user message. Segments are expected to already be+/// ordered by `sequence_num` ascending; we preserve that order verbatim.+fn format_transcript_prompt(call_id: &Uuid, transcript: &[CallRecordTranscriptSegment]) -> String {+ if transcript.is_empty() {+ return format!(+ "Call {call_id} has no transcript segments. Produce a one-line \+ summary noting that the call has no transcribed content."+ );+ }++ // Rough pre-allocation: each segment typically renders on one line.+ let mut buf = String::with_capacity(transcript.len() * 64);+ let _ = writeln!(+ buf,+ "Transcript for call {call_id} (one line per segment, format: `speaker: text`):\n"+ );+ for segment in transcript {+ // `write!` into `String` never fails; discard the `fmt::Result`.+ let _ = writeln!(buf, "{}: {}", segment.speaker_id, segment.content);+ }+ let _ = write!(+ buf,+ "\nWrite a concise summary of this call following the rules in the system prompt."+ );+ buf+}diff --git a/rust/cloud-storage/call/src/outbound/mod.rs b/rust/cloud-storage/call/src/outbound/mod.rsindex bc85d1b053..c973bb2cdc 100644--- a/rust/cloud-storage/call/src/outbound/mod.rs+++ b/rust/cloud-storage/call/src/outbound/mod.rs@@ -1,3 +1,5 @@+/// AI-backed summarizer implementing [`CallSummarizer`](crate::domain::ports::CallSummarizer).+pub mod ai_call_summarizer;/// LiveKit RTC client adapter implementing [`CallRtcClient`](crate::domain::ports::CallRtcClient).pub mod livekit_rtc_client;/// Postgres-backed repository implementing [`CallRepository`](crate::domain::ports::CallRepository).diff --git a/rust/cloud-storage/call/src/outbound/pg_call_repo.rs b/rust/cloud-storage/call/src/outbound/pg_call_repo.rsindex 6491cd1883..c79600f932 100644--- a/rust/cloud-storage/call/src/outbound/pg_call_repo.rs+++ b/rust/cloud-storage/call/src/outbound/pg_call_repo.rs@@ -81,6 +81,7 @@ fn find_attended(expr: &Expr<CallLiteral>) -> Option<bool> {}/// Postgres implementation of [`CallRepository`].+#[derive(Clone)]pub struct PgCallRepo {pool: PgPool,}@@ -1311,4 +1312,19 @@ impl CallRepository for PgCallRepo {tx.commit().await?;Ok(())}++ #[tracing::instrument(skip(self, summary), err)]+ async fn insert_call_summary(&self, call_id: &Uuid, summary: &str) -> Result<(), Self::Err> {+ // Tolerate missing rows: summarization can race with record deletion.+ sqlx::query!(+ r#"+ UPDATE call_records SET summary = $2 WHERE id = $1+ "#,+ call_id,+ summary,+ )+ .execute(&self.pool)+ .await?;+ Ok(())+ }}diff --git a/rust/cloud-storage/call/src/outbound/pg_call_repo/test.rs b/rust/cloud-storage/call/src/outbound/pg_call_repo/test.rsindex cb3685d3cc..0b7056a511 100644--- a/rust/cloud-storage/call/src/outbound/pg_call_repo/test.rs+++ b/rust/cloud-storage/call/src/outbound/pg_call_repo/test.rs@@ -1703,3 +1703,48 @@ async fn patch_call_record_share_with_team_true_noop_when_creator_has_no_team(Ok(())}++// -- insert_call_summary ------------------------------------------------------++#[sqlx::test(+ fixtures(path = "../../../fixtures", scripts("call_repo")),+ migrator = "MACRO_DB_MIGRATIONS"+)]+async fn insert_call_summary_sets_summary_text(pool: Pool<Postgres>) -> anyhow::Result<()> {+ let repo = repo(pool.clone());+ let summary = "A short synopsis of the call.";++ repo.insert_call_summary(&CALL_ARCHIVED, summary).await?;++ let stored = sqlx::query_scalar!(+ r#"SELECT summary FROM call_records WHERE id = $1"#,+ CALL_ARCHIVED,+ )+ .fetch_one(&pool)+ .await?;++ assert_eq!(stored.as_deref(), Some(summary));+ Ok(())+}++#[sqlx::test(+ fixtures(path = "../../../fixtures", scripts("call_repo")),+ migrator = "MACRO_DB_MIGRATIONS"+)]+async fn insert_call_summary_noop_for_unknown_id(pool: Pool<Postgres>) -> anyhow::Result<()> {+ let repo = repo(pool.clone());++ // Unknown id should be an idempotent no-op (not an error).+ repo.insert_call_summary(&Uuid::now_v7(), "irrelevant")+ .await?;++ // The archived fixture row must remain untouched.+ let stored = sqlx::query_scalar!(+ r#"SELECT summary FROM call_records WHERE id = $1"#,+ CALL_ARCHIVED,+ )+ .fetch_one(&pool)+ .await?;+ assert!(stored.is_none());+ Ok(())+}diff --git a/rust/cloud-storage/document_storage_service/src/api/context.rs b/rust/cloud-storage/document_storage_service/src/api/context.rsindex 764905df02..08b4e91390 100644--- a/rust/cloud-storage/document_storage_service/src/api/context.rs+++ b/rust/cloud-storage/document_storage_service/src/api/context.rs@@ -195,6 +195,7 @@ pub(crate) type DssCallService = CallServiceImpl<EntityAccessService,NotificationIngressType,Option<call::outbound::s3_recording_storage::S3RecordingStorage>,+ call::outbound::ai_call_summarizer::AiCallSummarizer,>;/// Type alias for the call router state.diff --git a/rust/cloud-storage/document_storage_service/src/main.rs b/rust/cloud-storage/document_storage_service/src/main.rsindex f42a4180c0..94b6674037 100644--- a/rust/cloud-storage/document_storage_service/src/main.rs+++ b/rust/cloud-storage/document_storage_service/src/main.rs@@ -18,7 +18,10 @@ use cal::{use call::{domain::service::CallServiceImpl,inbound::axum_router::{CallRouterState, InternalCallRouterState, WebhookRouterState},- outbound::{livekit_rtc_client::LivekitRtcClient, pg_call_repo::PgCallRepo},+ outbound::{+ ai_call_summarizer::AiCallSummarizer, livekit_rtc_client::LivekitRtcClient,+ pg_call_repo::PgCallRepo,+ },};use channels::{domain::service::ChannelMessagesServiceImpl, inbound::axum_router::ChannelsRouterState,@@ -436,7 +439,7 @@ async fn main() -> anyhow::Result<()> {),None => None,};- let mut call_service_builder = CallServiceImpl::new(+ let mut call_service_builder = CallServiceImpl::<_, _, _, _, _, _, AiCallSummarizer>::new(call_repo,livekit_rtc_client,call_connection_service,@@ -444,7 +447,8 @@ async fn main() -> anyhow::Result<()> {(*notification_ingress_service).clone(),recording_storage,config.vars.livekit_server_url.as_ref(),- );+ )+ .with_summarizer(AiCallSummarizer::new());if let Some(secret) = internal_call_secret {call_service_builder = call_service_builder.with_internal_call_secret(secret);}diff --git a/rust/cloud-storage/macro_db_client/migrations/20260424120100_call_record_summary.sql b/rust/cloud-storage/macro_db_client/migrations/20260424120100_call_record_summary.sqlnew file mode 100644index 0000000000..d37d580346--- /dev/null+++ b/rust/cloud-storage/macro_db_client/migrations/20260424120100_call_record_summary.sql@@ -0,0 +1 @@+ALTER TABLE call_records ADD COLUMN summary TEXT;