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
fix(call): refresh Soup when a Granola meeting is imported (#8458)
Eric Hayes7009acb2b84a
diff --git a/Cargo.lock b/Cargo.lockindex 8b4f2e2934..217ad8d2bf 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -18552,6 +18552,7 @@ version = "0.1.0"dependencies = ["agent_session","broadcast",+ "call","channels","chat","chrono",diff --git a/crates/call/src/domain/activity.rs b/crates/call/src/domain/activity.rsindex dea2d404b2..ef9d030ac4 100644--- a/crates/call/src/domain/activity.rs+++ b/crates/call/src/domain/activity.rs@@ -130,10 +130,11 @@ impl ActivitySource for CallTopicEvent {CallTopicEvent::RecordDeleted(m) => {Ingest::Purge(vec![(EntityType::Call, m.call_id.to_string())])}- // Archival/processing pipeline, not user activity.+ // Archival/processing pipeline and integration sync, not user activity.CallTopicEvent::RecordUpdated(_)| CallTopicEvent::RecordSummarized(_)- | CallTopicEvent::RecordingReady(_) => Ingest::Ignore,+ | CallTopicEvent::RecordingReady(_)+ | CallTopicEvent::RecordImported(_) => Ingest::Ignore,}}}diff --git a/crates/call/src/domain/events.rs b/crates/call/src/domain/events.rsindex 12982d0eeb..f9004abc35 100644--- a/crates/call/src/domain/events.rs+++ b/crates/call/src/domain/events.rs@@ -112,6 +112,15 @@ pub struct CallRecordingReadyMetadata {pub channel_id: Option<Uuid>,}+/// Metadata for [`CallTopicEvent::RecordImported`].+#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]+pub struct CallRecordImportedMetadata {+ /// Identifier of the created or refreshed call record.+ pub call_id: Uuid,+ /// Connected Macro user who owns the imported record.+ pub owner: MacroUserIdStr<'static>,+}+/// Lifecycle and recording events published to [`MacroCallsTopic`].#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(tag = "event_type", content = "metadata")]@@ -134,6 +143,9 @@ pub enum CallTopicEvent {/// A call record's recording became available.#[serde(rename = "call.recording_ready")]RecordingReady(CallRecordingReadyMetadata),+ /// An integration created or refreshed a call record.+ #[serde(rename = "call.record_imported")]+ RecordImported(CallRecordImportedMetadata),}impl TopicEvent for CallTopicEvent {@@ -185,6 +197,12 @@ impl CallMacroEvent {Self::new(key, CallTopicEvent::RecordingReady(metadata))}+ /// Build a record-imported event keyed by the call id.+ pub fn record_imported(metadata: CallRecordImportedMetadata) -> Self {+ let key = metadata.call_id.to_string();+ Self::new(key, CallTopicEvent::RecordImported(metadata))+ }+fn new(key: String, event: CallTopicEvent) -> Self {Self::with_event(key, Event::new(event))}diff --git a/crates/call/src/domain/events/test.rs b/crates/call/src/domain/events/test.rsindex cdaf2ecc18..906465b059 100644--- a/crates/call/src/domain/events/test.rs+++ b/crates/call/src/domain/events/test.rs@@ -140,6 +140,19 @@ fn topic_events() -> Vec<(CallTopicEvent, Value)> {},}),),+ (+ CallTopicEvent::RecordImported(CallRecordImportedMetadata {+ call_id: uuid(CALL_ID),+ owner: user_id("macro|[email protected]"),+ }),+ json!({+ "event_type": "call.record_imported",+ "metadata": {+ "call_id": CALL_ID,+ "owner": "macro|[email protected]",+ },+ }),+ ),]}@@ -155,6 +168,7 @@ fn macro_events() -> Vec<CallMacroEvent> {CallMacroEvent::record_summarized(metadata)}CallTopicEvent::RecordingReady(metadata) => CallMacroEvent::recording_ready(metadata),+ CallTopicEvent::RecordImported(metadata) => CallMacroEvent::record_imported(metadata),}).collect()}diff --git a/crates/call/src/domain/imports.rs b/crates/call/src/domain/imports.rsindex 9cca4c2753..0c50db0453 100644--- a/crates/call/src/domain/imports.rs+++ b/crates/call/src/domain/imports.rs@@ -1,8 +1,14 @@//! Trusted integration entry point. Import ownership comes from the connected//! Macro user, never from provider attendees; imports confer no attendee access.+#[cfg(test)]+mod test;++use super::events::{CallMacroEvent, CallRecordImportedMetadata};use super::records::{CallEntityRecord, CallParticipant, CallSource, CallTranscript};+use super::service::publish_call_event;use async_trait::async_trait;use chrono::{DateTime, Utc};+use macro_event_broker::MacroEventBroker;use macro_user_id::user_id::MacroUserIdStr;use serde::Serialize;use uuid::Uuid;@@ -73,11 +79,14 @@ pub trait CallImportService: Send + Sync {) -> Result<Option<CallEntityRecord>, rootcause::Report>;}-/// Validates provider snapshots before passing them to persistence.-pub struct CallImportServiceImpl<R>(pub R);+/// Validates provider snapshots before passing them to persistence, then+/// announces each stored record on `macro.calls`.+pub struct CallImportServiceImpl<R, B>(pub R, pub B);#[async_trait]-impl<R: ImportedCallRepository> CallImportService for CallImportServiceImpl<R> {+impl<R: ImportedCallRepository, B: MacroEventBroker> CallImportService+ for CallImportServiceImpl<R, B>+{async fn ingest(&self, call: ImportedCall) -> Result<Uuid, rootcause::Report> {if call.source.namespace.trim().is_empty()|| call.source.object_type.trim().is_empty()@@ -90,7 +99,13 @@ impl<R: ImportedCallRepository> CallImportService for CallImportServiceImpl<R> {if matches!((call.started_at, call.ended_at), (Some(start), Some(end)) if end < start) {return Err(rootcause::report!("reversed imported call timing"));}- self.0.upsert(call).await+ let owner = call.source.user_id.clone();+ let call_id = self.0.upsert(call).await?;+ publish_call_event(+ &self.1,+ &CallMacroEvent::record_imported(CallRecordImportedMetadata { call_id, owner }),+ );+ Ok(call_id)}async fn list(&self,diff --git a/crates/call/src/domain/imports/test.rs b/crates/call/src/domain/imports/test.rsnew file mode 100644index 0000000000..d733d5d322--- /dev/null+++ b/crates/call/src/domain/imports/test.rs@@ -0,0 +1,97 @@+use super::*;+use crate::domain::events::CallTopicEvent;+use crate::domain::records::CallProvider;+use macro_event_broker::{EventBrokerError, MacroEvent};+use std::sync::{Arc, Mutex};++const CALL_ID: Uuid = Uuid::from_u128(0x0198a1b2_c3d4_7e5f_8061_728394a5b6c7);++fn owner() -> MacroUserIdStr<'static> {+ MacroUserIdStr::try_from("macro|[email protected]".to_string()).unwrap()+}++struct FixedRepo;++#[async_trait]+impl ImportedCallRepository for FixedRepo {+ async fn upsert(&self, _call: ImportedCall) -> Result<Uuid, rootcause::Report> {+ Ok(CALL_ID)+ }+ async fn list_owned(+ &self,+ _user: &MacroUserIdStr<'static>,+ ) -> Result<Vec<ImportedCallPreview>, rootcause::Report> {+ Ok(vec![])+ }+ async fn read_owned(+ &self,+ _user: &MacroUserIdStr<'static>,+ _id: Uuid,+ ) -> Result<Option<CallEntityRecord>, rootcause::Report> {+ Ok(None)+ }+}++#[derive(Clone, Default)]+struct RecordingBroker(Arc<Mutex<Vec<(String, serde_json::Value)>>>);++impl MacroEventBroker for RecordingBroker {+ fn send_event<E: MacroEvent + ?Sized>(+ &self,+ event: &E,+ ) -> Result<tokio::task::JoinHandle<Result<(), EventBrokerError>>, EventBrokerError> {+ self.0.lock().unwrap().push((+ event.key().to_string(),+ serde_json::to_value(event.event())?,+ ));+ Ok(tokio::spawn(async { Ok(()) }))+ }+}++fn snapshot(namespace: &str) -> ImportedCall {+ ImportedCall {+ source: CallSource {+ user_id: owner(),+ namespace: namespace.into(),+ provider: CallProvider::Granola,+ object_type: "note".into(),+ external_id: "not_123456789abcde".to_owned().try_into().unwrap(),+ external_url: None,+ external_updated_at: None,+ synced_at: None,+ metadata: Default::default(),+ },+ title: None,+ started_at: None,+ ended_at: None,+ participants: vec![],+ transcript: None,+ }+}++#[tokio::test]+async fn ingest_announces_the_stored_record_for_its_owner() {+ let broker = RecordingBroker::default();+ let service = CallImportServiceImpl(FixedRepo, broker.clone());++ assert_eq!(service.ingest(snapshot("account")).await.unwrap(), CALL_ID);++ let events = broker.0.lock().unwrap().clone();+ assert_eq!(events.len(), 1);+ assert_eq!(events[0].0, CALL_ID.to_string());+ let event: CallTopicEvent = serde_json::from_value(events[0].1.clone()).unwrap();+ let CallTopicEvent::RecordImported(metadata) = event else {+ panic!("expected an imported record event");+ };+ assert_eq!(metadata.call_id, CALL_ID);+ assert_eq!(metadata.owner, owner());+}++#[tokio::test]+async fn rejected_imports_publish_nothing() {+ let broker = RecordingBroker::default();+ let service = CallImportServiceImpl(FixedRepo, broker.clone());++ assert!(service.ingest(snapshot(" ")).await.is_err());+ assert!(broker.0.lock().unwrap().is_empty());+}diff --git a/crates/call/src/domain/service.rs b/crates/call/src/domain/service.rsindex 4da152c635..52b11683c3 100644--- a/crates/call/src/domain/service.rs+++ b/crates/call/src/domain/service.rs@@ -2129,7 +2129,7 @@ impl<}}-fn publish_call_event<B: MacroEventBroker>(event_broker: &B, event: &CallMacroEvent) {+pub(crate) fn publish_call_event<B: MacroEventBroker>(event_broker: &B, event: &CallMacroEvent) {drop(event_broker.send_event(event).inspect_err(|error| {tracing::error!(error = ?error, "failed to schedule call lifecycle event");}));diff --git a/crates/call/src/outbound/pg_imported_call_repo/test.rs b/crates/call/src/outbound/pg_imported_call_repo/test.rsindex ec36e57c57..b036d33b99 100644--- a/crates/call/src/outbound/pg_imported_call_repo/test.rs+++ b/crates/call/src/outbound/pg_imported_call_repo/test.rs@@ -59,7 +59,10 @@ fn snapshot(owner: &str, revision: chrono::DateTime<Utc>) -> ImportedCall {fixtures(path = "../../../fixtures", scripts("import_users")))]async fn imports_are_private_idempotent_owner_scoped_and_revision_ordered(pool: PgPool) {- let service = CallImportServiceImpl(PgImportedCallRepository::new(pool.clone()));+ let service = CallImportServiceImpl(+ PgImportedCallRepository::new(pool.clone()),+ macro_event_broker::NoopMacroEventBroker,+ );let now = Utc::now();let id = service.ingest(snapshot("import-a", now)).await.unwrap();let first = service.read(&user("import-a"), id).await.unwrap().unwrap();diff --git a/crates/soup_realtime/AGENTS.md b/crates/soup_realtime/AGENTS.mdindex 6f756e3e1c..50f7fbb4af 100644--- a/crates/soup_realtime/AGENTS.md+++ b/crates/soup_realtime/AGENTS.md@@ -3,7 +3,7 @@## What it isPart of the Soup query feature (Home/Recent/Signal) — keeps cached Soup-results live by turning document/project/chat/email/channel/property Kafka+results live by turning document/project/chat/email/channel/property/call Kafkaevents into recipient-targeted Soup patches, and fanning those out toinstance-local, user-keyed subscriptions. No composition root; starts notasks itself.@@ -32,7 +32,7 @@ tasks itself.- Depends on: `macro_event_broker`, `macro_event_topics`, `model-entity`,`model_owner`; feature-gated: `channels`, `chat`, `documents`, `email`,- `github_pull_requests`, `initiative`, `properties`, `projects`,+ `call`, `github_pull_requests`, `initiative`, `properties`, `projects`,`system_properties`, `rdkafka` (`consumer`), `agent_session`/`entity_access`(`outbound`).- Used by: `complete_graph`, `graphql_soup`, `work_feed`.@@ -55,6 +55,8 @@ tasks itself.- Property definition/option lifecycle events are intentionally ignored; theydon't identify every affected entity.- Channel threads use their containing channel as the access source.+- Only `call.record_imported` patches calls; native call lifecycle events on+ `macro.calls` are ignored.## Relateddiff --git a/crates/soup_realtime/Cargo.toml b/crates/soup_realtime/Cargo.tomlindex 5e45b9ef6b..7fdb0171da 100644--- a/crates/soup_realtime/Cargo.toml+++ b/crates/soup_realtime/Cargo.toml@@ -6,6 +6,7 @@ version = "0.1.0"[features]consumer = [+ "dep:call","dep:channels","dep:chat","dep:documents",@@ -40,6 +41,7 @@ ports = [[dependencies]agent_session = { path = "../agent_session", default-features = false, optional = true }broadcast = { path = "../broadcast", optional = true }+call = { path = "../call", default-features = false, optional = true }channels = { path = "../channels", default-features = false, optional = true }messages = { path = "../messages", features = ["broker"] }chat = { path = "../chat", default-features = false, optional = true }diff --git a/crates/soup_realtime/README.md b/crates/soup_realtime/README.mdindex d8ac87477e..cc3f1fd78b 100644--- a/crates/soup_realtime/README.md+++ b/crates/soup_realtime/README.md@@ -1,6 +1,6 @@# soup_realtime-Hexagonal components for turning existing document, project, chat, email, channel, and property Kafka events into recipient-targeted Soup patches.+Hexagonal components for turning existing document, project, chat, email, channel, property, and imported-call Kafka events into recipient-targeted Soup patches.The inbound consumer maps each source event to `Patch::Updated(Entity)` or `Patch::Deleted(Entity)`. Entity-property updates, deletions, and clears map to updated Soup entities; property task entities map to their document representation. Property definition and option lifecycle events are ignored because they do not identify every affected entity. The domain service expands current access and publishes one patch per recipient to `macro.soup`; it does not hydrate or serialize `SoupItem` values. Channel threads use their containing channel as the access source.diff --git a/crates/soup_realtime/src/inbound/kafka_consumer.rs b/crates/soup_realtime/src/inbound/kafka_consumer.rsindex 96a35f4b8a..769d1c0387 100644--- a/crates/soup_realtime/src/inbound/kafka_consumer.rs+++ b/crates/soup_realtime/src/inbound/kafka_consumer.rs@@ -17,6 +17,7 @@ use crate::domain::{ports::{PullRequestSessions, SoupRealtimeService},service::SoupRealtimeServiceImpl,};+use call::domain::events::{CallMacroEvent, CallTopicEvent};use channels::domain::{broker_events::{ChannelMacroEvent, ChannelTopicEvent},models::ReferencedShareItemType,@@ -69,6 +70,7 @@ macro_event_broker::declare_topics!(MessageMacroEvent,PropertyMacroEvent,InitiativeMacroEvent,+ CallMacroEvent,);fn entity(entity_type: EntityType, entity_id: impl ToString) -> Entity<'static> {@@ -395,6 +397,22 @@ fn patches_from_channel_event(event: &ChannelTopicEvent) -> Vec<SoupRealtimePatc}}+/// Imported records reach Soup as soon as they are stored. Native call+/// lifecycle events don't patch Soup yet.+fn patches_from_call_event(event: &CallTopicEvent) -> Vec<SoupRealtimePatch> {+ match event {+ CallTopicEvent::RecordImported(metadata) => {+ vec![update(EntityType::Call, metadata.call_id)]+ }+ CallTopicEvent::Started(_)+ | CallTopicEvent::RecordArchived(_)+ | CallTopicEvent::RecordUpdated(_)+ | CallTopicEvent::RecordDeleted(_)+ | CallTopicEvent::RecordSummarized(_)+ | CallTopicEvent::RecordingReady(_) => Vec::new(),+ }+}+/// Message facts carry their parent. Channel messages are Soup items, so a/// channel post, edit, deletion, or attachment change patches the channel/// and its thread; document discussions are not Soup items and patch nothing.@@ -585,6 +603,7 @@ fn patches_from_event(event: &DeclaredMacroEvent) -> Vec<SoupRealtimePatch> {DeclaredMacroEvent::PropertyMacroEvent(event) => {patches_from_property_event(&event.event().event)}+ DeclaredMacroEvent::CallMacroEvent(event) => patches_from_call_event(&event.event().event),}}diff --git a/crates/soup_realtime/src/inbound/kafka_consumer/test.rs b/crates/soup_realtime/src/inbound/kafka_consumer/test.rsindex 9adbf6c5f3..00b31512e6 100644--- a/crates/soup_realtime/src/inbound/kafka_consumer/test.rs+++ b/crates/soup_realtime/src/inbound/kafka_consumer/test.rs@@ -4,6 +4,7 @@ use std::collections::HashSet;use std::sync::atomic::{AtomicUsize, Ordering};use std::sync::{Arc, Mutex};+use call::domain::events::{CallRecordImportedMetadata, CallRecordSummarizedMetadata};use channels::domain::models::ChannelSender;use chat::domain::events::{ChatMessageDeletedMetadata, ChatMessageRole, ChatMessageSentMetadata, ChatTopicEvent,@@ -124,6 +125,7 @@ fn subscribes_to_all_existing_soup_source_topics() {"macro.messages","macro.properties","macro.initiatives",+ "macro.calls",]);}@@ -1073,3 +1075,24 @@ impl PullRequestSessions for NoPullRequestSessions {Ok(Vec::new())}}++#[test]+fn imported_call_records_update_soup_and_native_call_events_are_ignored() {+ let call_id = Uuid::now_v7();+ let imported = CallTopicEvent::RecordImported(CallRecordImportedMetadata {+ call_id,+ owner: user(),+ });+ let patches = patches_from_call_event(&imported);+ assert_eq!(patches.len(), 1);+ assert!(matches!(patches[0].patch, Patch::Updated(_)));+ assert_eq!(patch_entity(&patches[0]).entity_type, EntityType::Call);+ assert_eq!(patch_entity(&patches[0]).entity_id, call_id.to_string());++ let summarized = CallTopicEvent::RecordSummarized(CallRecordSummarizedMetadata {+ call_id,+ channel_id: None,+ ai_name_generated: false,+ });+ assert!(patches_from_call_event(&summarized).is_empty());+}diff --git a/docs/agent-guide/calls.md b/docs/agent-guide/calls.mdindex 4189761298..eb050c6fed 100644--- a/docs/agent-guide/calls.md+++ b/docs/agent-guide/calls.md@@ -43,9 +43,10 @@ Business or Enterprise API key) is the only setup; there are no sync controls.Within about 30 seconds the backend registers a Granola webhook at the widestscope the key allows, and removing or disabling the connection stops sync. Noteswhose first summary is generated, edited, or shared after that are imported as-private calls about a minute after Granola finishes the summary; history is not-backfilled. Imported calls appear in `All` and `Attended`, never in a channel's-`Calls` tab, and open in the normal call detail with title, summary, attendees+private calls about a minute after Granola finishes the summary, and appear in+Soup lists without a refresh; history is not backfilled. Imported calls appear+in `All` and `Attended`, never in a channel's `Calls` tab, and open in the+normal call detail with title, summary, attendees(shown as guests), and transcript but no recording. Rename and delete do notapply to imported calls yet. Webhooks require a public HTTPS `MCP_PUBLIC_URL`;on a laptop stack, expose the webhook path with a tunnel such as Tailscale Funnel.diff --git a/services/document_cognition_service/src/server.rs b/services/document_cognition_service/src/server.rsindex ce309f06c3..ff8987ba4d 100644--- a/services/document_cognition_service/src/server.rs+++ b/services/document_cognition_service/src/server.rs@@ -661,6 +661,7 @@ pub async fn run() -> anyhow::Result<()> {call::outbound::pg_imported_call_repo::PgImportedCallRepository::new(db.clone(),),+ macro_event_broker.clone(),)),public_url: config.mcp_public_url.clone(),}) as Arc<dyn granola_sync::domain::service::SyncService>diff --git a/services/search_processing_service/src/inbound/kafka_consumer/call.rs b/services/search_processing_service/src/inbound/kafka_consumer/call.rsindex c9a2602c30..a101fa4a74 100644--- a/services/search_processing_service/src/inbound/kafka_consumer/call.rs+++ b/services/search_processing_service/src/inbound/kafka_consumer/call.rs@@ -69,6 +69,11 @@ pub(super) fn describe_call_event(event: &CallTopicEvent) -> CallEventDescriptiocall_id: metadata.call_id,event_type: "call.recording_ready",},+ CallTopicEvent::RecordImported(metadata) => CallEventDescription {+ action: CallIndexAction::Ignore,+ call_id: metadata.call_id,+ event_type: "call.record_imported",+ },}}