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(calendar): occurrence scoping for AI-tool and API event updates (#5728)
gbirman46fd83a34fcd
diff --git a/apps/docs/AI/mcp/tools/update-calendar-event.mdx b/apps/docs/AI/mcp/tools/update-calendar-event.mdxindex 56b1b284b7..4130d1f839 100644--- a/apps/docs/AI/mcp/tools/update-calendar-event.mdx+++ b/apps/docs/AI/mcp/tools/update-calendar-event.mdx@@ -1,23 +1,27 @@---title: UpdateCalendarEvent-description: "Update an existing calendar event. Only the supplied fields change; omitted fields keep their current values. The change is written to Google immediately and attendees are notified of it, so confirm details with the user first. Get the `eventId` from ListCalendarEvents. Passing `attendees` replaces the full attendee list — include everyone who should remain, not just additions. An empty string for `description` or `location` clears it. Updating a recurring event changes the whole series. Fails on events from calendars the user cannot edit."+description: "Update an existing calendar event. Only the supplied fields change; omitted fields keep their current values. The change is written to Google immediately and attendees are notified of it, so confirm details with the user first. Get the `eventId` from ListCalendarEvents. `scope` picks how much of a recurring series changes and is always required: \"this_event\" edits one occurrence (pass the occurrence's `recurrenceId` from ListCalendarEvents) and leaves the rest of the series alone; \"all\" edits the series itself — with `time` that MOVES EVERY OCCURRENCE, so never use \"all\" to reschedule a single occurrence. Non-recurring events use \"all\". There is no this-and-following update: end the series with DeleteCalendarEvent's \"this_and_following\" and create a new event instead. Passing `attendees` replaces the full attendee list — include everyone who should remain, not just additions. An empty string for `description` or `location` clears it. Fails on events from calendars the user cannot edit."---# UpdateCalendarEventUpdate an existing calendar event. Only the supplied fields change; omitted fields keep their current values. The change is written to Google immediately and attendees are notified of it, so confirm details with the user first. Get the `eventId` from ListCalendarEvents.-Passing `attendees` replaces the full attendee list — include everyone who should remain, not just additions. An empty string for `description` or `location` clears it. Updating a recurring event changes the whole series. Fails on events from calendars the user cannot edit.+`scope` picks how much of a recurring series changes and is always required: "this_event" edits one occurrence (pass the occurrence's `recurrenceId` from ListCalendarEvents) and leaves the rest of the series alone; "all" edits the series itself — with `time` that MOVES EVERY OCCURRENCE, so never use "all" to reschedule a single occurrence. Non-recurring events use "all". There is no this-and-following update: end the series with DeleteCalendarEvent's "this_and_following" and create a new event instead.++Passing `attendees` replaces the full attendee list — include everyone who should remain, not just additions. An empty string for `description` or `location` clears it. Fails on events from calendars the user cannot edit.## Parameters| Parameter | Type | Required | Description || --- | --- | --- | --- || `eventId` | string | Yes | The event's id, from ListCalendarEvents or CreateCalendarEvent. |+| `scope` | `"all"` \| `"this_event"` | Yes | How much of a recurring series an update applies to. |+| `recurrenceId` | string | No | The `recurrenceId` of the targeted occurrence, from its ListCalendarEvents entry. Required for "this_event"; omit for "all". || `title` | string | No | Replacement title. Omit to keep the current title. || `description` | string | No | Replacement event body/description. An empty string clears it; omit to keep the current one. || `location` | string | No | Replacement location label. An empty string clears it; omit to keep the current one. || `time` | EventTimeInput | No | Replacement time: a timed span with `kind` "timed" (startsAt, endsAt, optional timeZone) or whole days with `kind` "allDay" (startDate, exclusive endDate). Omit to keep the current time. || `attendees` | AttendeeInput[] | No | Replacement attendee list — replaces all current attendees, so include everyone who should remain. Omit to leave attendees unchanged. |-| `recurrenceLines` | string[] | No | Replacement RFC 5545 recurrence lines. An empty list makes the event one-off; omit to keep the current recurrence. |+| `recurrenceLines` | string[] | No | Replacement RFC 5545 recurrence lines. An empty list makes the event one-off; omit to keep the current recurrence. Only valid with scope "all". || `conference` | `"google_meet"` \| `"remove"` | No | Change the event's video conference: "google_meet" attaches a fresh Google Meet, "remove" detaches the current conference. Omit to leave it untouched. |diff --git a/apps/web/src/lib/core/component/AI/component/tool/CalendarTools.tsx b/apps/web/src/lib/core/component/AI/component/tool/CalendarTools.tsxindex 22b966857c..475e8b1437 100644--- a/apps/web/src/lib/core/component/AI/component/tool/CalendarTools.tsx+++ b/apps/web/src/lib/core/component/AI/component/tool/CalendarTools.tsx@@ -93,6 +93,10 @@ const mutationRenderer = (render: (ctx) => {const [isExpanded, setIsExpanded] = createSignal(false);const event = () => ctx.response?.data as ToolCalendarEvent | undefined;+ const callLabel = () => {+ const scope = (ctx.tool.data as { scope?: string }).scope;+ return scope === 'this_event' ? `${label} occurrence` : label;+ };const title = () => {const responseTitle = event()?.title;if (responseTitle) return responseTitle;@@ -113,7 +117,7 @@ const mutationRenderer = (><div class="flex min-w-0 flex-1 items-center justify-between gap-3 overflow-hidden"><span class="min-w-0 truncate">- {label}+ {callLabel()}<Show when={title()}>{(eventTitle) => (<>diff --git a/apps/web/src/lib/service-clients/service-cognition/generated/tools/schemas.ts b/apps/web/src/lib/service-clients/service-cognition/generated/tools/schemas.tsindex f9547d7405..a99eb14f6c 100644--- a/apps/web/src/lib/service-clients/service-cognition/generated/tools/schemas.ts+++ b/apps/web/src/lib/service-clients/service-cognition/generated/tools/schemas.ts@@ -3775,7 +3775,26 @@ export const UpdateCalendarEvent = z.object({description: z.union([z.string(), z.null()]).optional(),eventId: z.string().uuid(),location: z.union([z.string(), z.null()]).optional(),+ recurrenceId: z.union([z.string(), z.null()]).optional(),recurrenceLines: z.union([z.array(z.string()), z.null()]).optional(),+ scope: z.any().superRefine((x, ctx) => {+ const schemas = [z.literal('all'), z.literal('this_event')];+ const errors = schemas.reduce<z.ZodError[]>(+ (errors, schema) =>+ ((result) => (result.error ? [...errors, result.error] : errors))(+ schema.safeParse(x)+ ),+ []+ );+ if (schemas.length - errors.length !== 1) {+ ctx.addIssue({+ path: ctx.path,+ code: 'invalid_union',+ unionErrors: errors,+ message: 'Invalid input: Should pass single schema',+ });+ }+ }),time: z.union([z.any().superRefine((x, ctx) => {diff --git a/apps/web/src/lib/service-clients/service-cognition/generated/tools/types.ts b/apps/web/src/lib/service-clients/service-cognition/generated/tools/types.tsindex 643b2881c3..b449d3ff51 100644--- a/apps/web/src/lib/service-clients/service-cognition/generated/tools/types.ts+++ b/apps/web/src/lib/service-clients/service-cognition/generated/tools/types.ts@@ -620,6 +620,10 @@ export type TextEditorCodeExecutionContent =| (TextEditorCodeExecutionToolError & {type: 'text_editor_code_execution_tool_result_error';});+/**+ * How much of a recurring series an update applies to.+ */+export type UpdateScopeInput = 'all' | 'this_event';/*** User tools are pending until a user executes them*/@@ -876,7 +880,7 @@ export interface CalendarEventListItem {organizerEmail?: string | null;/*** Occurrence key identifying this instance within its recurring series;- * pass as `recurrenceId` for occurrence-scoped deletion.+ * pass as `recurrenceId` for occurrence-scoped updates and deletions.*/recurrenceId?: string | null;/**@@ -4391,7 +4395,9 @@ export interface ToolCalendarEvent {/*** Update an existing calendar event. Only the supplied fields change; omitted fields keep their current values. The change is written to Google immediately and attendees are notified of it, so confirm details with the user first. Get the `eventId` from ListCalendarEvents.*- * Passing `attendees` replaces the full attendee list — include everyone who should remain, not just additions. An empty string for `description` or `location` clears it. Updating a recurring event changes the whole series. Fails on events from calendars the user cannot edit.+ * `scope` picks how much of a recurring series changes and is always required: "this_event" edits one occurrence (pass the occurrence's `recurrenceId` from ListCalendarEvents) and leaves the rest of the series alone; "all" edits the series itself — with `time` that MOVES EVERY OCCURRENCE, so never use "all" to reschedule a single occurrence. Non-recurring events use "all". There is no this-and-following update: end the series with DeleteCalendarEvent's "this_and_following" and create a new event instead.+ *+ * Passing `attendees` replaces the full attendee list — include everyone who should remain, not just additions. An empty string for `description` or `location` clears it. Fails on events from calendars the user cannot edit.*/export interface UpdateCalendarEvent {/**@@ -4415,9 +4421,14 @@ export interface UpdateCalendarEvent {*/location?: string | null;/**- * Replacement RFC 5545 recurrence lines. An empty list makes the event one-off; omit to keep the current recurrence.+ * The `recurrenceId` of the targeted occurrence, from its ListCalendarEvents entry. Required for "this_event"; omit for "all".+ */+ recurrenceId?: string | null;+ /**+ * Replacement RFC 5545 recurrence lines. An empty list makes the event one-off; omit to keep the current recurrence. Only valid with scope "all".*/recurrenceLines?: string[] | null;+ scope: UpdateScopeInput;/*** Replacement time: a timed span with `kind` "timed" (startsAt, endsAt, optional timeZone) or whole days with `kind` "allDay" (startDate, exclusive endDate). Omit to keep the current time.*/diff --git a/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarMutationErrorCode.ts b/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarMutationErrorCode.tsindex 27b75af8ca..74ff949f03 100644--- a/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarMutationErrorCode.ts+++ b/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarMutationErrorCode.ts@@ -14,6 +14,7 @@ export type CalendarMutationErrorCode =// eslint-disable-next-line @typescript-eslint/no-redeclareexport const CalendarMutationErrorCode = {not_found: 'not_found',+ occurrence_not_found: 'occurrence_not_found',read_only: 'read_only',no_writable_calendar: 'no_writable_calendar',not_attendee: 'not_attendee',diff --git a/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarUpdateScopeParam.ts b/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarUpdateScopeParam.tsnew file mode 100644index 0000000000..19f82d1656--- /dev/null+++ b/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarUpdateScopeParam.ts@@ -0,0 +1,24 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * email_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * How much of a recurring series an update applies to.++Like RSVPs there is no this-and-following variant: the provider cannot+express a forward-scoped edit as one write, and emulating it (truncate+the series, insert an edited clone) is non-atomic and re-invites the+attendees of the clone. Compose it from a this-and-following deletion+and a create when that shape is wanted.+ */+export type CalendarUpdateScopeParam =+ (typeof CalendarUpdateScopeParam)[keyof typeof CalendarUpdateScopeParam];++// eslint-disable-next-line @typescript-eslint/no-redeclare+export const CalendarUpdateScopeParam = {+ all: 'all',+ this_event: 'this_event',+} as const;diff --git a/apps/web/src/lib/service-clients/service-email/generated/schemas/index.ts b/apps/web/src/lib/service-clients/service-email/generated/schemas/index.tsindex 3961f847dd..5eba1c5c0e 100644--- a/apps/web/src/lib/service-clients/service-email/generated/schemas/index.ts+++ b/apps/web/src/lib/service-clients/service-email/generated/schemas/index.ts@@ -159,6 +159,7 @@ export * from './calendarEventOrganizerName';export * from './calendarMutationApiError';export * from './calendarMutationErrorCode';export * from './calendarRsvpScopeParam';+export * from './calendarUpdateScopeParam';export * from './cancelBackfillParams';export * from './conferenceChange';export * from './conferenceProvider';@@ -318,8 +319,10 @@ export * from './updateCalendarEventRequestAttendees';export * from './updateCalendarEventRequestConference';export * from './updateCalendarEventRequestDescription';export * from './updateCalendarEventRequestLocation';+export * from './updateCalendarEventRequestRecurrenceId';export * from './updateCalendarEventRequestRecurrenceLines';export * from './updateCalendarEventRequestReminders';+export * from './updateCalendarEventRequestScope';export * from './updateCalendarEventRequestTime';export * from './updateCalendarEventRequestTitle';export * from './updateCalendarEventRequestTransparency';diff --git a/apps/web/src/lib/service-clients/service-email/generated/schemas/updateCalendarEventRequest.ts b/apps/web/src/lib/service-clients/service-email/generated/schemas/updateCalendarEventRequest.tsindex 630f9d862d..d1493d9b24 100644--- a/apps/web/src/lib/service-clients/service-email/generated/schemas/updateCalendarEventRequest.ts+++ b/apps/web/src/lib/service-clients/service-email/generated/schemas/updateCalendarEventRequest.ts@@ -8,8 +8,10 @@ import type { UpdateCalendarEventRequestAttendees } from './updateCalendarEventRimport type { UpdateCalendarEventRequestConference } from './updateCalendarEventRequestConference';import type { UpdateCalendarEventRequestDescription } from './updateCalendarEventRequestDescription';import type { UpdateCalendarEventRequestLocation } from './updateCalendarEventRequestLocation';+import type { UpdateCalendarEventRequestRecurrenceId } from './updateCalendarEventRequestRecurrenceId';import type { UpdateCalendarEventRequestRecurrenceLines } from './updateCalendarEventRequestRecurrenceLines';import type { UpdateCalendarEventRequestReminders } from './updateCalendarEventRequestReminders';+import type { UpdateCalendarEventRequestScope } from './updateCalendarEventRequestScope';import type { UpdateCalendarEventRequestTime } from './updateCalendarEventRequestTime';import type { UpdateCalendarEventRequestTitle } from './updateCalendarEventRequestTitle';import type { UpdateCalendarEventRequestTransparency } from './updateCalendarEventRequestTransparency';@@ -26,9 +28,12 @@ export interface UpdateCalendarEventRequest {description?: UpdateCalendarEventRequestDescription;/** Replacement location; an empty string clears it. */location?: UpdateCalendarEventRequestLocation;+ /** Original-start key of the occurrence the update targets. */+ recurrenceId?: UpdateCalendarEventRequestRecurrenceId;/** Replacement recurrence properties; an empty list clears them. */recurrenceLines?: UpdateCalendarEventRequestRecurrenceLines;reminders?: UpdateCalendarEventRequestReminders;+ scope?: UpdateCalendarEventRequestScope;time?: UpdateCalendarEventRequestTime;/** Replacement title; an empty string clears it. */title?: UpdateCalendarEventRequestTitle;diff --git a/apps/web/src/lib/service-clients/service-email/generated/schemas/updateCalendarEventRequestRecurrenceId.ts b/apps/web/src/lib/service-clients/service-email/generated/schemas/updateCalendarEventRequestRecurrenceId.tsnew file mode 100644index 0000000000..b3b8048898--- /dev/null+++ b/apps/web/src/lib/service-clients/service-email/generated/schemas/updateCalendarEventRequestRecurrenceId.ts@@ -0,0 +1,11 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * email_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * Original-start key of the occurrence the update targets.+ */+export type UpdateCalendarEventRequestRecurrenceId = string | null;diff --git a/apps/web/src/lib/service-clients/service-email/generated/schemas/updateCalendarEventRequestScope.ts b/apps/web/src/lib/service-clients/service-email/generated/schemas/updateCalendarEventRequestScope.tsnew file mode 100644index 0000000000..6201ed892d--- /dev/null+++ b/apps/web/src/lib/service-clients/service-email/generated/schemas/updateCalendarEventRequestScope.ts@@ -0,0 +1,9 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * email_service+ * OpenAPI spec version: 0.1.0+ */+import type { CalendarUpdateScopeParam } from './calendarUpdateScopeParam';++export type UpdateCalendarEventRequestScope = null | CalendarUpdateScopeParam;diff --git a/apps/web/src/lib/service-clients/service-email/openapi.json b/apps/web/src/lib/service-clients/service-email/openapi.jsonindex 99c4f64bd3..5a9fd8eb68 100644--- a/apps/web/src/lib/service-clients/service-email/openapi.json+++ b/apps/web/src/lib/service-clients/service-email/openapi.json@@ -259,7 +259,7 @@}},"404": {- "description": "Event not found",+ "description": "Event or targeted occurrence not found","content": {"application/json": {"schema": {@@ -4652,6 +4652,7 @@"description": "Machine-readable failure category for calendar mutations.","enum": ["not_found",+ "occurrence_not_found","read_only","no_writable_calendar","not_attendee",@@ -4667,6 +4668,11 @@"description": "How much of a recurring series an RSVP applies to.\n\nUnlike deletion there is no this-and-following variant: the provider\ncannot express a forward-scoped response, so offering one would be a\npromise sync could not keep.","enum": ["all", "this_event"]},+ "CalendarUpdateScopeParam": {+ "type": "string",+ "description": "How much of a recurring series an update applies to.\n\nLike RSVPs there is no this-and-following variant: the provider cannot\nexpress a forward-scoped edit as one write, and emulating it (truncate\nthe series, insert an edited clone) is non-atomic and re-invites the\nattendees of the clone. Compose it from a this-and-following deletion\nand a create when that shape is wanted.",+ "enum": ["all", "this_event"]+ },"CancelBackfillParams": {"type": "object","required": ["job_id"],@@ -6160,6 +6166,10 @@"type": ["string", "null"],"description": "Replacement location; an empty string clears it."},+ "recurrenceId": {+ "type": ["string", "null"],+ "description": "Original-start key of the occurrence the update targets."+ },"recurrenceLines": {"type": ["array", "null"],"items": {@@ -6178,6 +6188,17 @@}]},+ "scope": {+ "oneOf": [+ {+ "type": "null"+ },+ {+ "$ref": "#/components/schemas/CalendarUpdateScopeParam",+ "description": "How much of a recurring series the update covers. Omit to let\n`recurrenceId` decide: the identified occurrence alone when one is\nsupplied, otherwise the whole event or series. An explicit\n`this_event` scope requires `recurrenceId`, so a scoped request is\nnever silently widened to the series."+ }+ ]+ },"time": {"oneOf": [{diff --git a/crates/calendar_events/src/domain/mutations.rs b/crates/calendar_events/src/domain/mutations.rsindex d03c713a6c..503a861c6c 100644--- a/crates/calendar_events/src/domain/mutations.rs+++ b/crates/calendar_events/src/domain/mutations.rs@@ -19,8 +19,9 @@ use super::{ports::{CalendarAccessTokenProvider, CalendarDeletionScope, CalendarEventWrite,CalendarMutationError, CalendarMutationService, CalendarRepository, CalendarRsvpScope,- CalendarTokenError, GoogleCalendarMutationProvider, GoogleProviderError,- GoogleProviderErrorKind, GoogleRsvpOutcome, GoogleSeriesMutationOutcome,+ CalendarTokenError, CalendarUpdateScope, GoogleCalendarMutationProvider,+ GoogleInstanceUpdateOutcome, GoogleProviderError, GoogleProviderErrorKind,+ GoogleRsvpOutcome, GoogleSeriesMutationOutcome,},};@@ -138,6 +139,7 @@ whererequester_id: &str,event_id: Uuid,patch: CalendarEventPatch,+ scope: CalendarUpdateScope,) -> Result<CalendarEvent, CalendarMutationError> {if patch.is_empty() {return Err(CalendarMutationError::InvalidInput(@@ -153,28 +155,80 @@ whereif let Some(reminders) = &patch.reminders {validate_reminders(reminders)?;}+ if matches!(scope, CalendarUpdateScope::ThisEvent { .. })+ && patch.recurrence_lines.is_some()+ {+ return Err(CalendarMutationError::InvalidInput(+ "a single occurrence has no recurrence of its own; update the whole series to \+ change the recurrence"+ .to_string(),+ ));+ }let target = self.resolve_mutation_target(requester_id, event_id).await?;if target.is_read_only {return Err(CalendarMutationError::ReadOnly);}let access_token = self.fetch_token(&target.token_identity).await?;- let updated = self- .provider- .update_event(- &access_token,- &target.google_target(OccurrenceRange::maintenance_horizon(Utc::now())),- target.master_provider_event_id(),- &patch,- )- .await- .map_err(provider_error)?;- let Some(upsert) = updated else {- // The provider no longer has the event; retire the stale local- // source the same way a feed tombstone would.- self.retire_gone_source(&target).await;- return Err(CalendarMutationError::NotFound);- };- self.persist_echo(upsert).await+ let google_target = target.google_target(OccurrenceRange::maintenance_horizon(Utc::now()));+ match scope {+ CalendarUpdateScope::All => {+ let updated = self+ .provider+ .update_event(+ &access_token,+ &google_target,+ target.master_provider_event_id(),+ &patch,+ )+ .await+ .map_err(provider_error)?;+ let Some(upsert) = updated else {+ // The provider no longer has the event; retire the stale+ // local source the same way a feed tombstone would.+ self.retire_gone_source(&target).await;+ return Err(CalendarMutationError::NotFound);+ };+ self.persist_echo(upsert).await+ }+ CalendarUpdateScope::ThisEvent { recurrence_id } => {+ let outcome = self+ .provider+ .update_event_instance(+ &access_token,+ &google_target,+ target.master_provider_event_id(),+ &recurrence_id,+ &patch,+ )+ .await+ .map_err(provider_error)?;+ match outcome {+ GoogleInstanceUpdateOutcome::Applied(upsert) => {+ self.persist_echo(*upsert).await+ }+ GoogleInstanceUpdateOutcome::OccurrenceGone(upsert) => {+ // Nothing was written, but the provider's view of the+ // series is fresher than whatever listed this+ // occurrence — persist it so the phantom disappears.+ self.persist_echo(*upsert)+ .await+ .inspect_err(|error| {+ tracing::warn!(+ error=?error,+ event_id=%target.event_id,+ "failed to persist the series refresh for a vanished occurrence"+ );+ })+ .ok();+ Err(CalendarMutationError::OccurrenceNotFound)+ }+ GoogleInstanceUpdateOutcome::SeriesGone => {+ self.retire_gone_source(&target).await;+ Err(CalendarMutationError::NotFound)+ }+ }+ }+ }}#[tracing::instrument(skip(self, requester_id), err)]diff --git a/crates/calendar_events/src/domain/mutations/test.rs b/crates/calendar_events/src/domain/mutations/test.rsindex 33f65f7ab0..756665f1fb 100644--- a/crates/calendar_events/src/domain/mutations/test.rs+++ b/crates/calendar_events/src/domain/mutations/test.rs@@ -271,6 +271,7 @@ impl CalendarRepository for FakeRepo {enum FakeProviderBehavior {Echo,Gone,+ OccurrenceGone,NotAttendee,Fail(GoogleProviderErrorKind),}@@ -333,6 +334,29 @@ impl GoogleCalendarMutationProvider for FakeProvider {Ok(Some(echo_upsert(&target.owner_id)))}+ async fn update_event_instance(+ &self,+ _access_token: &str,+ target: &GoogleCalendarTarget,+ master_provider_event_id: &str,+ original_start: &str,+ _patch: &CalendarEventPatch,+ ) -> Result<GoogleInstanceUpdateOutcome, GoogleProviderError> {+ self.calls.lock().unwrap().push(format!(+ "instance-update:{master_provider_event_id}:{original_start}"+ ));+ if let Some(error) = self.fail() {+ return Err(error);+ }+ Ok(match self.behavior {+ FakeProviderBehavior::Gone => GoogleInstanceUpdateOutcome::SeriesGone,+ FakeProviderBehavior::OccurrenceGone => {+ GoogleInstanceUpdateOutcome::OccurrenceGone(Box::new(echo_upsert(&target.owner_id)))+ }+ _ => GoogleInstanceUpdateOutcome::Applied(Box::new(echo_upsert(&target.owner_id))),+ })+ }+async fn delete_event(&self,_access_token: &str,@@ -564,7 +588,12 @@ async fn update_validates_lookup_policy_and_addresses_the_series_master() {);assert!(matches!(empty_patch- .update_event("macro|user", Uuid::now_v7(), CalendarEventPatch::default())+ .update_event(+ "macro|user",+ Uuid::now_v7(),+ CalendarEventPatch::default(),+ CalendarUpdateScope::All,+ ).await,Err(CalendarMutationError::InvalidInput(_))));@@ -581,7 +610,12 @@ async fn update_validates_lookup_policy_and_addresses_the_series_master() {);assert!(matches!(not_found- .update_event("macro|user", Uuid::now_v7(), patch.clone())+ .update_event(+ "macro|user",+ Uuid::now_v7(),+ patch.clone(),+ CalendarUpdateScope::All,+ ).await,Err(CalendarMutationError::NotFound)));@@ -596,7 +630,12 @@ async fn update_validates_lookup_policy_and_addresses_the_series_master() {);assert!(matches!(read_only- .update_event("macro|user", Uuid::now_v7(), patch.clone())+ .update_event(+ "macro|user",+ Uuid::now_v7(),+ patch.clone(),+ CalendarUpdateScope::All,+ ).await,Err(CalendarMutationError::ReadOnly)));@@ -611,7 +650,12 @@ async fn update_validates_lookup_policy_and_addresses_the_series_master() {provider,FakeTokens::ok(),)- .update_event("macro|user", Uuid::now_v7(), patch)+ .update_event(+ "macro|user",+ Uuid::now_v7(),+ patch,+ CalendarUpdateScope::All,+ ).await.unwrap();assert_eq!(@@ -640,6 +684,7 @@ async fn update_on_a_provider_deleted_event_retires_the_stale_source() {title: Some("Renamed".to_string()),..CalendarEventPatch::default()},+ CalendarUpdateScope::All,).await;@@ -649,6 +694,143 @@ async fn update_on_a_provider_deleted_event_retires_the_stale_source() {assert_eq!(removed[0].2, "master-id");}+#[tokio::test]+async fn occurrence_scoped_update_patches_the_instance_not_the_master() {+ let repo = FakeRepo {+ mutation_target: Some(mutation_target(false)),+ ..FakeRepo::default()+ };+ let upserts = repo.upserts.clone();+ let provider = FakeProvider::new(FakeProviderBehavior::Echo);+ let calls = provider.calls.clone();++ service(repo, provider, FakeTokens::ok())+ .update_event(+ "macro|user",+ Uuid::now_v7(),+ CalendarEventPatch {+ time: Some(timed_time()),+ ..CalendarEventPatch::default()+ },+ CalendarUpdateScope::ThisEvent {+ recurrence_id: "2026-08-18T20:00:00+00:00".to_string(),+ },+ )+ .await+ .unwrap();++ assert_eq!(+ calls.lock().unwrap().as_slice(),+ ["instance-update:master-id:2026-08-18T20:00:00+00:00"],+ "an occurrence-scoped update must never patch the series master"+ );+ assert_eq!(upserts.lock().unwrap().len(), 1);+}++#[tokio::test]+async fn occurrence_scoped_update_rejects_recurrence_changes() {+ let provider = FakeProvider::new(FakeProviderBehavior::Echo);+ let calls = provider.calls.clone();+ let result = service(+ FakeRepo {+ mutation_target: Some(mutation_target(false)),+ ..FakeRepo::default()+ },+ provider,+ FakeTokens::ok(),+ )+ .update_event(+ "macro|user",+ Uuid::now_v7(),+ CalendarEventPatch {+ recurrence_lines: Some(vec!["RRULE:FREQ=WEEKLY".to_string()]),+ ..CalendarEventPatch::default()+ },+ CalendarUpdateScope::ThisEvent {+ recurrence_id: "2026-08-18T20:00:00+00:00".to_string(),+ },+ )+ .await;++ assert!(matches!(+ result,+ Err(CalendarMutationError::InvalidInput(_))+ ));+ assert!(calls.lock().unwrap().is_empty());+}++/// The listed occurrence may be a phantom from a stale projection. Nothing+/// must be written, the caller must hear the target is gone, and the fresh+/// series echo must be persisted so the phantom disappears from listings.+#[tokio::test]+async fn occurrence_scoped_update_on_a_vanished_occurrence_persists_the_refresh_and_errors() {+ let repo = FakeRepo {+ mutation_target: Some(mutation_target(false)),+ ..FakeRepo::default()+ };+ let upserts = repo.upserts.clone();+ let removed = repo.removed_sources.clone();+ let result = service(+ repo,+ FakeProvider::new(FakeProviderBehavior::OccurrenceGone),+ FakeTokens::ok(),+ )+ .update_event(+ "macro|user",+ Uuid::now_v7(),+ CalendarEventPatch {+ time: Some(timed_time()),+ ..CalendarEventPatch::default()+ },+ CalendarUpdateScope::ThisEvent {+ recurrence_id: "2026-08-18T20:00:00+00:00".to_string(),+ },+ )+ .await;++ assert!(matches!(+ result,+ Err(CalendarMutationError::OccurrenceNotFound)+ ));+ assert_eq!(+ upserts.lock().unwrap().len(),+ 1,+ "the provider's fresh view of the series converges the stale projection"+ );+ assert!(removed.lock().unwrap().is_empty());+}++#[tokio::test]+async fn occurrence_scoped_update_on_a_vanished_series_retires_the_source() {+ let repo = FakeRepo {+ mutation_target: Some(mutation_target(false)),+ ..FakeRepo::default()+ };+ let upserts = repo.upserts.clone();+ let removed = repo.removed_sources.clone();+ let result = service(+ repo,+ FakeProvider::new(FakeProviderBehavior::Gone),+ FakeTokens::ok(),+ )+ .update_event(+ "macro|user",+ Uuid::now_v7(),+ CalendarEventPatch {+ title: Some("Renamed".to_string()),+ ..CalendarEventPatch::default()+ },+ CalendarUpdateScope::ThisEvent {+ recurrence_id: "2026-08-18T20:00:00+00:00".to_string(),+ },+ )+ .await;++ assert!(matches!(result, Err(CalendarMutationError::NotFound)));+ assert!(upserts.lock().unwrap().is_empty());+ assert_eq!(removed.lock().unwrap().len(), 1);+}+#[tokio::test]async fn delete_pushes_to_the_provider_then_retires_the_local_source() {let repo = FakeRepo {@@ -890,6 +1072,7 @@ async fn conference_changes_reach_the_provider_for_any_conference() {conference: Some(change),..CalendarEventPatch::default()},+ CalendarUpdateScope::All,).await;diff --git a/crates/calendar_events/src/domain/ports.rs b/crates/calendar_events/src/domain/ports.rsindex 6f1f60e792..da9b3f58de 100644--- a/crates/calendar_events/src/domain/ports.rs+++ b/crates/calendar_events/src/domain/ports.rs@@ -131,6 +131,21 @@ pub trait GoogleCalendarMutationProvider: Send + Sync + 'static {patch: &CalendarEventPatch,) -> impl Future<Output = Result<Option<CalendarEventUpsert>, GoogleProviderError>> + Send;+ /// Patch the supplied fields of one occurrence of a recurring series,+ /// identified by its original start key, then refresh the series. An+ /// occurrence the provider does not have writes nothing and surfaces as+ /// [`GoogleInstanceUpdateOutcome::OccurrenceGone`] with the refreshed+ /// series, so a stale projection converges instead of mutating the+ /// master.+ fn update_event_instance(+ &self,+ access_token: &str,+ target: &GoogleCalendarTarget,+ master_provider_event_id: &str,+ original_start: &str,+ patch: &CalendarEventPatch,+ ) -> impl Future<Output = Result<GoogleInstanceUpdateOutcome, GoogleProviderError>> + Send;+/// Delete an event. An event already gone at the provider is success.fn delete_event(&self,@@ -225,6 +240,28 @@ pub enum CalendarRsvpScope {},}+/// How much of a recurring series an update applies to.+///+/// Like [`CalendarRsvpScope`] there is deliberately no this-and-following+/// variant: the provider has no forward-scoped write, and emulating one the+/// way Google's own UI does — truncate the series, then insert a clone+/// carrying the edits — is two non-atomic provider writes whose first half+/// alone destroys every future occurrence, and the clone is a new provider+/// event that re-invites its attendees. Callers wanting that shape compose+/// it explicitly from a this-and-following deletion and a create.+#[derive(Clone, Debug, PartialEq, Eq)]+pub enum CalendarUpdateScope {+ /// The entire event or series, written on the master. A time change+ /// here re-anchors a recurring series: every occurrence moves.+ All,+ /// One occurrence, identified by its original start key, written as a+ /// provider exception. The rest of the series stays untouched.+ ThisEvent {+ /// Stable original-start key of the occurrence.+ recurrence_id: String,+ },+}+/// Result of a provider mutation that reshapes a recurring series.pub enum GoogleSeriesMutationOutcome {/// The series survives; the echo carries its refreshed state.@@ -235,6 +272,18 @@ pub enum GoogleSeriesMutationOutcome {Gone,}+/// Result of patching one occurrence of a recurring series.+pub enum GoogleInstanceUpdateOutcome {+ /// The occurrence was patched; the echo carries the refreshed series.+ Applied(Box<CalendarEventUpsert>),+ /// The provider has no such occurrence — nothing was written. The echo+ /// carries the series as the provider actually holds it, so the caller+ /// can converge a projection stale enough to list phantom occurrences.+ OccurrenceGone(Box<CalendarEventUpsert>),+ /// The whole series no longer exists at the provider.+ SeriesGone,+}+/// Result of attempting to set the connected account's RSVP.pub enum GoogleRsvpOutcome {/// The RSVP was applied; the echo carries the refreshed event.@@ -422,12 +471,14 @@ pub trait CalendarMutationService: Send + Sync + 'static {requester_id: &str,) -> impl Future<Output = Result<Vec<VisibleCalendar>, CalendarMutationError>> + Send;- /// Patch an event at its provider and persist the echo.+ /// Patch an event at its provider — the whole event or series, or one+ /// occurrence of a recurring series — and persist the echo.fn update_event(&self,requester_id: &str,event_id: Uuid,patch: CalendarEventPatch,+ scope: CalendarUpdateScope,) -> impl Future<Output = Result<CalendarEvent, CalendarMutationError>> + Send;/// Delete an event at its provider — entirely, one occurrence, or from@@ -465,6 +516,10 @@ pub enum CalendarMutationError {/// The event does not exist or is not visible to the requester.#[error("calendar event was not found")]NotFound,+ /// The targeted occurrence does not exist on the recurring event at the+ /// provider; the local projection was refreshed to match the provider.+ #[error("the targeted occurrence was not found on the recurring event")]+ OccurrenceNotFound,/// The containing calendar prohibits mutation.#[error("calendar event is read-only")]ReadOnly,diff --git a/crates/calendar_events/src/inbound/mutation_router.rs b/crates/calendar_events/src/inbound/mutation_router.rsindex bf92d79089..9f3efb7e06 100644--- a/crates/calendar_events/src/inbound/mutation_router.rs+++ b/crates/calendar_events/src/inbound/mutation_router.rs@@ -30,6 +30,7 @@ use crate::domain::{},ports::{CalendarDeletionScope, CalendarMutationError, CalendarMutationService, CalendarRsvpScope,+ CalendarUpdateScope,},};@@ -171,6 +172,31 @@ pub struct UpdateCalendarEventRequest {/// A third-party conference is replaced or detached like any other, since/// the request is explicit. Omit the field to leave it alone.pub conference: Option<ConferenceChange>,+ /// How much of a recurring series the update covers. Omit to let+ /// `recurrenceId` decide: the identified occurrence alone when one is+ /// supplied, otherwise the whole event or series. An explicit+ /// `this_event` scope requires `recurrenceId`, so a scoped request is+ /// never silently widened to the series.+ pub scope: Option<CalendarUpdateScopeParam>,+ /// Original-start key of the occurrence the update targets.+ pub recurrence_id: Option<String>,+}++/// How much of a recurring series an update applies to.+///+/// Like RSVPs there is no this-and-following variant: the provider cannot+/// express a forward-scoped edit as one write, and emulating it (truncate+/// the series, insert an edited clone) is non-atomic and re-invites the+/// attendees of the clone. Compose it from a this-and-following deletion+/// and a create when that shape is wanted.+#[derive(Clone, Copy, Debug, Deserialize, utoipa::ToSchema)]+#[serde(rename_all = "snake_case")]+pub enum CalendarUpdateScopeParam {+ /// The entire event or series. A time change here moves every+ /// occurrence of a recurring series.+ All,+ /// One occurrence.+ ThisEvent,}/// How much of a recurring series a deletion removes.@@ -234,6 +260,9 @@ pub struct RsvpCalendarEventRequest {pub enum CalendarMutationErrorCode {/// The event does not exist or is not visible to the requester.NotFound,+ /// The targeted occurrence does not exist on the recurring event at the+ /// provider; the local projection was refreshed to match.+ OccurrenceNotFound,/// The containing calendar prohibits mutation.ReadOnly,/// No connected calendar can accept new events.@@ -284,6 +313,13 @@ impl From<CalendarMutationError> for CalendarMutationApiError {CalendarMutationErrorCode::NotFound,"calendar event was not found".to_string(),),+ CalendarMutationError::OccurrenceNotFound => (+ StatusCode::NOT_FOUND,+ CalendarMutationErrorCode::OccurrenceNotFound,+ "the targeted occurrence was not found on the recurring event; the calendar \+ was out of date and has been refreshed"+ .to_string(),+ ),CalendarMutationError::ReadOnly => (StatusCode::FORBIDDEN,CalendarMutationErrorCode::ReadOnly,@@ -423,6 +459,31 @@ whereOk(Json(ListCalendarsResponse { calendars }))}+/// Resolve an update's scope from its transport pair. An omitted scope+/// defers to `recurrenceId`; contradictory pairs are rejected so a+/// one-occurrence intent is never silently widened to the series and a+/// series intent never carries a dangling occurrence key.+fn update_scope(+ scope: Option<CalendarUpdateScopeParam>,+ recurrence_id: Option<String>,+) -> Result<CalendarUpdateScope, CalendarMutationApiError> {+ match (scope, recurrence_id) {+ (Some(CalendarUpdateScopeParam::All), None) | (None, None) => Ok(CalendarUpdateScope::All),+ (Some(CalendarUpdateScopeParam::ThisEvent), Some(recurrence_id))+ | (None, Some(recurrence_id)) => Ok(CalendarUpdateScope::ThisEvent { recurrence_id }),+ (Some(CalendarUpdateScopeParam::ThisEvent), None) => Err(CalendarMutationApiError {+ code: CalendarMutationErrorCode::InvalidInput,+ message: "a this-event update requires recurrenceId".to_string(),+ status: StatusCode::BAD_REQUEST,+ }),+ (Some(CalendarUpdateScopeParam::All), Some(_)) => Err(CalendarMutationApiError {+ code: CalendarMutationErrorCode::InvalidInput,+ message: "recurrenceId only applies to a this_event update".to_string(),+ status: StatusCode::BAD_REQUEST,+ }),+ }+}+/// Update fields of a calendar event and return its synced entity.#[tracing::instrument(skip_all, fields(event_id = %event_id), err)]#[utoipa::path(@@ -436,7 +497,7 @@ where(status = 400, description = "Invalid event fields", body = CalendarMutationApiError),(status = 401, description = "Authentication required"),(status = 403, description = "Calendar is read-only or needs reauthorization", body = CalendarMutationApiError),- (status = 404, description = "Event not found", body = CalendarMutationApiError),+ (status = 404, description = "Event or targeted occurrence not found", body = CalendarMutationApiError),(status = 409, description = "The provider rejected the update", body = CalendarMutationApiError),(status = 503, description = "Transient provider failure", body = CalendarMutationApiError),)@@ -451,6 +512,7 @@ whereS: CalendarMutationService,Auth: MacroAuthorizationService,{+ let scope = update_scope(request.scope, request.recurrence_id)?;let patch = CalendarEventPatch {title: request.title,description: request.description,@@ -471,6 +533,7 @@ whereuser.authorization.user.macro_user_id.as_ref(),event_id,patch,+ scope,).await?;Ok(Json(event))diff --git a/crates/calendar_events/src/inbound/mutation_router/test.rs b/crates/calendar_events/src/inbound/mutation_router/test.rsindex 5ead43da15..7b893883ac 100644--- a/crates/calendar_events/src/inbound/mutation_router/test.rs+++ b/crates/calendar_events/src/inbound/mutation_router/test.rs@@ -11,6 +11,13 @@ fn domain_errors_map_to_distinct_transport_semantics() {transport_of(CalendarMutationError::NotFound),(StatusCode::NOT_FOUND, CalendarMutationErrorCode::NotFound));+ assert_eq!(+ transport_of(CalendarMutationError::OccurrenceNotFound),+ (+ StatusCode::NOT_FOUND,+ CalendarMutationErrorCode::OccurrenceNotFound+ )+ );assert_eq!(transport_of(CalendarMutationError::ReadOnly),(StatusCode::FORBIDDEN, CalendarMutationErrorCode::ReadOnly)@@ -76,6 +83,32 @@ fn provider_rejections_surface_their_message_but_internal_failures_do_not() {assert!(!retryable.message.contains("10.0.0.7"));}+#[test]+fn update_scope_resolves_each_transport_pair() {+ assert_eq!(update_scope(None, None).unwrap(), CalendarUpdateScope::All);+ assert_eq!(+ update_scope(Some(CalendarUpdateScopeParam::All), None).unwrap(),+ CalendarUpdateScope::All+ );+ for scope in [None, Some(CalendarUpdateScopeParam::ThisEvent)] {+ assert_eq!(+ update_scope(scope, Some("k-1".to_string())).unwrap(),+ CalendarUpdateScope::ThisEvent {+ recurrence_id: "k-1".to_string(),+ }+ );+ }++ let missing_key = update_scope(Some(CalendarUpdateScopeParam::ThisEvent), None).unwrap_err();+ assert_eq!(missing_key.code, CalendarMutationErrorCode::InvalidInput);++ // A series update carrying an occurrence key is contradictory input;+ // dropping the key would apply a one-occurrence intent to the series.+ let stray_key =+ update_scope(Some(CalendarUpdateScopeParam::All), Some("k-1".to_string())).unwrap_err();+ assert_eq!(stray_key.code, CalendarMutationErrorCode::InvalidInput);+}+#[test]fn attendee_body_defaults_to_required_attendance() {let body: CalendarAttendeeInputBody =diff --git a/crates/calendar_events/src/inbound/toolset/list_calendar_events.rs b/crates/calendar_events/src/inbound/toolset/list_calendar_events.rsindex 274229580b..1ae268291c 100644--- a/crates/calendar_events/src/inbound/toolset/list_calendar_events.rs+++ b/crates/calendar_events/src/inbound/toolset/list_calendar_events.rs@@ -52,7 +52,7 @@ pub struct CalendarEventListItem {/// Whether this occurrence belongs to a recurring series.pub is_recurring: bool,/// Occurrence key identifying this instance within its recurring series;- /// pass as `recurrenceId` for occurrence-scoped deletion.+ /// pass as `recurrenceId` for occurrence-scoped updates and deletions.pub recurrence_id: Option<String>,/// Attendees, capped at 20; `attendee_count` has the full number.pub attendees: Vec<ToolEventAttendee>,diff --git a/crates/calendar_events/src/inbound/toolset/mod.rs b/crates/calendar_events/src/inbound/toolset/mod.rsindex 326d087bfb..7f6afcbc0e 100644--- a/crates/calendar_events/src/inbound/toolset/mod.rs+++ b/crates/calendar_events/src/inbound/toolset/mod.rs@@ -35,7 +35,7 @@ pub use list_calendar_events::{CalendarEventListItem, ListCalendarEvents, ListCalendarEventsResponse,};pub use list_calendars::{ListCalendars, ListCalendarsToolResponse, ToolCalendar};-pub use update_calendar_event::{ConferenceChangeInput, UpdateCalendarEvent};+pub use update_calendar_event::{ConferenceChangeInput, UpdateCalendarEvent, UpdateScopeInput};/// Service context for calendar AI tools.pub struct CalendarToolContext<M, O>@@ -300,6 +300,12 @@ fn mutation_tool_error(action: &str, error: CalendarMutationError) -> ToolCallErUse ListCalendarEvents to get current event ids.".to_string()}+ CalendarMutationError::OccurrenceNotFound => {+ "That occurrence does not exist on the recurring event at Google — the calendar \+ copy was out of date and has now been refreshed. Nothing was changed. Run \+ ListCalendarEvents again and retry with a current occurrence."+ .to_string()+ }CalendarMutationError::ReadOnly => {"This event's calendar is read-only for the user, so it cannot be modified.".to_string()}diff --git a/crates/calendar_events/src/inbound/toolset/test.rs b/crates/calendar_events/src/inbound/toolset/test.rsindex 3dc075b276..b975fcf7cd 100644--- a/crates/calendar_events/src/inbound/toolset/test.rs+++ b/crates/calendar_events/src/inbound/toolset/test.rs@@ -14,7 +14,7 @@ use crate::domain::models::{};use crate::domain::ports::{CalendarDeletionScope, CalendarMutationError, CalendarMutationService,- CalendarOccurrenceService, CalendarRsvpScope,+ CalendarOccurrenceService, CalendarRsvpScope, CalendarUpdateScope,};#[test]@@ -138,7 +138,7 @@ type RecordedCreate = (Option<Uuid>, Option<Uuid>, CalendarEventDraft);struct MockMutations {created: Mutex<Vec<RecordedCreate>>,create_error: Mutex<Option<CalendarMutationError>>,- updated: Mutex<Vec<(Uuid, CalendarEventPatch)>>,+ updated: Mutex<Vec<(Uuid, CalendarEventPatch, CalendarUpdateScope)>>,deleted: Mutex<Vec<(Uuid, CalendarDeletionScope)>>,calendars: Mutex<Vec<VisibleCalendar>>,}@@ -173,8 +173,9 @@ impl CalendarMutationService for MockMutations {_requester_id: &str,event_id: Uuid,patch: CalendarEventPatch,+ scope: CalendarUpdateScope,) -> Result<crate::domain::models::CalendarEvent, CalendarMutationError> {- self.updated.lock().unwrap().push((event_id, patch));+ self.updated.lock().unwrap().push((event_id, patch, scope));Ok(sample_event(Vec::new()))}@@ -343,6 +344,8 @@ async fn update_converts_input_into_a_domain_patch() {let tool = UpdateCalendarEvent {event_id,+ scope: UpdateScopeInput::All,+ recurrence_id: None,title: Some("Renamed".to_string()),description: Some(String::new()),location: None,@@ -357,8 +360,9 @@ async fn update_converts_input_into_a_domain_patch() {tool.call(context, request_context()).await.unwrap();let updated = mutations.updated.lock().unwrap();- let (patched_id, patch) = updated.first().expect("one update call");+ let (patched_id, patch, scope) = updated.first().expect("one update call");assert_eq!(*patched_id, event_id);+ assert_eq!(*scope, CalendarUpdateScope::All);assert_eq!(patch.title.as_deref(), Some("Renamed"));assert_eq!(patch.description.as_deref(), Some(""));assert_eq!(patch.location, None);@@ -369,6 +373,84 @@ async fn update_converts_input_into_a_domain_patch() {assert_eq!(patch.conference, Some(ConferenceChange::Removed));}+#[tokio::test]+async fn update_passes_the_selected_occurrence_scope() {+ let (mutations, context) = context(MockMutations::default(), empty_occurrences());+ let event_id = Uuid::from_u128(11);++ let tool = UpdateCalendarEvent {+ event_id,+ scope: UpdateScopeInput::ThisEvent,+ recurrence_id: Some("2026-08-18T20:00:00+00:00".to_string()),+ title: None,+ description: None,+ location: None,+ time: Some(EventTimeInput::Timed {+ starts_at: Utc.with_ymd_and_hms(2026, 8, 18, 20, 0, 0).unwrap(),+ ends_at: Utc.with_ymd_and_hms(2026, 8, 18, 22, 0, 0).unwrap(),+ time_zone: None,+ }),+ attendees: None,+ recurrence_lines: None,+ conference: None,+ };+ tool.call(context, request_context()).await.unwrap();++ let updated = mutations.updated.lock().unwrap();+ let (_, _, scope) = updated.first().expect("one update call");+ assert_eq!(+ *scope,+ CalendarUpdateScope::ThisEvent {+ recurrence_id: "2026-08-18T20:00:00+00:00".to_string(),+ }+ );+}++#[tokio::test]+async fn scoped_update_requires_a_recurrence_id() {+ let (mutations, context) = context(MockMutations::default(), empty_occurrences());++ let tool = UpdateCalendarEvent {+ event_id: Uuid::from_u128(11),+ scope: UpdateScopeInput::ThisEvent,+ recurrence_id: None,+ title: Some("Renamed".to_string()),+ description: None,+ location: None,+ time: None,+ attendees: None,+ recurrence_lines: None,+ conference: None,+ };+ let error = tool.call(context, request_context()).await.unwrap_err();+ assert!(error.description.contains("recurrenceId"));+ assert!(mutations.updated.lock().unwrap().is_empty());+}++/// A series-wide update carrying an occurrence key is contradictory input;+/// silently dropping the key would apply a one-occurrence intent to the+/// whole series — the exact failure scoping exists to prevent.+#[tokio::test]+async fn series_update_rejects_a_stray_recurrence_id() {+ let (mutations, context) = context(MockMutations::default(), empty_occurrences());++ let tool = UpdateCalendarEvent {+ event_id: Uuid::from_u128(11),+ scope: UpdateScopeInput::All,+ recurrence_id: Some("2026-08-18T20:00:00+00:00".to_string()),+ title: Some("Renamed".to_string()),+ description: None,+ location: None,+ time: None,+ attendees: None,+ recurrence_lines: None,+ conference: None,+ };+ let error = tool.call(context, request_context()).await.unwrap_err();+ assert!(error.description.contains("this_event"));+ assert!(mutations.updated.lock().unwrap().is_empty());+}+#[tokio::test]async fn scoped_deletion_requires_a_recurrence_id() {let (mutations, context) = context(MockMutations::default(), empty_occurrences());diff --git a/crates/calendar_events/src/inbound/toolset/update_calendar_event.rs b/crates/calendar_events/src/inbound/toolset/update_calendar_event.rsindex 35658dc043..49d1d1afb7 100644--- a/crates/calendar_events/src/inbound/toolset/update_calendar_event.rs+++ b/crates/calendar_events/src/inbound/toolset/update_calendar_event.rs@@ -1,9 +1,11 @@//! UpdateCalendarEvent tool for editing existing calendar events.use ai_toolset::{- AsyncTool, RequestContext, ServiceContext, ToolAnnotated, ToolAnnotations, ToolResult,+ AsyncTool, RequestContext, ServiceContext, ToolAnnotated, ToolAnnotations, ToolCallError,+ ToolResult,};use async_trait::async_trait;+use rootcause::compat::boxed_error::IntoBoxedError;use schemars::JsonSchema;use serde::Deserialize;@@ -12,7 +14,7 @@ use super::{};use crate::domain::{models::{CalendarEventPatch, ConferenceChange},- ports::{CalendarMutationService, CalendarOccurrenceService},+ ports::{CalendarMutationService, CalendarOccurrenceService, CalendarUpdateScope},};/// A requested change to an event's video conference.@@ -34,6 +36,16 @@ impl From<ConferenceChangeInput> for ConferenceChange {}}+/// How much of a recurring series an update applies to.+#[derive(Debug, Deserialize, JsonSchema, Clone, Copy, PartialEq, Eq)]+#[serde(rename_all = "snake_case")]+pub enum UpdateScopeInput {+ /// The entire event or series.+ All,+ /// One occurrence of a recurring series.+ ThisEvent,+}+/// Update fields of a calendar event.#[derive(Debug, Deserialize, JsonSchema, Clone)]#[serde(rename_all = "camelCase")]@@ -45,16 +57,40 @@ their current values. The change is written to Google immediately and attendeesnotified of it, so confirm details with the user first. Get the `eventId` from \ListCalendarEvents.\n\\n\+`scope` picks how much of a recurring series changes and is always required: \+\"this_event\" edits one occurrence (pass the occurrence's `recurrenceId` from \+ListCalendarEvents) and leaves the rest of the series alone; \"all\" edits the series \+itself — with `time` that MOVES EVERY OCCURRENCE, so never use \"all\" to reschedule a \+single occurrence. Non-recurring events use \"all\". There is no this-and-following \+update: end the series with DeleteCalendarEvent's \"this_and_following\" and create a new \+event instead.\n\+\n\Passing `attendees` replaces the full attendee list — include everyone who should remain, \-not just additions. An empty string for `description` or `location` clears it. Updating a \-recurring event changes the whole series. Fails on events from calendars the user cannot \-edit."+not just additions. An empty string for `description` or `location` clears it. Fails on \+events from calendars the user cannot edit.")]pub struct UpdateCalendarEvent {/// Event to update.#[schemars(description = "The event's id, from ListCalendarEvents or CreateCalendarEvent.")]pub event_id: uuid::Uuid,+ /// Update scope.+ #[schemars(+ description = "How much of a recurring series to change: \"this_event\" edits one \+ occurrence (requires `recurrenceId`), \"all\" edits the whole event or \+ series. Non-recurring events use \"all\"."+ )]+ pub scope: UpdateScopeInput,++ /// Occurrence key for occurrence-scoped updates.+ #[schemars(+ description = "The `recurrenceId` of the targeted occurrence, from its \+ ListCalendarEvents entry. Required for \"this_event\"; omit for \+ \"all\"."+ )]+ #[serde(default)]+ pub recurrence_id: Option<String>,+/// Replacement title.#[schemars(description = "Replacement title. Omit to keep the current title.")]#[serde(default)]@@ -96,7 +132,8 @@ pub struct UpdateCalendarEvent {/// Replacement recurrence properties.#[schemars(description = "Replacement RFC 5545 recurrence lines. An empty list makes the event \- one-off; omit to keep the current recurrence."+ one-off; omit to keep the current recurrence. Only valid with scope \+ \"all\".")]#[serde(default)]pub recurrence_lines: Option<Vec<String>>,@@ -131,11 +168,42 @@ where) -> ToolResult<Self::Output> {tracing::info!(event_id=%self.event_id,+ scope=?self.scope,attendee_count=?self.attendees.as_ref().map(Vec::len),"Update calendar event");let requester_id = request_context.user_id.to_string();+ let scope = match (self.scope, self.recurrence_id.clone()) {+ (UpdateScopeInput::All, None) => CalendarUpdateScope::All,+ (UpdateScopeInput::ThisEvent, Some(recurrence_id)) => {+ CalendarUpdateScope::ThisEvent { recurrence_id }+ }+ (UpdateScopeInput::ThisEvent, None) => {+ return Err(ToolCallError {+ description: "A this_event update requires `recurrenceId` — use the \+ occurrence's `recurrenceId` from ListCalendarEvents."+ .to_string(),+ internal_error: anyhow::Error::from_boxed(+ rootcause::report!("scoped update without recurrenceId").into_boxed_error(),+ ),+ });+ }+ // Dropping the key would silently widen a one-occurrence intent+ // to the whole series — exactly the mistake scoping exists to+ // prevent — so make the caller restate what it wants.+ (UpdateScopeInput::All, Some(_)) => {+ return Err(ToolCallError {+ description: "`recurrenceId` only applies to scope \"this_event\". Pass \+ scope \"this_event\" to change that occurrence, or drop \+ `recurrenceId` to change the whole series."+ .to_string(),+ internal_error: anyhow::Error::from_boxed(+ rootcause::report!("series update with a recurrenceId").into_boxed_error(),+ ),+ });+ }+ };let patch = CalendarEventPatch {title: self.title.clone(),description: self.description.clone(),@@ -154,7 +222,7 @@ wherelet event = service_context.mutations- .update_event(&requester_id, self.event_id, patch)+ .update_event(&requester_id, self.event_id, patch, scope).await.map_err(|error| mutation_tool_error("update the calendar event", error))?;diff --git a/crates/calendar_events/src/outbound/email_service_mutations.rs b/crates/calendar_events/src/outbound/email_service_mutations.rsindex 069a2ce391..2d4e250f21 100644--- a/crates/calendar_events/src/outbound/email_service_mutations.rs+++ b/crates/calendar_events/src/outbound/email_service_mutations.rs@@ -21,6 +21,7 @@ use crate::domain::{},ports::{CalendarDeletionScope, CalendarMutationError, CalendarMutationService, CalendarRsvpScope,+ CalendarUpdateScope,},};@@ -123,6 +124,7 @@ fn error_from_response(status: StatusCode, body: Option<String>) -> CalendarMuta};match error.code.as_str() {"not_found" => CalendarMutationError::NotFound,+ "occurrence_not_found" => CalendarMutationError::OccurrenceNotFound,"read_only" => CalendarMutationError::ReadOnly,"no_writable_calendar" => CalendarMutationError::NoWritableCalendar,"not_attendee" => CalendarMutationError::NotAttendee,@@ -173,7 +175,13 @@ fn create_body(}/// Wire body for an event patch, matching `UpdateCalendarEventRequest`.-fn update_body(patch: &CalendarEventPatch) -> serde_json::Value {+fn update_body(patch: &CalendarEventPatch, scope: &CalendarUpdateScope) -> serde_json::Value {+ let (scope_name, recurrence_id) = match scope {+ CalendarUpdateScope::All => ("all", None),+ CalendarUpdateScope::ThisEvent { recurrence_id } => {+ ("this_event", Some(recurrence_id.as_str()))+ }+ };serde_json::json!({"title": patch.title,"description": patch.description,@@ -188,6 +196,8 @@ fn update_body(patch: &CalendarEventPatch) -> serde_json::Value {"transparency": patch.transparency,"reminders": patch.reminders,"conference": patch.conference,+ "scope": scope_name,+ "recurrenceId": recurrence_id,})}@@ -274,6 +284,7 @@ impl CalendarMutationService for EmailServiceCalendarMutations {requester_id: &str,event_id: Uuid,patch: CalendarEventPatch,+ scope: CalendarUpdateScope,) -> Result<CalendarEvent, CalendarMutationError> {self.event_from(self.request(@@ -281,7 +292,7 @@ impl CalendarMutationService for EmailServiceCalendarMutations {&format!("/calendar/events/{event_id}"),requester_id,)- .json(&update_body(&patch)),+ .json(&update_body(&patch, &scope)),).await}diff --git a/crates/calendar_events/src/outbound/email_service_mutations/test.rs b/crates/calendar_events/src/outbound/email_service_mutations/test.rsindex 7c97b47c5c..749e23591a 100644--- a/crates/calendar_events/src/outbound/email_service_mutations/test.rs+++ b/crates/calendar_events/src/outbound/email_service_mutations/test.rs@@ -9,8 +9,8 @@ use uuid::Uuid;use super::*;use crate::domain::models::{CalendarAttendeeInput, EventReminders, EventTime};use crate::inbound::mutation_router::{- CalendarMutationApiError, CreateCalendarEventRequest, DeleteCalendarEventQuery,- RsvpCalendarEventRequest, UpdateCalendarEventRequest,+ CalendarMutationApiError, CalendarUpdateScopeParam, CreateCalendarEventRequest,+ DeleteCalendarEventQuery, RsvpCalendarEventRequest, UpdateCalendarEventRequest,};fn sample_draft() -> CalendarEventDraft {@@ -68,7 +68,8 @@ fn update_body_matches_the_router_request() {conference: Some(crate::domain::models::ConferenceChange::Removed),..Default::default()};- let request: UpdateCalendarEventRequest = serde_json::from_value(update_body(&patch)).unwrap();+ let request: UpdateCalendarEventRequest =+ serde_json::from_value(update_body(&patch, &CalendarUpdateScope::All)).unwrap();assert_eq!(request.title.as_deref(), Some("Renamed"));assert_eq!(request.description.as_deref(), Some(""));@@ -80,6 +81,34 @@ fn update_body_matches_the_router_request() {request.conference,Some(crate::domain::models::ConferenceChange::Removed));+ assert!(matches!(request.scope, Some(CalendarUpdateScopeParam::All)));+ assert!(request.recurrence_id.is_none());+}++/// An occurrence-scoped update must arrive at the router still scoped — a+/// body the router reads as scope-less would widen the write to the series.+#[test]+fn update_body_carries_the_occurrence_scope() {+ let patch = CalendarEventPatch {+ title: Some("Renamed".to_string()),+ ..Default::default()+ };+ let request: UpdateCalendarEventRequest = serde_json::from_value(update_body(+ &patch,+ &CalendarUpdateScope::ThisEvent {+ recurrence_id: "2026-08-18T20:00:00+00:00".to_string(),+ },+ ))+ .unwrap();++ assert_eq!(+ request.recurrence_id.as_deref(),+ Some("2026-08-18T20:00:00+00:00")+ );+ assert!(matches!(+ request.scope,+ Some(CalendarUpdateScopeParam::ThisEvent)+ ));}#[test]@@ -127,6 +156,7 @@ fn rsvp_body_matches_the_router_request() {fn router_error_bodies_round_trip_to_their_domain_failures() {let cases = [CalendarMutationError::NotFound,+ CalendarMutationError::OccurrenceNotFound,CalendarMutationError::ReadOnly,CalendarMutationError::NoWritableCalendar,CalendarMutationError::NotAttendee,diff --git a/crates/calendar_events/src/outbound/google.rs b/crates/calendar_events/src/outbound/google.rsindex 20609921f9..0eaf73e71c 100644--- a/crates/calendar_events/src/outbound/google.rs+++ b/crates/calendar_events/src/outbound/google.rs@@ -20,8 +20,8 @@ use crate::domain::{},ports::{CalendarRsvpScope, GoogleCalendarMutationProvider, GoogleCalendarProvider,- GoogleEventSyncContext, GoogleProviderError, GoogleProviderErrorKind, GoogleRsvpOutcome,- GoogleSeriesMutationOutcome,+ GoogleEventSyncContext, GoogleInstanceUpdateOutcome, GoogleProviderError,+ GoogleProviderErrorKind, GoogleRsvpOutcome, GoogleSeriesMutationOutcome,},};@@ -961,6 +961,66 @@ impl<G: GoogleRequestGate> GoogleCalendarMutationProvider for GoogleCalendarClieself.mutation_readback(access_token, target, updated).await}+ #[tracing::instrument(+ skip(self, access_token, target, patch),+ fields(provider_calendar_id = %target.provider_calendar_id),+ err+ )]+ async fn update_event_instance(+ &self,+ access_token: &str,+ target: &GoogleCalendarTarget,+ master_provider_event_id: &str,+ original_start: &str,+ patch: &CalendarEventPatch,+ ) -> Result<GoogleInstanceUpdateOutcome, GoogleProviderError> {+ let refresh_without_writing = |gone_reason: &'static str| async move {+ tracing::info!(gone_reason, "occurrence-scoped update found no occurrence");+ match self+ .refresh_series(access_token, target, master_provider_event_id, None)+ .await?+ {+ SeriesOutcome::Refreshed(upsert) => {+ Ok(GoogleInstanceUpdateOutcome::OccurrenceGone(upsert))+ }+ SeriesOutcome::Gone => Ok(GoogleInstanceUpdateOutcome::SeriesGone),+ SeriesOutcome::Malformed => Err(GoogleProviderError::new(+ GoogleProviderErrorKind::Permanent,+ "Google Calendar returned a malformed series after the mutation",+ )),+ }+ };+ let Some(instance_id) = self+ .instance_id_at(+ access_token,+ target,+ master_provider_event_id,+ original_start,+ )+ .await?+ else {+ return refresh_without_writing("no instance matches the occurrence key").await;+ };+ if self+ .patch_event_raw(access_token, target, &instance_id, patch_body(patch))+ .await?+ .is_none()+ {+ return refresh_without_writing("the instance vanished before the patch").await;+ }+ match self+ .series_outcome(access_token, target, master_provider_event_id)+ .await?+ {+ GoogleSeriesMutationOutcome::Applied(upsert) => {+ Ok(GoogleInstanceUpdateOutcome::Applied(upsert))+ }+ GoogleSeriesMutationOutcome::SeriesDeleted | GoogleSeriesMutationOutcome::Gone => {+ Ok(GoogleInstanceUpdateOutcome::SeriesGone)+ }+ }+ }+#[tracing::instrument(skip(self, access_token, target),fields(provider_calendar_id = %target.provider_calendar_id),diff --git a/crates/calendar_events/src/outbound/google/test.rs b/crates/calendar_events/src/outbound/google/test.rsindex 150dddd9b9..d0946ebc3d 100644--- a/crates/calendar_events/src/outbound/google/test.rs+++ b/crates/calendar_events/src/outbound/google/test.rs@@ -678,6 +678,43 @@ fn mutation_bodies_serialize_reminders_in_google_shape() {);}+/// The provider write for a patch must carry exactly the supplied fields:+/// a stray key overwrites provider state the user never asked to change —+/// a time-only patch that also wrote `recurrence` or `summary` would mangle+/// a recurring series' rules or revert its title.+#[test]+fn patch_bodies_carry_only_the_supplied_fields() {+ let time_only = patch_body(&CalendarEventPatch {+ time: Some(EventTime::Timed {+ starts_at: DateTime::parse_from_rfc3339("2026-08-18T20:00:00Z")+ .unwrap()+ .with_timezone(&Utc),+ ends_at: DateTime::parse_from_rfc3339("2026-08-18T22:00:00Z")+ .unwrap()+ .with_timezone(&Utc),+ time_zone: None,+ }),+ ..CalendarEventPatch::default()+ });+ let mut keys: Vec<_> = time_only.as_object().unwrap().keys().cloned().collect();+ keys.sort();+ assert_eq!(keys, ["end", "start"]);++ let title_only = patch_body(&CalendarEventPatch {+ title: Some("Renamed".to_string()),+ ..CalendarEventPatch::default()+ });+ let keys: Vec<_> = title_only.as_object().unwrap().keys().cloned().collect();+ assert_eq!(keys, ["summary"]);++ assert!(+ patch_body(&CalendarEventPatch::default())+ .as_object()+ .unwrap()+ .is_empty()+ );+}+#[test]fn attaching_a_meet_asks_google_to_generate_one() {let body = patch_body(&CalendarEventPatch {diff --git a/packages/sdk/generated/email/index.ts b/packages/sdk/generated/email/index.tsindex e7b1964acf..03b2d2c99c 100644--- a/packages/sdk/generated/email/index.ts+++ b/packages/sdk/generated/email/index.ts@@ -1,4 +1,4 @@// This file is auto-generated by @hey-api/openapi-tsexport { type Options, Sdk } from './sdk.gen';-export type { AccessLevel, AddDraftAttachmentData, AddDraftAttachmentError, AddDraftAttachmentErrors, AddDraftAttachmentRequest, AddDraftAttachmentResponse, AddDraftAttachmentResponse2, AddDraftAttachmentResponses, AddForwardedAttachmentData, AddForwardedAttachmentError, AddForwardedAttachmentErrors, AddForwardedAttachmentRequest, AddForwardedAttachmentResponse, AddForwardedAttachmentResponse2, AddForwardedAttachmentResponses, AddRemoveLabelData, AddRemoveLabelError, AddRemoveLabelErrors, AddRemoveLabelResponse, AddRemoveLabelResponses, AddRemoveThreadLabelData, AddRemoveThreadLabelError, AddRemoveThreadLabelErrors, AddRemoveThreadLabelResponse, AddRemoveThreadLabelResponses, ApiAttachment, ApiAttachmentDraft, ApiAttachmentForwarded, ApiContact, ApiContactInfo, ApiDraftContactInfo, ApiDraftInput, ApiDraftOutput, ApiEmailFilter, ApiLabel, ApiLabelListVisibility, ApiLabelType, ApiMessage, ApiMessageAttachment, ApiMessageLabel, ApiMessageListVisibility, ApiPaginatedThreadCursor, ApiSortMethod, ApiThread, ApiThreadPreviewCursor, ApiThreadPreviewCursorInner, ArchiveThreadData, ArchiveThreadError, ArchiveThreadErrors, ArchiveThreadRequest, ArchiveThreadResponse, ArchiveThreadResponses, Attachment, AttachmentDraft, AttachmentForwarded, AttendeeResponseStatus, BackfillJob, BackfillJobStatus, BackfillStatus, BlockSenderData, BlockSenderError, BlockSenderErrors, BlockSenderRequest, BlockSenderResponses, CalendarAttendee, CalendarAttendeeInputBody, CalendarDeletionScopeParam, CalendarEvent, CalendarMutationApiError, CalendarMutationErrorCode, CalendarRsvpScopeParam, CancelBackfillGmailData, CancelBackfillGmailError, CancelBackfillGmailErrors, CancelBackfillGmailResponse, CancelBackfillGmailResponses, CancelBackfillParams, ClientOptions, ConferenceChange, ConferenceProvider, Contact, ContactInfo, ContactInfoLegacy, ContactInfoWithInteraction, CreateCalendarEventData, CreateCalendarEventError, CreateCalendarEventErrors, CreateCalendarEventRequest, CreateCalendarEventResponse, CreateCalendarEventResponses, CreateDraftData, CreateDraftError, CreateDraftErrors, CreateDraftRequest, CreateDraftResponse, CreateDraftResponse2, CreateDraftResponses, CreateLabelData, CreateLabelError, CreateLabelErrors, CreateLabelRequest, CreateLabelResponse, CreateLabelResponse2, CreateLabelResponses, DeleteCalendarEventData, DeleteCalendarEventError, DeleteCalendarEventErrors, DeleteCalendarEventResponse, DeleteCalendarEventResponses, DeleteDraftData, DeleteDraftError, DeleteDraftErrors, DeleteDraftResponse, DeleteDraftResponses, DeleteEmailFilterData, DeleteEmailFilterError, DeleteEmailFilterErrors, DeleteEmailFilterResponse, DeleteEmailFilterResponses, DeleteLabelData, DeleteLabelError, DeleteLabelErrors, DeleteLabelResponse, DeleteLabelResponses, DeleteLinkData, DeleteLinkError, DeleteLinkErrors, DeleteLinkResponse, DeleteLinkResponses, DeleteScheduledDraftData, DeleteScheduledDraftError, DeleteScheduledDraftErrors, DeleteScheduledDraftResponse, DeleteScheduledDraftResponses, DisableLinkCalendarData, DisableLinkCalendarError, DisableLinkCalendarErrors, DisableLinkCalendarResponse, DisableLinkCalendarResponses, DisableSyncData, DisableSyncError, DisableSyncErrors, DisableSyncResponse, DisableSyncResponses, EmptyResponse, ErrorResponse, EventReminderOverride, EventReminders, EventStatus, EventTime, EventTransparency, EventVisibility, GetActiveBackfillJobResponse, GetAttachmentData, GetAttachmentDocumentIdData, GetAttachmentDocumentIdError, GetAttachmentDocumentIdErrors, GetAttachmentDocumentIdResponse, GetAttachmentDocumentIdResponse2, GetAttachmentDocumentIdResponses, GetAttachmentError, GetAttachmentErrors, GetAttachmentResponse, GetAttachmentResponse2, GetAttachmentResponses, GetBackfillGmailActiveData, GetBackfillGmailActiveError, GetBackfillGmailActiveErrors, GetBackfillGmailActiveResponse, GetBackfillGmailActiveResponses, GetBackfillGmailData, GetBackfillGmailError, GetBackfillGmailErrors, GetBackfillGmailResponse, GetBackfillGmailResponses, GetBackfillJobResponse, GetMessageData, GetMessageError, GetMessageErrors, GetMessageResponse, GetMessageResponses, GetMessagesBatchData, GetMessagesBatchError, GetMessagesBatchErrors, GetMessagesBatchResponse, GetMessagesBatchResponses, GetPreviewsCursorParams, GetScheduledMessagesData, GetScheduledMessagesError, GetScheduledMessagesErrors, GetScheduledMessagesResponse, GetScheduledMessagesResponses, GetScheduledResponse, GetThreadData, GetThreadError, GetThreadErrors, GetThreadMessagesHandlerData, GetThreadMessagesHandlerError, GetThreadMessagesHandlerErrors, GetThreadMessagesHandlerResponse, GetThreadMessagesHandlerResponses, GetThreadResponse, GetThreadResponse2, GetThreadResponses, HealthCheckLinksData, HealthCheckLinksError, HealthCheckLinksErrors, HealthCheckLinksResponse, HealthCheckLinksResponses, HealthHandlerData, HealthHandlerResponse, HealthHandlerResponses, InitErrorCodeResponse, InitResponse, InitUserData, InitUserError, InitUserErrors, InitUserResponse, InitUserResponses, Label, LabelInfo, LabelListVisibility, LabelType, Link, ListBackfillGmailData, ListBackfillGmailError, ListBackfillGmailErrors, ListBackfillGmailResponse, ListBackfillGmailResponses, ListBackfillJobsResponse, ListBlockedResponse, ListBlockedSendersData, ListBlockedSendersError, ListBlockedSendersErrors, ListBlockedSendersResponse, ListBlockedSendersResponses, ListCalendarsData, ListCalendarsError, ListCalendarsErrors, ListCalendarsResponse, ListCalendarsResponse2, ListCalendarsResponses, ListContactsData, ListContactsError, ListContactsErrors, ListContactsResponse, ListContactsResponse2, ListContactsResponses, ListEmailFiltersData, ListEmailFiltersError, ListEmailFiltersErrors, ListEmailFiltersResponse, ListEmailFiltersResponse2, ListEmailFiltersResponses, ListLabelsData, ListLabelsError, ListLabelsErrors, ListLabelsResponse, ListLabelsResponse2, ListLabelsResponses, ListLinksData, ListLinksError, ListLinksErrors, ListLinksResponse, ListLinksResponse2, ListLinksResponses, Message, MessageListVisibility, ParsedMessage, PatchSettingsData, PatchSettingsError, PatchSettingsErrors, PatchSettingsRequest, PatchSettingsResponse, PatchSettingsResponse2, PatchSettingsResponses, PreviewsInboxCursorData, PreviewsInboxCursorError, PreviewsInboxCursorErrors, PreviewsInboxCursorResponse, PreviewsInboxCursorResponses, PreviewView, PreviewViewStandardLabel, RefreshCalendarEvent, RefreshEmailEvent, RemoveDraftAttachmentData, RemoveDraftAttachmentError, RemoveDraftAttachmentErrors, RemoveDraftAttachmentResponse, RemoveDraftAttachmentResponses, RemoveForwardedAttachmentData, RemoveForwardedAttachmentError, RemoveForwardedAttachmentErrors, RemoveForwardedAttachmentResponse, RemoveForwardedAttachmentResponses, ResyncLinkData, ResyncLinkError, ResyncLinkErrors, ResyncLinkResponse, ResyncLinkResponses, ResyncResponse, RsvpCalendarEventData, RsvpCalendarEventError, RsvpCalendarEventErrors, RsvpCalendarEventRequest, RsvpCalendarEventResponse, RsvpCalendarEventResponses, SendMessageData, SendMessageError, SendMessageErrors, SendMessageRequest, SendMessageResponse, SendMessageResponse2, SendMessageResponses, Settings, SharedInboxConflictResponse, SyncStatus, Thread, ThreadList, ThreadPreviewCursor, ThreadSeenData, ThreadSeenError, ThreadSeenErrors, ThreadSeenResponse, ThreadSeenResponses, ThreadSummary, UnblockSenderData, UnblockSenderError, UnblockSenderErrors, UnblockSenderRequest, UnblockSenderResponse, UnblockSenderResponses, UnresolvedSignatureImagesError, UpdateCalendarEventData, UpdateCalendarEventError, UpdateCalendarEventErrors, UpdateCalendarEventRequest, UpdateCalendarEventResponse, UpdateCalendarEventResponses, UpdateLabelBatchRequest, UpdateLabelBatchResponse, UpdateThreadLabelRequest, UpdateThreadLabelsResponse, UpdateThreadProjectData, UpdateThreadProjectError, UpdateThreadProjectErrors, UpdateThreadProjectRequest, UpdateThreadProjectResponse, UpdateThreadProjectResponse2, UpdateThreadProjectResponses, UpsertEmailFilterData, UpsertEmailFilterError, UpsertEmailFilterErrors, UpsertEmailFilterRequest, UpsertEmailFilterResponse, UpsertEmailFilterResponse2, UpsertEmailFilterResponses, UpsertScheduledMessageData, UpsertScheduledMessageError, UpsertScheduledMessageErrors, UpsertScheduledMessageResponse, UpsertScheduledMessageResponses, UpsertScheduledRequest, UpsertScheduledResponse, UserProvider, Value, VisibleCalendar } from './types.gen';+export type { AccessLevel, AddDraftAttachmentData, AddDraftAttachmentError, AddDraftAttachmentErrors, AddDraftAttachmentRequest, AddDraftAttachmentResponse, AddDraftAttachmentResponse2, AddDraftAttachmentResponses, AddForwardedAttachmentData, AddForwardedAttachmentError, AddForwardedAttachmentErrors, AddForwardedAttachmentRequest, AddForwardedAttachmentResponse, AddForwardedAttachmentResponse2, AddForwardedAttachmentResponses, AddRemoveLabelData, AddRemoveLabelError, AddRemoveLabelErrors, AddRemoveLabelResponse, AddRemoveLabelResponses, AddRemoveThreadLabelData, AddRemoveThreadLabelError, AddRemoveThreadLabelErrors, AddRemoveThreadLabelResponse, AddRemoveThreadLabelResponses, ApiAttachment, ApiAttachmentDraft, ApiAttachmentForwarded, ApiContact, ApiContactInfo, ApiDraftContactInfo, ApiDraftInput, ApiDraftOutput, ApiEmailFilter, ApiLabel, ApiLabelListVisibility, ApiLabelType, ApiMessage, ApiMessageAttachment, ApiMessageLabel, ApiMessageListVisibility, ApiPaginatedThreadCursor, ApiSortMethod, ApiThread, ApiThreadPreviewCursor, ApiThreadPreviewCursorInner, ArchiveThreadData, ArchiveThreadError, ArchiveThreadErrors, ArchiveThreadRequest, ArchiveThreadResponse, ArchiveThreadResponses, Attachment, AttachmentDraft, AttachmentForwarded, AttendeeResponseStatus, BackfillJob, BackfillJobStatus, BackfillStatus, BlockSenderData, BlockSenderError, BlockSenderErrors, BlockSenderRequest, BlockSenderResponses, CalendarAttendee, CalendarAttendeeInputBody, CalendarDeletionScopeParam, CalendarEvent, CalendarMutationApiError, CalendarMutationErrorCode, CalendarRsvpScopeParam, CalendarUpdateScopeParam, CancelBackfillGmailData, CancelBackfillGmailError, CancelBackfillGmailErrors, CancelBackfillGmailResponse, CancelBackfillGmailResponses, CancelBackfillParams, ClientOptions, ConferenceChange, ConferenceProvider, Contact, ContactInfo, ContactInfoLegacy, ContactInfoWithInteraction, CreateCalendarEventData, CreateCalendarEventError, CreateCalendarEventErrors, CreateCalendarEventRequest, CreateCalendarEventResponse, CreateCalendarEventResponses, CreateDraftData, CreateDraftError, CreateDraftErrors, CreateDraftRequest, CreateDraftResponse, CreateDraftResponse2, CreateDraftResponses, CreateLabelData, CreateLabelError, CreateLabelErrors, CreateLabelRequest, CreateLabelResponse, CreateLabelResponse2, CreateLabelResponses, DeleteCalendarEventData, DeleteCalendarEventError, DeleteCalendarEventErrors, DeleteCalendarEventResponse, DeleteCalendarEventResponses, DeleteDraftData, DeleteDraftError, DeleteDraftErrors, DeleteDraftResponse, DeleteDraftResponses, DeleteEmailFilterData, DeleteEmailFilterError, DeleteEmailFilterErrors, DeleteEmailFilterResponse, DeleteEmailFilterResponses, DeleteLabelData, DeleteLabelError, DeleteLabelErrors, DeleteLabelResponse, DeleteLabelResponses, DeleteLinkData, DeleteLinkError, DeleteLinkErrors, DeleteLinkResponse, DeleteLinkResponses, DeleteScheduledDraftData, DeleteScheduledDraftError, DeleteScheduledDraftErrors, DeleteScheduledDraftResponse, DeleteScheduledDraftResponses, DisableLinkCalendarData, DisableLinkCalendarError, DisableLinkCalendarErrors, DisableLinkCalendarResponse, DisableLinkCalendarResponses, DisableSyncData, DisableSyncError, DisableSyncErrors, DisableSyncResponse, DisableSyncResponses, EmptyResponse, ErrorResponse, EventReminderOverride, EventReminders, EventStatus, EventTime, EventTransparency, EventVisibility, GetActiveBackfillJobResponse, GetAttachmentData, GetAttachmentDocumentIdData, GetAttachmentDocumentIdError, GetAttachmentDocumentIdErrors, GetAttachmentDocumentIdResponse, GetAttachmentDocumentIdResponse2, GetAttachmentDocumentIdResponses, GetAttachmentError, GetAttachmentErrors, GetAttachmentResponse, GetAttachmentResponse2, GetAttachmentResponses, GetBackfillGmailActiveData, GetBackfillGmailActiveError, GetBackfillGmailActiveErrors, GetBackfillGmailActiveResponse, GetBackfillGmailActiveResponses, GetBackfillGmailData, GetBackfillGmailError, GetBackfillGmailErrors, GetBackfillGmailResponse, GetBackfillGmailResponses, GetBackfillJobResponse, GetMessageData, GetMessageError, GetMessageErrors, GetMessageResponse, GetMessageResponses, GetMessagesBatchData, GetMessagesBatchError, GetMessagesBatchErrors, GetMessagesBatchResponse, GetMessagesBatchResponses, GetPreviewsCursorParams, GetScheduledMessagesData, GetScheduledMessagesError, GetScheduledMessagesErrors, GetScheduledMessagesResponse, GetScheduledMessagesResponses, GetScheduledResponse, GetThreadData, GetThreadError, GetThreadErrors, GetThreadMessagesHandlerData, GetThreadMessagesHandlerError, GetThreadMessagesHandlerErrors, GetThreadMessagesHandlerResponse, GetThreadMessagesHandlerResponses, GetThreadResponse, GetThreadResponse2, GetThreadResponses, HealthCheckLinksData, HealthCheckLinksError, HealthCheckLinksErrors, HealthCheckLinksResponse, HealthCheckLinksResponses, HealthHandlerData, HealthHandlerResponse, HealthHandlerResponses, InitErrorCodeResponse, InitResponse, InitUserData, InitUserError, InitUserErrors, InitUserResponse, InitUserResponses, Label, LabelInfo, LabelListVisibility, LabelType, Link, ListBackfillGmailData, ListBackfillGmailError, ListBackfillGmailErrors, ListBackfillGmailResponse, ListBackfillGmailResponses, ListBackfillJobsResponse, ListBlockedResponse, ListBlockedSendersData, ListBlockedSendersError, ListBlockedSendersErrors, ListBlockedSendersResponse, ListBlockedSendersResponses, ListCalendarsData, ListCalendarsError, ListCalendarsErrors, ListCalendarsResponse, ListCalendarsResponse2, ListCalendarsResponses, ListContactsData, ListContactsError, ListContactsErrors, ListContactsResponse, ListContactsResponse2, ListContactsResponses, ListEmailFiltersData, ListEmailFiltersError, ListEmailFiltersErrors, ListEmailFiltersResponse, ListEmailFiltersResponse2, ListEmailFiltersResponses, ListLabelsData, ListLabelsError, ListLabelsErrors, ListLabelsResponse, ListLabelsResponse2, ListLabelsResponses, ListLinksData, ListLinksError, ListLinksErrors, ListLinksResponse, ListLinksResponse2, ListLinksResponses, Message, MessageListVisibility, ParsedMessage, PatchSettingsData, PatchSettingsError, PatchSettingsErrors, PatchSettingsRequest, PatchSettingsResponse, PatchSettingsResponse2, PatchSettingsResponses, PreviewsInboxCursorData, PreviewsInboxCursorError, PreviewsInboxCursorErrors, PreviewsInboxCursorResponse, PreviewsInboxCursorResponses, PreviewView, PreviewViewStandardLabel, RefreshCalendarEvent, RefreshEmailEvent, RemoveDraftAttachmentData, RemoveDraftAttachmentError, RemoveDraftAttachmentErrors, RemoveDraftAttachmentResponse, RemoveDraftAttachmentResponses, RemoveForwardedAttachmentData, RemoveForwardedAttachmentError, RemoveForwardedAttachmentErrors, RemoveForwardedAttachmentResponse, RemoveForwardedAttachmentResponses, ResyncLinkData, ResyncLinkError, ResyncLinkErrors, ResyncLinkResponse, ResyncLinkResponses, ResyncResponse, RsvpCalendarEventData, RsvpCalendarEventError, RsvpCalendarEventErrors, RsvpCalendarEventRequest, RsvpCalendarEventResponse, RsvpCalendarEventResponses, SendMessageData, SendMessageError, SendMessageErrors, SendMessageRequest, SendMessageResponse, SendMessageResponse2, SendMessageResponses, Settings, SharedInboxConflictResponse, SyncStatus, Thread, ThreadList, ThreadPreviewCursor, ThreadSeenData, ThreadSeenError, ThreadSeenErrors, ThreadSeenResponse, ThreadSeenResponses, ThreadSummary, UnblockSenderData, UnblockSenderError, UnblockSenderErrors, UnblockSenderRequest, UnblockSenderResponse, UnblockSenderResponses, UnresolvedSignatureImagesError, UpdateCalendarEventData, UpdateCalendarEventError, UpdateCalendarEventErrors, UpdateCalendarEventRequest, UpdateCalendarEventResponse, UpdateCalendarEventResponses, UpdateLabelBatchRequest, UpdateLabelBatchResponse, UpdateThreadLabelRequest, UpdateThreadLabelsResponse, UpdateThreadProjectData, UpdateThreadProjectError, UpdateThreadProjectErrors, UpdateThreadProjectRequest, UpdateThreadProjectResponse, UpdateThreadProjectResponse2, UpdateThreadProjectResponses, UpsertEmailFilterData, UpsertEmailFilterError, UpsertEmailFilterErrors, UpsertEmailFilterRequest, UpsertEmailFilterResponse, UpsertEmailFilterResponse2, UpsertEmailFilterResponses, UpsertScheduledMessageData, UpsertScheduledMessageError, UpsertScheduledMessageErrors, UpsertScheduledMessageResponse, UpsertScheduledMessageResponses, UpsertScheduledRequest, UpsertScheduledResponse, UserProvider, Value, VisibleCalendar } from './types.gen';diff --git a/packages/sdk/generated/email/types.gen.ts b/packages/sdk/generated/email/types.gen.tsindex 1b97736b5b..3ede6bade3 100644--- a/packages/sdk/generated/email/types.gen.ts+++ b/packages/sdk/generated/email/types.gen.ts@@ -698,7 +698,7 @@ export type CalendarMutationApiError = {/*** Machine-readable failure category for calendar mutations.*/-export type CalendarMutationErrorCode = 'not_found' | 'read_only' | 'no_writable_calendar' | 'not_attendee' | 'invalid_input' | 'reauth_required' | 'provider_rejected' | 'retryable' | 'persist_failed';+export type CalendarMutationErrorCode = 'not_found' | 'occurrence_not_found' | 'read_only' | 'no_writable_calendar' | 'not_attendee' | 'invalid_input' | 'reauth_required' | 'provider_rejected' | 'retryable' | 'persist_failed';/*** How much of a recurring series an RSVP applies to.@@ -709,6 +709,17 @@ export type CalendarMutationErrorCode = 'not_found' | 'read_only' | 'no_writable*/export type CalendarRsvpScopeParam = 'all' | 'this_event';+/**+ * How much of a recurring series an update applies to.+ *+ * Like RSVPs there is no this-and-following variant: the provider cannot+ * express a forward-scoped edit as one write, and emulating it (truncate+ * the series, insert an edited clone) is non-atomic and re-invites the+ * attendees of the clone. Compose it from a this-and-following deletion+ * and a create when that shape is wanted.+ */+export type CalendarUpdateScopeParam = 'all' | 'this_event';+export type CancelBackfillParams = {job_id: string;};@@ -1434,11 +1445,16 @@ export type UpdateCalendarEventRequest = {* Replacement location; an empty string clears it.*/location?: string | null;+ /**+ * Original-start key of the occurrence the update targets.+ */+ recurrenceId?: string | null;/*** Replacement recurrence properties; an empty list clears them.*/recurrenceLines?: Array<string> | null;reminders?: null | EventReminders;+ scope?: null | CalendarUpdateScopeParam;time?: null | EventTime;/*** Replacement title; an empty string clears it.@@ -1726,7 +1742,7 @@ export type UpdateCalendarEventErrors = {*/403: CalendarMutationApiError;/**- * Event not found+ * Event or targeted occurrence not found*/404: CalendarMutationApiError;/**diff --git a/packages/sdk/specs/email.json b/packages/sdk/specs/email.jsonindex 99c4f64bd3..5a9fd8eb68 100644--- a/packages/sdk/specs/email.json+++ b/packages/sdk/specs/email.json@@ -259,7 +259,7 @@}},"404": {- "description": "Event not found",+ "description": "Event or targeted occurrence not found","content": {"application/json": {"schema": {@@ -4652,6 +4652,7 @@"description": "Machine-readable failure category for calendar mutations.","enum": ["not_found",+ "occurrence_not_found","read_only","no_writable_calendar","not_attendee",@@ -4667,6 +4668,11 @@"description": "How much of a recurring series an RSVP applies to.\n\nUnlike deletion there is no this-and-following variant: the provider\ncannot express a forward-scoped response, so offering one would be a\npromise sync could not keep.","enum": ["all", "this_event"]},+ "CalendarUpdateScopeParam": {+ "type": "string",+ "description": "How much of a recurring series an update applies to.\n\nLike RSVPs there is no this-and-following variant: the provider cannot\nexpress a forward-scoped edit as one write, and emulating it (truncate\nthe series, insert an edited clone) is non-atomic and re-invites the\nattendees of the clone. Compose it from a this-and-following deletion\nand a create when that shape is wanted.",+ "enum": ["all", "this_event"]+ },"CancelBackfillParams": {"type": "object","required": ["job_id"],@@ -6160,6 +6166,10 @@"type": ["string", "null"],"description": "Replacement location; an empty string clears it."},+ "recurrenceId": {+ "type": ["string", "null"],+ "description": "Original-start key of the occurrence the update targets."+ },"recurrenceLines": {"type": ["array", "null"],"items": {@@ -6178,6 +6188,17 @@}]},+ "scope": {+ "oneOf": [+ {+ "type": "null"+ },+ {+ "$ref": "#/components/schemas/CalendarUpdateScopeParam",+ "description": "How much of a recurring series the update covers. Omit to let\n`recurrenceId` decide: the identified occurrence alone when one is\nsupplied, otherwise the whole event or series. An explicit\n`this_event` scope requires `recurrenceId`, so a scoped request is\nnever silently widened to the series."+ }+ ]+ },"time": {"oneOf": [{diff --git a/services/email_service/src/api/swagger.rs b/services/email_service/src/api/swagger.rsindex f4992238f8..dead571262 100644--- a/services/email_service/src/api/swagger.rs+++ b/services/email_service/src/api/swagger.rs@@ -203,6 +203,7 @@ use utoipa::OpenApi;calendar_events::inbound::mutation_router::CalendarMutationApiError,calendar_events::inbound::mutation_router::CalendarMutationErrorCode,calendar_events::inbound::mutation_router::CalendarDeletionScopeParam,+ calendar_events::inbound::mutation_router::CalendarUpdateScopeParam,calendar_events::domain::models::CalendarEvent,calendar_events::domain::models::CalendarAttendee,calendar_events::domain::models::AttendeeResponseStatus,