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): stop guests without modify rights from changing event details (#8557)
gbirman41a2396329cc
diff --git a/.sqlx/query-95334b207fad665ea24c0fb939d2d2e5a07fc60882998c178a8071cad66ee81a.json b/.sqlx/query-95334b207fad665ea24c0fb939d2d2e5a07fc60882998c178a8071cad66ee81a.jsonnew file mode 100644index 0000000000..d953de7497--- /dev/null+++ b/.sqlx/query-95334b207fad665ea24c0fb939d2d2e5a07fc60882998c178a8071cad66ee81a.json@@ -0,0 +1,131 @@+{+ "db_name": "PostgreSQL",+ "query": "\n SELECT\n event.title,\n event.description,\n event.location,\n event.visibility,\n event.starts_at,\n event.ends_at,\n event.start_date,\n event.end_date,\n event.time_zone,\n event.recurrence_lines,\n event.conference_url IS NOT NULL AS \"has_conference!\",\n $2::text IS NOT NULL AS \"has_occurrence!\",\n override.title AS override_title,\n override.description AS override_description,\n override.location AS override_location,\n CASE WHEN occurrence.event_id IS NULL THEN override.starts_at\n ELSE occurrence.starts_at END AS occurrence_starts_at,\n CASE WHEN occurrence.event_id IS NULL THEN override.ends_at\n ELSE occurrence.ends_at END AS occurrence_ends_at,\n CASE WHEN occurrence.event_id IS NULL THEN override.start_date\n ELSE occurrence.start_date END AS occurrence_start_date,\n CASE WHEN occurrence.event_id IS NULL THEN override.end_date\n ELSE occurrence.end_date END AS occurrence_end_date\n FROM calendar_events event\n LEFT JOIN calendar_event_occurrences occurrence\n ON occurrence.event_id = event.id\n AND occurrence.occurrence_key = $2\n LEFT JOIN calendar_event_overrides override\n ON override.event_id = event.id\n AND override.recurrence_id = $2\n WHERE event.id = $1\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "title",+ "type_info": "Text"+ },+ {+ "ordinal": 1,+ "name": "description",+ "type_info": "Text"+ },+ {+ "ordinal": 2,+ "name": "location",+ "type_info": "Text"+ },+ {+ "ordinal": 3,+ "name": "visibility",+ "type_info": "Text"+ },+ {+ "ordinal": 4,+ "name": "starts_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 5,+ "name": "ends_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 6,+ "name": "start_date",+ "type_info": "Date"+ },+ {+ "ordinal": 7,+ "name": "end_date",+ "type_info": "Date"+ },+ {+ "ordinal": 8,+ "name": "time_zone",+ "type_info": "Text"+ },+ {+ "ordinal": 9,+ "name": "recurrence_lines",+ "type_info": "TextArray"+ },+ {+ "ordinal": 10,+ "name": "has_conference!",+ "type_info": "Bool"+ },+ {+ "ordinal": 11,+ "name": "has_occurrence!",+ "type_info": "Bool"+ },+ {+ "ordinal": 12,+ "name": "override_title",+ "type_info": "Text"+ },+ {+ "ordinal": 13,+ "name": "override_description",+ "type_info": "Text"+ },+ {+ "ordinal": 14,+ "name": "override_location",+ "type_info": "Text"+ },+ {+ "ordinal": 15,+ "name": "occurrence_starts_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 16,+ "name": "occurrence_ends_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 17,+ "name": "occurrence_start_date",+ "type_info": "Date"+ },+ {+ "ordinal": 18,+ "name": "occurrence_end_date",+ "type_info": "Date"+ }+ ],+ "parameters": {+ "Left": [+ "Uuid",+ "Text"+ ]+ },+ "nullable": [+ false,+ true,+ true,+ false,+ true,+ true,+ true,+ true,+ true,+ false,+ null,+ null,+ true,+ true,+ true,+ null,+ null,+ null,+ null+ ]+ },+ "hash": "95334b207fad665ea24c0fb939d2d2e5a07fc60882998c178a8071cad66ee81a"+}diff --git a/apps/docs/AI/mcp/tools/update-calendar-event.mdx b/apps/docs/AI/mcp/tools/update-calendar-event.mdxindex 45d6abef8c..1af4456d3b 100644--- a/apps/docs/AI/mcp/tools/update-calendar-event.mdx+++ b/apps/docs/AI/mcp/tools/update-calendar-event.mdx@@ -12,6 +12,8 @@ Update an existing calendar event. Only the supplied fields change; omitted fielPassing `attendees` replaces the full attendee list — include everyone who should remain, not just additions. That holds when `viewerCan.removeGuests` from ListCalendarEvents is true (the user organizes the event, or the organizer lets guests modify it). When it is false, the list may only grow: pass the current attendees plus the additions; the additions are invited without touching anyone else, and dropping any guest fails. Adding guests then needs `viewerCan.inviteGuests`; otherwise the organizer doesn't let guests invite others or hides the guest list, or the event is an Outlook meeting the user doesn't organize. An empty string for `description` or `location` clears it. Fails on events from calendars the user cannot edit.+A guest without modify rights (`viewerCan.editDetails` false while `viewerCan.rsvp` is true) may only change their own `reminders`, add guests where `viewerCan.inviteGuests` allows it, and answer with `rsvp`; changing the title, time, description, location, recurrence or conference fails because the organizer doesn't let guests change the event.+`rsvp` sets the user's own response to an invitation and is independent of the field edits — it can be the only thing this call changes. It applies at the same `scope` as the rest of the call and answers as the connected inbox the event's copy belongs to, so it only works when that inbox is an attendee.## Parametersdiff --git a/apps/web/src/features/block-calendar/components/EventComposerSplit.tsx b/apps/web/src/features/block-calendar/components/EventComposerSplit.tsxindex ea8bab6e32..92fe38e19b 100644--- a/apps/web/src/features/block-calendar/components/EventComposerSplit.tsx+++ b/apps/web/src/features/block-calendar/components/EventComposerSplit.tsx@@ -94,6 +94,7 @@ function EventComposerContent(disabledFields={editor.disabledFields()}addOnlyGuests={editor.addOnlyGuests()}guestsReadOnlyReason={editor.guestsReadOnlyReason()}+ detailsReadOnlyReason={editor.detailsReadOnlyReason()}showRecurringEditNotice={editor.showRecurringEditNotice()}pending={editor.pending()}onCalendarChange={props.onCalendarChange}diff --git a/apps/web/src/features/calendar-view/components/Page.tsx b/apps/web/src/features/calendar-view/components/Page.tsxindex 8df5ccbd19..4b7e5361e4 100644--- a/apps/web/src/features/calendar-view/components/Page.tsx+++ b/apps/web/src/features/calendar-view/components/Page.tsx@@ -19,6 +19,7 @@ import {DEFAULT_CALENDAR_SOURCE,} from '@app/features/calendar/types';import { isCalendarRangeSupported } from '@app/features/calendar/utils/calendar-supported-range';+import { GUEST_EDITS_RESTRICTED } from '@app/features/calendar/utils/event-guest-editing';import {type CalendarEventTimeChange,calendarEventTimeFromFullCalendar,@@ -38,7 +39,10 @@ import { isMobile } from '@core/mobile/isMobile';import { fireAndForget } from '@core/util/fireAndForget';import type { DateSelectArg, DatesSetArg } from '@fullcalendar/core';import { useVisibleCalendarsQuery } from '@queries/calendar/calendars';-import { useUpdateCalendarEventMutation } from '@queries/calendar/mutations';+import {+ isGuestEditRefused,+ useUpdateCalendarEventMutation,+} from '@queries/calendar/mutations';import {type CalendarOccurrenceQueryRange,createCalendarOccurrenceQueryRange,@@ -316,6 +320,10 @@ export function Page(props: {{onError: (error) => {change.revert();+ if (isGuestEditRefused(error)) {+ toast.failure(GUEST_EDITS_RESTRICTED);+ return;+ }toast.failure('Failed to update event', {subtext: error.message,});diff --git a/apps/web/src/features/calendar/components/composer/EventForm.test.tsx b/apps/web/src/features/calendar/components/composer/EventForm.test.tsxindex 90a8473a91..a30c832fe2 100644--- a/apps/web/src/features/calendar/components/composer/EventForm.test.tsx+++ b/apps/web/src/features/calendar/components/composer/EventForm.test.tsx@@ -4,7 +4,7 @@import { cleanup, render, screen } from '@solidjs/testing-library';import userEvent from '@testing-library/user-event';-import { createMemo } from 'solid-js';+import { type ComponentProps, createMemo } from 'solid-js';import { afterEach, beforeEach, expect, it, vi } from 'vitest';vi.mock('@components/app/split-layout/split-router/mention-links', () => ({@@ -50,7 +50,7 @@ const WORK_CALENDAR: EventEditorCalendarOption = {};/** Renders the form and counts the edits it reports back to its host. */-function showForm() {+function showForm(props: Partial<ComponentProps<typeof EventForm>> = {}) {const edits = { count: 0 };render(() => {const calendarOptions = createMemo(() => [WORK_CALENDAR]);@@ -83,6 +83,7 @@ function showForm() {pending={false}onCancel={vi.fn()}onSubmit={vi.fn()}+ {...props}/>);});@@ -120,3 +121,41 @@ it('settles after a Macro call is picked', async () => {expect(trigger.textContent).toContain('Macro call');expect(edits.count).toBeLessThan(10);});++it('keeps a guest the organizer does not let modify to their own reminders', async () => {+ const user = userEvent.setup();+ showForm({+ isEdit: true,+ disabledFields: {+ calendar: true,+ title: true,+ allDay: true,+ start: true,+ end: true,+ recurrence: true,+ location: true,+ description: true,+ conference: true,+ },+ detailsReadOnlyReason: 'Only the organizer can change this event.',+ });++ await user.type(screen.getByLabelText('Title'), 'ab');+ expect(screen.getByLabelText('Title')).toHaveProperty(+ 'value',+ 'Customer demo'+ );+ expect(screen.getByRole('button', { name: 'Location' })).toHaveProperty(+ 'disabled',+ true+ );+ expect(+ screen.getByRole('button', { name: /Video conferencing/ })+ ).toHaveProperty('disabled', true);+ expect(+ screen.getByText('Only the organizer can change this event.')+ ).toBeTruthy();++ await user.click(screen.getByRole('button', { name: /Notifications/ }));+ expect(screen.getAllByRole('option').length).toBeGreaterThan(0);+});diff --git a/apps/web/src/features/calendar/components/composer/EventForm.tsx b/apps/web/src/features/calendar/components/composer/EventForm.tsxindex 8ff93f9a39..a6f5d3b82f 100644--- a/apps/web/src/features/calendar/components/composer/EventForm.tsx+++ b/apps/web/src/features/calendar/components/composer/EventForm.tsx@@ -2,12 +2,13 @@ import { useMacroMentionLinkResolver } from '@components/app/split-layout/split-import { MarkdownTextarea } from '@core/component/LexicalMarkdown/component/core/MarkdownTextarea';import SpinnerIcon from '@phosphor/spinner.svg';import type { CalendarUpdateScope } from '@service-email/client';-import { Button, cn, Layer, RadioGroup } from '@ui';+import { Button, cn, Layer, RadioGroup, Tooltip } from '@ui';import {createEffect,createSignal,createUniqueId,For,+ type ParentProps,Show,} from 'solid-js';import {@@ -44,6 +45,11 @@ export interface EventFormProps {addOnlyGuests?: boolean;/** Why a read-only guest list cannot change. */guestsReadOnlyReason?: string;+ /**+ * Why the event's title, time, description, location, recurrence and+ * conferencing cannot change.+ */+ detailsReadOnlyReason?: string;showRecurringEditNotice?: boolean;/** Disable interaction without presenting the form as an in-flight save. */disabled?: boolean;@@ -68,6 +74,19 @@ const RECURRING_EDIT_SCOPE_OPTIONS = [label: string;}[];+/** Explains a locked field on hover and keyboard focus. */+function LockedField(props: ParentProps<{ reason?: string; class?: string }>) {+ return (+ <Show when={props.reason} fallback={props.children}>+ {(reason) => (+ <Tooltip as="span" label={reason()} tabIndex={0} class={props.class}>+ {props.children}+ </Tooltip>+ )}+ </Show>+ );+}+/** Create/edit event form laid out like the standalone task composer. */export function EventForm(props: EventFormProps) {const formId = createUniqueId();@@ -154,19 +173,24 @@ export function EventForm(props: EventFormProps) {<div class="flex min-w-0 flex-col gap-6 text-sm text-ink-muted"><div class="flex min-w-0 flex-col gap-1"><div class="flex min-w-0 flex-col gap-1">- <EventDateTimeRangeFields- start={state().start}- end={state().end}- allDay={state().allDay}- onStartChange={controller.setStart}- onEndChange={(end) => controller.setField('end', end)}- onAllDayChange={controller.setAllDay}- startDisabled={fieldIsDisabled('start')}- endDisabled={fieldIsDisabled('end')}- allDayDisabled={fieldIsDisabled('allDay')}- invalid={controller.dateRangeError() !== undefined}- describedBy={dateRangeDescribedBy()}- />+ <LockedField+ reason={props.detailsReadOnlyReason}+ class="block min-w-0"+ >+ <EventDateTimeRangeFields+ start={state().start}+ end={state().end}+ allDay={state().allDay}+ onStartChange={controller.setStart}+ onEndChange={(end) => controller.setField('end', end)}+ onAllDayChange={controller.setAllDay}+ startDisabled={fieldIsDisabled('start')}+ endDisabled={fieldIsDisabled('end')}+ allDayDisabled={fieldIsDisabled('allDay')}+ invalid={controller.dateRangeError() !== undefined}+ describedBy={dateRangeDescribedBy()}+ />+ </LockedField><Show when={controller.dateRangeError()}>{(error) => (<p@@ -191,50 +215,60 @@ export function EventForm(props: EventFormProps) {</Show></div>- <input- type="text"- value={state().title}- onInput={(event) =>- controller.setField('title', event.currentTarget.value)- }- placeholder="New event"- aria-label="Title"- autofocus={!isEdit()}- disabled={fieldIsDisabled('title')}- class="h-9 w-full bg-transparent px-2 text-lg font-semibold leading-snug text-ink outline-none placeholder:text-ink-placeholder"- />+ <LockedField+ reason={props.detailsReadOnlyReason}+ class="flex w-full"+ >+ <input+ type="text"+ value={state().title}+ onInput={(event) =>+ controller.setField('title', event.currentTarget.value)+ }+ placeholder="New event"+ aria-label="Title"+ autofocus={!isEdit()}+ disabled={fieldIsDisabled('title')}+ class="h-9 w-full bg-transparent px-2 text-lg font-semibold leading-snug text-ink outline-none placeholder:text-ink-placeholder"+ />+ </LockedField>{/* Google rejects a description on an out-of-office event. Theeditor re-initializes from the kind switch's reset state, sowhat it shows always matches what a save submits. */}<Show when={!isOutOfOffice()}>- <div class="h-12 overflow-y-auto">- <MarkdownTextarea- resolveAppLink={resolveAppLink}- type="calendar"- initialHtml={calendarDescriptionToEditorHtml(- initialDescription- )}- editable={() => !fieldIsDisabled('description')}- onInitialized={(editor) => {- loadedDescription = exportCalendarDescription(editor);- }}- onChange={(_markdown, editor) => {- if (!editor) return;- const next = exportCalendarDescription(editor);- controller.setField(- 'description',- next === loadedDescription ? initialDescription : next- );- }}- placeholder="Add description..."- portalScope="local"- domRef={(element) =>- element.setAttribute('aria-label', 'Description')- }- class="h-full w-full bg-transparent px-2 text-sm text-ink outline-none"- />- </div>+ <LockedField+ reason={props.detailsReadOnlyReason}+ class="block w-full"+ >+ <div class="h-12 overflow-y-auto">+ <MarkdownTextarea+ resolveAppLink={resolveAppLink}+ type="calendar"+ initialHtml={calendarDescriptionToEditorHtml(+ initialDescription+ )}+ editable={() => !fieldIsDisabled('description')}+ onInitialized={(editor) => {+ loadedDescription = exportCalendarDescription(editor);+ }}+ onChange={(_markdown, editor) => {+ if (!editor) return;+ const next = exportCalendarDescription(editor);+ controller.setField(+ 'description',+ next === loadedDescription ? initialDescription : next+ );+ }}+ placeholder="Add description..."+ portalScope="local"+ domRef={(element) =>+ element.setAttribute('aria-label', 'Description')+ }+ class="h-full w-full bg-transparent px-2 text-sm text-ink outline-none"+ />+ </div>+ </LockedField></Show></div>@@ -254,17 +288,19 @@ export function EventForm(props: EventFormProps) {disabled={formIsDisabled()}readOnly={fieldIsReadOnly('calendar')}/>- <EventComposerRecurrencePill- options={controller.recurrenceOptions()}- value={controller.selectedRecurrenceOption()}- onChange={controller.changeRecurrenceChoice}- disabled={formIsDisabled()}- // A single occurrence has no recurrence rule of its own, so the- // recurrence cannot be edited while the scope is one event.- readOnly={- fieldIsReadOnly('recurrence') || editScope() === 'this_event'- }- />+ <LockedField reason={props.detailsReadOnlyReason}>+ <EventComposerRecurrencePill+ options={controller.recurrenceOptions()}+ value={controller.selectedRecurrenceOption()}+ onChange={controller.changeRecurrenceChoice}+ disabled={formIsDisabled()}+ // A single occurrence has no recurrence rule of its own, so the+ // recurrence cannot be edited while the scope is one event.+ readOnly={+ fieldIsReadOnly('recurrence') || editScope() === 'this_event'+ }+ />+ </LockedField><Show when={!isOutOfOffice()}><EventComposerGuestsPilloptions={controller.guestOptions}@@ -277,25 +313,29 @@ export function EventForm(props: EventFormProps) {props.addOnlyGuests ? controller.initialGuests() : undefined}/>- <EventComposerConferencePill- value={state().conference}- provider={capabilities()?.conferenceProvider}- macroCallsEnabled={props.macroCallsEnabled}- canKeepExisting={- controller.initialConferenceChoice() === 'existing'- }- onChange={(conference) =>- controller.setField('conference', conference)- }- disabled={fieldIsDisabled('conference') || conferenceLocked()}- />- <EventComposerLocationPill- value={state().location}- onChange={(location) =>- controller.setField('location', location)- }- disabled={fieldIsDisabled('location')}- />+ <LockedField reason={props.detailsReadOnlyReason}>+ <EventComposerConferencePill+ value={state().conference}+ provider={capabilities()?.conferenceProvider}+ macroCallsEnabled={props.macroCallsEnabled}+ canKeepExisting={+ controller.initialConferenceChoice() === 'existing'+ }+ onChange={(conference) =>+ controller.setField('conference', conference)+ }+ disabled={fieldIsDisabled('conference') || conferenceLocked()}+ />+ </LockedField>+ <LockedField reason={props.detailsReadOnlyReason}>+ <EventComposerLocationPill+ value={state().location}+ onChange={(location) =>+ controller.setField('location', location)+ }+ disabled={fieldIsDisabled('location')}+ />+ </LockedField></Show><Show when={isOutOfOffice()}><Show@@ -310,7 +350,7 @@ export function EventForm(props: EventFormProps) {<EventComposerDeclinePillvalue={state().outOfOffice}onChange={controller.setOutOfOffice}- disabled={formIsDisabled()}+ disabled={fieldIsDisabled('outOfOffice')}/></Show><Show@@ -328,7 +368,7 @@ export function EventForm(props: EventFormProps) {declineMessage,})}- disabled={formIsDisabled()}+ disabled={fieldIsDisabled('outOfOffice')}/></Show></Show>@@ -344,6 +384,9 @@ export function EventForm(props: EventFormProps) {/></div>+ <Show when={props.detailsReadOnlyReason}>+ {(reason) => <p class="text-xs text-ink-muted">{reason()}</p>}+ </Show><Show when={conferenceLocked()}><p class="text-xs text-ink-muted">Microsoft keeps the online meeting link on an existing event. Todiff --git a/apps/web/src/features/calendar/components/composer/event-form-model.ts b/apps/web/src/features/calendar/components/composer/event-form-model.tsindex 39d6dc6da8..56e460a52e 100644--- a/apps/web/src/features/calendar/components/composer/event-form-model.ts+++ b/apps/web/src/features/calendar/components/composer/event-form-model.ts@@ -132,7 +132,8 @@ type EventEditorField =| 'location'| 'description'| 'conference'- | 'reminders';+ | 'reminders'+ | 'outOfOffice';/** Field-level disabled state supplied by a create/edit owner. */export type EventEditorDisabledFields = Partial<diff --git a/apps/web/src/features/calendar/hooks/use-event-editor.test.ts b/apps/web/src/features/calendar/hooks/use-event-editor.test.tsindex 5a26d1673d..d49020401f 100644--- a/apps/web/src/features/calendar/hooks/use-event-editor.test.ts+++ b/apps/web/src/features/calendar/hooks/use-event-editor.test.ts@@ -47,6 +47,8 @@ vi.mock('@queries/calendar/mutations', () => ({mutateAsync: mocks.inviteGuests,isPending: false,}),+ isGuestEditRefused: (error: unknown) =>+ (error as { code?: string }).code === 'guests_cannot_modify',}));vi.mock('@queries/call/meetings', () => ({useCreateMeetingMutation: () => ({ mutateAsync: mocks.createMeeting }),@@ -806,8 +808,9 @@ describe('scheduling a Macro call', () => {it('retains an invited event link without managing another organizer’s call', async () => {const event = {...savedEvent,+ // A guest the organizer lets modify the event.viewerCan: {- editDetails: false,+ editDetails: true,inviteGuests: true,removeGuests: false,setGuestPolicy: false,@@ -1043,6 +1046,11 @@ describe('guests of an event the viewer was invited to', () => {rsvp: true,};const mayNotInvite = { ...mayInvite, inviteGuests: false };+ const mayModify = { ...mayInvite, editDetails: true, removeGuests: true };+ const thirtyMinutes = {+ useDefault: false,+ overrides: [{ method: 'popup', minutes: 30 }],+ };const unchanged: EventEditorSubmitValues = {...values,location: '',@@ -1072,13 +1080,13 @@ describe('guests of an event the viewer was invited to', () => {await editor.save({...unchanged,- title: 'Planning review',+ reminders: thirtyMinutes,guestEmails: ['[email protected]', '[email protected]'],});expect(mocks.updateEvent).toHaveBeenCalledOnce();expect(mocks.updateEvent.mock.lastCall?.[0].patch).toEqual({- title: 'Planning review',+ reminders: thirtyMinutes,});expect(mocks.inviteGuests).toHaveBeenCalledWith({eventId: 'event-1',@@ -1176,4 +1184,90 @@ describe('guests of an event the viewer was invited to', () => {dispose();}});++ it('locks the details of a guest the organizer does not let modify, but not their reminders', () => {+ const { editor, dispose } = editorFor(invitedEvent(mayInvite), true);+ try {+ expect(editor.disabledFields()).toMatchObject({+ title: true,+ allDay: true,+ start: true,+ end: true,+ recurrence: true,+ location: true,+ description: true,+ conference: true,+ reminders: false,+ });+ expect(editor.detailsReadOnlyReason()).toBe(+ 'Only the organizer can change this event.'+ );+ } finally {+ dispose();+ }+ });++ it('saves only the reminders of a guest the organizer does not let modify', async () => {+ const { editor, dispose } = editorFor(invitedEvent(mayInvite), true);+ try {+ await editor.save({+ ...unchanged,+ title: 'Planning review',+ location: 'Room 4',+ time: {+ kind: 'timed',+ startsAt: '2026-09-22T16:00:00Z',+ endsAt: '2026-09-22T17:00:00Z',+ timeZone: 'America/New_York',+ },+ reminders: thirtyMinutes,+ });+ expect(mocks.updateEvent).toHaveBeenCalledOnce();+ expect(mocks.updateEvent.mock.lastCall?.[0].patch).toEqual({+ reminders: thirtyMinutes,+ });+ } finally {+ dispose();+ }+ });++ it('leaves the details editable for a guest the organizer lets modify', async () => {+ const { editor, dispose } = editorFor(invitedEvent(mayModify), true);+ try {+ expect(editor.disabledFields()?.title).toBeUndefined();+ expect(editor.detailsReadOnlyReason()).toBeUndefined();+ await editor.save({ ...unchanged, title: 'Planning review' });+ expect(mocks.updateEvent.mock.lastCall?.[0].patch).toEqual({+ title: 'Planning review',+ });+ } finally {+ dispose();+ }+ });++ it('locks the details when the server refuses a guest’s change', async () => {+ mocks.updateEvent.mockRejectedValueOnce({ code: 'guests_cannot_modify' });+ const { editor, dispose } = editorFor(invitedEvent(mayModify), true);+ try {+ await editor.save({ ...unchanged, title: 'Planning review' });+ expect(mocks.failure).toHaveBeenCalledWith(+ 'Only the organizer can change this event.'+ );+ expect(editor.disabledFields()?.title).toBe(true);+ expect(editor.detailsReadOnlyReason()).toBe(+ 'Only the organizer can change this event.'+ );++ await editor.save({+ ...unchanged,+ title: 'Planning review',+ reminders: thirtyMinutes,+ });+ expect(mocks.updateEvent.mock.lastCall?.[0].patch).toEqual({+ reminders: thirtyMinutes,+ });+ } finally {+ dispose();+ }+ });});diff --git a/apps/web/src/features/calendar/hooks/use-event-editor.ts b/apps/web/src/features/calendar/hooks/use-event-editor.tsindex 3007217b5b..b15790f8be 100644--- a/apps/web/src/features/calendar/hooks/use-event-editor.ts+++ b/apps/web/src/features/calendar/hooks/use-event-editor.ts@@ -3,6 +3,7 @@ import { toast } from '@core/component/Toast/Toast';import { recipientEntityMapper, useContacts } from '@core/user';import { useVisibleCalendarsQuery } from '@queries/calendar/calendars';import {+ isGuestEditRefused,useCreateCalendarEventMutation,useInviteCalendarEventGuestsMutation,useUpdateCalendarEventMutation,@@ -35,7 +36,9 @@ import {addedGuestEmails,type EventGuestEditing,eventGuestEditing,+ GUEST_EDITS_RESTRICTED,GUEST_INVITES_RESTRICTED,+ guestEditsRestricted,guestInvitesRestricted,guestListChanged,viewerReplacesGuests,@@ -50,6 +53,18 @@ const EDIT_DISABLED_FIELDS = {calendar: true,} satisfies EventEditorDisabledFields;+/** What a guest the organizer does not let modify the event cannot change. */+const DETAIL_FIELDS = {+ title: true,+ allDay: true,+ start: true,+ end: true,+ recurrence: true,+ location: true,+ description: true,+ outOfOffice: true,+} satisfies EventEditorDisabledFields;+/*** Whether the editor addresses the copy whose reminders Macro's alerts* follow and whose guests and conferencing Macro records. Another copy's@@ -167,6 +182,16 @@ export function useEventEditor(props: UseEventEditorProps) {? GUEST_INVITES_RESTRICTED: undefined;};+ // A refusal means the stored guest policy was newer than the event shown,+ // so the details lock without waiting for the refetch.+ const [detailEditsRefused, setDetailEditsRefused] = createSignal(false);+ const detailsLocked = () => {+ const event = props.event();+ return (+ event !== undefined &&+ (detailEditsRefused() || guestEditsRestricted(event))+ );+ };const updateMeeting = useUpdateMeetingMutation();const create = useCreateCalendarEventMutation();@@ -330,6 +355,21 @@ export function useEventEditor(props: UseEventEditorProps) {guestEditing() === 'add'? addedGuestEmails(event, values.guestEmails): [];+ const detailChanges = {+ ...(values.title !== event.title ? { title: values.title } : {}),+ ...(hasTimeChanged(event, values.time) ? { time: values.time } : {}),+ ...(content.location !== (event.location ?? '')+ ? { location: content.location }+ : {}),+ ...(content.description !== (event.description ?? '')+ ? { description: content.description }+ : {}),+ ...(recurrenceChanged+ ? { recurrenceLines: values.recurrenceLines }+ : {}),+ ...(conference ? { conference } : {}),+ ...(values.outOfOffice ? { outOfOffice: values.outOfOffice } : {}),+ };const updateArgs = {eventId: event.eventId,calendarId: event.calendarId,@@ -339,26 +379,15 @@ export function useEventEditor(props: UseEventEditorProps) {: undefined,occurrenceKey: targetsOneOccurrence ? event.occurrenceKey : undefined,patch: {- ...(values.title !== event.title ? { title: values.title } : {}),- ...(hasTimeChanged(event, values.time) ? { time: values.time } : {}),- ...(content.location !== (event.location ?? '')- ? { location: content.location }- : {}),- ...(content.description !== (event.description ?? '')- ? { description: content.description }- : {}),- ...(recurrenceChanged- ? { recurrenceLines: values.recurrenceLines }- : {}),+ // A guest who may not modify the event sends only their own fields.+ ...(detailsLocked() ? {} : detailChanges),...(guestEditing() === 'replace' &&guestListChanged(event, values.guestEmails)? {attendees: values.guestEmails.map((email) => ({ email })),}: {}),- ...(conference ? { conference } : {}),...(values.reminders ? { reminders: values.reminders } : {}),- ...(values.outOfOffice ? { outOfOffice: values.outOfOffice } : {}),},};if (Object.keys(updateArgs.patch).length > 0) {@@ -403,6 +432,9 @@ export function useEventEditor(props: UseEventEditorProps) {'Your event is saved, but its call link could not be added. Save again to retry.');}+ } else if (event && isGuestEditRefused(error)) {+ setDetailEditsRefused(true);+ toast.failure(GUEST_EDITS_RESTRICTED);} else {toast.failure(event ? 'Failed to update event' : 'Failed to create event',@@ -425,6 +457,7 @@ export function useEventEditor(props: UseEventEditorProps) {const editsOtherCopy = !editsPrimaryCopy(event);return {...EDIT_DISABLED_FIELDS,+ ...(detailsLocked() ? DETAIL_FIELDS : {}),guests: guestEditing() === 'none',conference: editsOtherCopy || !viewerReplacesGuests(event),reminders: editsOtherCopy,@@ -437,6 +470,8 @@ export function useEventEditor(props: UseEventEditorProps) {disabledFields,addOnlyGuests: () => guestEditing() === 'add',guestsReadOnlyReason,+ detailsReadOnlyReason: () =>+ detailsLocked() ? GUEST_EDITS_RESTRICTED : undefined,calendarOptions,guestOptions,showRecurringEditNotice,diff --git a/apps/web/src/features/calendar/types.test.ts b/apps/web/src/features/calendar/types.test.tsindex fa01992cc4..f2dcf6f471 100644--- a/apps/web/src/features/calendar/types.test.ts+++ b/apps/web/src/features/calendar/types.test.ts@@ -312,6 +312,30 @@ describe('mapCalendarEventToFullCalendar', () => {expect(rendered.durationEditable).toBe(false);});+ it('fixes a guest’s event in place unless the organizer lets them modify it', () => {+ const guest = {+ editDetails: false,+ inviteGuests: true,+ removeGuests: false,+ setGuestPolicy: false,+ rsvp: true,+ };+ const source = item([copy('primary')]);+ source.event.viewerCan = guest;+ const invited = mapCalendarEventToFullCalendar(+ mapCalendarOccurrence(source, { sourceById })+ );+ source.event.viewerCan = { ...guest, editDetails: true };+ const modifiable = mapCalendarEventToFullCalendar(+ mapCalendarOccurrence(source, { sourceById })+ );++ expect(invited.startEditable).toBe(false);+ expect(invited.durationEditable).toBe(false);+ expect(modifiable.startEditable).toBe(true);+ expect(modifiable.durationEditable).toBe(true);+ });+it('keeps the occurrence identity and displayed title on the rendered event', () => {const rendered = mapCalendarEventToFullCalendar(mapCalendarOccurrence(item([copy('primary'), sharedCopy]), {diff --git a/apps/web/src/features/calendar/utils/event-guest-editing.ts b/apps/web/src/features/calendar/utils/event-guest-editing.tsindex d6f6d93e34..57ad98e27c 100644--- a/apps/web/src/features/calendar/utils/event-guest-editing.ts+++ b/apps/web/src/features/calendar/utils/event-guest-editing.ts@@ -4,6 +4,21 @@ import type { CalendarEvent } from '../types';/** Shown where a guest would add guests when the organizer does not allow it. */export const GUEST_INVITES_RESTRICTED = 'Only the organizer can invite guests.';+/** Shown where a guest would change the event when the organizer does not allow it. */+export const GUEST_EDITS_RESTRICTED =+ 'Only the organizer can change this event.';++/**+ * Whether the viewer is a guest the organizer does not let modify the event,+ * so its title, time, description, location, recurrence and conferencing stay+ * as the organizer set them. Reminders stay the guest's own. Someone neither+ * organizing nor invited keeps what their calendar access allows, as on the+ * server.+ */+export function guestEditsRestricted(event: CalendarEvent): boolean {+ return event.viewerCan.rsvp && !event.viewerCan.editDetails;+}+function normalizeGuestEmail(email: string) {return email.trim().toLowerCase();}diff --git a/apps/web/src/features/calendar/utils/event-interaction.ts b/apps/web/src/features/calendar/utils/event-interaction.tsindex c79ef66bf1..cc46a1b4e8 100644--- a/apps/web/src/features/calendar/utils/event-interaction.ts+++ b/apps/web/src/features/calendar/utils/event-interaction.ts@@ -2,6 +2,7 @@ import type { EventApi } from '@fullcalendar/core';import type { EventTime } from '@service-calendar/generated/schemas/eventTime';import type { CalendarEvent } from '../types';import { formatLocalDate, isTimedPointEvent } from './calendar-date';+import { guestEditsRestricted } from './event-guest-editing';interface FullCalendarEventRange {allDay: boolean;@@ -37,6 +38,7 @@ export function canEditCalendarEventTime(event: CalendarEvent) {!event.teamProjection &&!event.isReadOnly &&!event.isCancelled &&+ !guestEditsRestricted(event) &&!isTimedPointEvent(event) &&event.recurrenceLines.length === 0 &&event.recurrenceId === undefineddiff --git a/apps/web/src/lib/queries/calendar/mutations.ts b/apps/web/src/lib/queries/calendar/mutations.tsindex 4765a8bee3..d2316e735b 100644--- a/apps/web/src/lib/queries/calendar/mutations.ts+++ b/apps/web/src/lib/queries/calendar/mutations.ts@@ -388,15 +388,29 @@ function withInvitedGuests(};}+function hasCalendarMutationCode(+ error: unknown,+ code: CalendarMutationErrorCode+): boolean {+ return (+ thrownResultErrorHasCode(error, code) ||+ (error instanceof CalendarMutationError && error.code === code)+ );+}+/** Whether a write failed because the organizer does not let the viewer invite guests. */export function isGuestInviteRefused(error: unknown): boolean {- return (- thrownResultErrorHasCode(- error,- CalendarMutationErrorCode.guests_cannot_invite- ) ||- (error instanceof CalendarMutationError &&- error.code === CalendarMutationErrorCode.guests_cannot_invite)+ return hasCalendarMutationCode(+ error,+ CalendarMutationErrorCode.guests_cannot_invite+ );+}++/** Whether a write failed because the organizer does not let the viewer change the event. */+export function isGuestEditRefused(error: unknown): boolean {+ return hasCalendarMutationCode(+ error,+ CalendarMutationErrorCode.guests_cannot_modify);}diff --git a/apps/web/src/lib/service-clients/service-calendar/generated/schemas/calendarMutationErrorCode.ts b/apps/web/src/lib/service-clients/service-calendar/generated/schemas/calendarMutationErrorCode.tsindex 4323667195..0a5ae58fc5 100644--- a/apps/web/src/lib/service-clients/service-calendar/generated/schemas/calendarMutationErrorCode.ts+++ b/apps/web/src/lib/service-clients/service-calendar/generated/schemas/calendarMutationErrorCode.ts@@ -20,6 +20,7 @@ export const CalendarMutationErrorCode = {not_attendee: 'not_attendee',guests_cannot_invite: 'guests_cannot_invite',guest_list_hidden: 'guest_list_hidden',+ guests_cannot_modify: 'guests_cannot_modify',already_on_calendar: 'already_on_calendar',invalid_input: 'invalid_input',reauth_required: 'reauth_required',diff --git a/apps/web/src/lib/service-clients/service-calendar/openapi.json b/apps/web/src/lib/service-clients/service-calendar/openapi.jsonindex c8b0a089dd..2c874f74d5 100644--- a/apps/web/src/lib/service-clients/service-calendar/openapi.json+++ b/apps/web/src/lib/service-clients/service-calendar/openapi.json@@ -1345,6 +1345,7 @@"not_attendee","guests_cannot_invite","guest_list_hidden",+ "guests_cannot_modify","already_on_calendar","invalid_input","reauth_required",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 61b70f39fb..07edbd622f 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@@ -14819,6 +14819,8 @@ export interface UpdateBookingSettings {** Passing `attendees` replaces the full attendee list — include everyone who should remain, not just additions. That holds when `viewerCan.removeGuests` from ListCalendarEvents is true (the user organizes the event, or the organizer lets guests modify it). When it is false, the list may only grow: pass the current attendees plus the additions; the additions are invited without touching anyone else, and dropping any guest fails. Adding guests then needs `viewerCan.inviteGuests`; otherwise the organizer doesn't let guests invite others or hides the guest list, or the event is an Outlook meeting the user doesn't organize. An empty string for `description` or `location` clears it. Fails on events from calendars the user cannot edit.*+ * A guest without modify rights (`viewerCan.editDetails` false while `viewerCan.rsvp` is true) may only change their own `reminders`, add guests where `viewerCan.inviteGuests` allows it, and answer with `rsvp`; changing the title, time, description, location, recurrence or conference fails because the organizer doesn't let guests change the event.+ ** `rsvp` sets the user's own response to an invitation and is independent of the field edits — it can be the only thing this call changes. It applies at the same `scope` as the rest of the call and answers as the connected inbox the event's copy belongs to, so it only works when that inbox is an attendee.*/export interface UpdateCalendarEvent {diff --git a/crates/calendar_events/AGENTS.md b/crates/calendar_events/AGENTS.mdindex 92c126aeec..bb7454b948 100644--- a/crates/calendar_events/AGENTS.md+++ b/crates/calendar_events/AGENTS.md@@ -69,6 +69,12 @@ reminder dispatch, team availability, and provider/Postgres persistence.write either: an Outlook organizer adds guests with the same full-list write(`email_api_client`'s `outlook/calendar/invite.rs`), and an Outlook guest mayonly answer (`guests_cannot_invite`).+- A guest without `edit_details` may change only what Google keeps on each+ guest's copy (reminders, availability) and add guests where allowed:+ `update_event` drops details the patch repeats at their stored value+ (`get_event_details`, the series or the addressed occurrence) and refuses+ any other detail change with `GuestsCannotModify` before inviting anyone.+ Someone neither organizing nor invited is left to their calendar access.- A channel-shared event reaches a member's calendar as a copy, not a seat:`copy_shared_event` (`src/domain/mutations/copy.rs`) imports it under themeeting's iCalendar UID with no guests or join link, behind the samediff --git a/crates/calendar_events/src/domain/models.rs b/crates/calendar_events/src/domain/models.rsindex c38bcac2c3..b1cb692a73 100644--- a/crates/calendar_events/src/domain/models.rs+++ b/crates/calendar_events/src/domain/models.rs@@ -1328,6 +1328,27 @@ impl CalendarEventPatch {}}+/// The stored details of an event or one of its occurrences: what every+/// guest shares and only those who may modify the event change.+#[derive(Clone, Debug, PartialEq, Eq)]+pub struct EventDetails {+ /// Display title.+ pub title: String,+ /// Event body.+ pub description: Option<String>,+ /// Location label.+ pub location: Option<String>,+ /// Event visibility.+ pub visibility: EventVisibility,+ /// Timed or all-day shape. `None` for an occurrence whose time is not+ /// stored, outside the materialized window.+ pub time: Option<EventTime>,+ /// Raw RFC 5545 recurrence properties of the series.+ pub recurrence_lines: Vec<String>,+ /// Whether a conference is attached.+ pub has_conference: bool,+}+/// OAuth identity used to mint an access token for a connected inbox.#[derive(Clone, Debug, PartialEq, Eq)]pub struct CalendarLinkTokenIdentity {diff --git a/crates/calendar_events/src/domain/mutations.rs b/crates/calendar_events/src/domain/mutations.rsindex 80bc8c02ab..4c5315c84a 100644--- a/crates/calendar_events/src/domain/mutations.rs+++ b/crates/calendar_events/src/domain/mutations.rs@@ -8,6 +8,7 @@use std::collections::HashMap;mod copy;+mod details;mod invite;mod replacement;@@ -35,6 +36,8 @@ use super::{use crate::domain::events::{CalendarEventMetadata, CalendarMacroEvent, CalendarTopicEvent};use macro_event_broker::MacroEventBroker;+const EMPTY_PATCH: &str = "the patch changes nothing";+/// Calendar mutation use cases with provider, token, and persistence/// details behind ports.pub struct CalendarMutationServiceImpl<R, G, T, B, N> {@@ -299,9 +302,7 @@ wherescope: CalendarUpdateScope,) -> Result<CalendarEvent, CalendarMutationError> {if patch.is_empty() {- return Err(CalendarMutationError::InvalidInput(- "the patch changes nothing".to_string(),- ));+ return Err(CalendarMutationError::InvalidInput(EMPTY_PATCH.to_string()));}if let Some(time) = &patch.time {validate_time(time)?;@@ -329,12 +330,20 @@ where}self.require_provider_writes(target.token_identity.provider)?;validate_conference(target.token_identity.provider, patch.conference)?;+ // The stored list is the baseline — an occurrence's own list when+ // an occurrence-scoped patch addresses one — so a retained guest's+ // per-instance RSVP wins over their series status.+ let stored = self.stored_attendees(event_id, &scope).await?;+ let capabilities = invite::copy_capabilities(&target, &stored);+ // Checked before any guest is invited, so a refused change leaves+ // the event untouched.+ self.require_detail_rights(event_id, &scope, capabilities, &mut patch)+ .await?;+ if patch.is_empty() {+ return Err(CalendarMutationError::InvalidInput(EMPTY_PATCH.to_string()));+ }if let Some(mut attendees) = patch.attendees.take() {- // The stored list is the baseline — an occurrence's own list when- // an occurrence-scoped patch addresses one — so a retained guest's- // per-instance RSVP wins over their series status.- let stored = self.stored_attendees(event_id, &scope).await?;- if invite::copy_capabilities(&target, &stored).remove_guests {+ if capabilities.remove_guests {preserve_retained_attendee_state(&mut attendees, &stored);patch.attendees = Some(attendees);} else {@@ -356,9 +365,7 @@ wherereturn Ok(invited);}} else if patch.is_empty() {- return Err(CalendarMutationError::InvalidInput(- "the patch changes nothing".to_string(),- ));+ return Err(CalendarMutationError::InvalidInput(EMPTY_PATCH.to_string()));}}}diff --git a/crates/calendar_events/src/domain/mutations/details.rs b/crates/calendar_events/src/domain/mutations/details.rsnew file mode 100644index 0000000000..c6568379ef--- /dev/null+++ b/crates/calendar_events/src/domain/mutations/details.rs@@ -0,0 +1,129 @@+//! Changing an event's details: the content and time the organizer shares+//! with every guest. Google keeps reminders and availability on each guest's+//! own copy, so any guest may change those.+use super::*;+use crate::domain::capabilities::ViewerCapabilities;+use crate::domain::models::{ConferenceChange, EventDetails};++impl<R, G, T, B, N> CalendarMutationServiceImpl<R, G, T, B, N>+where+ R: CalendarRepository,+ G: CalendarMutationProvider,+ T: CalendarAccessTokenProvider,+ B: MacroEventBroker,+ N: CalendarRefreshNotifier,+{+ /// Refuse a guest the organizer does not let modify the event any change+ /// to its details. Details the patch repeats at their stored value are+ /// dropped first, so a client that resends unchanged fields still saves+ /// the guest's own ones and Google never sees a guest's copy of them.+ pub(super) async fn require_detail_rights(+ &self,+ event_id: Uuid,+ scope: &CalendarUpdateScope,+ capabilities: ViewerCapabilities,+ patch: &mut CalendarEventPatch,+ ) -> Result<(), CalendarMutationError> {+ if !is_guest_without_modify(capabilities) || !changes_details(patch) {+ return Ok(());+ }+ let occurrence_key = match scope {+ CalendarUpdateScope::All => None,+ CalendarUpdateScope::ThisEvent { recurrence_id } => Some(recurrence_id.as_str()),+ };+ let stored = self+ .repository+ .get_event_details(event_id, occurrence_key)+ .await+ .map_err(internal)?+ .ok_or(CalendarMutationError::NotFound)?;+ drop_unchanged_details(patch, &stored);+ if changes_details(patch) {+ return Err(CalendarMutationError::GuestsCannotModify);+ }+ Ok(())+ }+}++/// Whether the actor is a guest the organizer does not let modify the+/// event. Someone neither organizing nor invited, such as a delegate writing+/// to a calendar shared with them, keeps what their calendar access allows.+fn is_guest_without_modify(capabilities: ViewerCapabilities) -> bool {+ capabilities.rsvp && !capabilities.edit_details+}++/// Whether the patch changes a detail. Reminders and availability are each+/// guest's own, and the guest list follows its own rules.+fn changes_details(patch: &CalendarEventPatch) -> bool {+ let CalendarEventPatch {+ title,+ description,+ location,+ time,+ attendees: _,+ recurrence_lines,+ visibility,+ transparency: _,+ reminders: _,+ conference,+ out_of_office,+ } = patch;+ title.is_some()+ || description.is_some()+ || location.is_some()+ || time.is_some()+ || recurrence_lines.is_some()+ || visibility.is_some()+ || conference.is_some()+ || out_of_office.is_some()+}++/// Clear every detail the patch sets to its stored value. A time counts as+/// unchanged when it covers the same span, whatever zone the client named.+fn drop_unchanged_details(patch: &mut CalendarEventPatch, stored: &EventDetails) {+ if patch.title.as_deref() == Some(stored.title.as_str()) {+ patch.title = None;+ }+ // An empty string clears the description or location, which reads back+ // as none.+ if patch.description.as_deref() == Some(stored.description.as_deref().unwrap_or("")) {+ patch.description = None;+ }+ if patch.location.as_deref() == Some(stored.location.as_deref().unwrap_or("")) {+ patch.location = None;+ }+ if patch+ .time+ .as_ref()+ .zip(stored.time.as_ref())+ .is_some_and(|(time, stored)| same_span(time, stored))+ {+ patch.time = None;+ }+ if patch.recurrence_lines.as_ref() == Some(&stored.recurrence_lines) {+ patch.recurrence_lines = None;+ }+ if patch.visibility == Some(stored.visibility) {+ patch.visibility = None;+ }+ if patch.conference == Some(ConferenceChange::Removed) && !stored.has_conference {+ patch.conference = None;+ }+}++fn same_span(time: &EventTime, stored: &EventTime) -> bool {+ match (time, stored) {+ (+ EventTime::Timed {+ starts_at, ends_at, ..+ },+ EventTime::Timed {+ starts_at: stored_starts_at,+ ends_at: stored_ends_at,+ ..+ },+ ) => starts_at == stored_starts_at && ends_at == stored_ends_at,+ (EventTime::AllDay { .. }, EventTime::AllDay { .. }) => time == stored,+ _ => false,+ }+}diff --git a/crates/calendar_events/src/domain/mutations/test.rs b/crates/calendar_events/src/domain/mutations/test.rsindex c2714581cc..068a2983c5 100644--- a/crates/calendar_events/src/domain/mutations/test.rs+++ b/crates/calendar_events/src/domain/mutations/test.rs@@ -3,9 +3,9 @@ use crate::domain::models::{ActorInboxes, AppliedGoogleGrant, CalendarAttendee, CalendarAttendeeInput,CalendarBackfillJobKey, CalendarCreationTarget, CalendarEventOverride, CalendarEventSource,CalendarLinkTokenIdentity, CalendarOccurrenceCursor, CalendarSyncStatus, CalendarWatchRelease,- ConferenceChange, DisconnectedCalendar, EventStart, EventStatus, EventTransparency, EventType,- EventVisibility, GoogleCalendarSyncSnapshot, GoogleWatchChannel, GuestPolicy,- OutOfOfficeAutoDeclineMode, OutOfOfficeProperties, OwnedInbox, ProviderCalendar,+ ConferenceChange, DisconnectedCalendar, EventDetails, EventStart, EventStatus,+ EventTransparency, EventType, EventVisibility, GoogleCalendarSyncSnapshot, GoogleWatchChannel,+ GuestPolicy, OutOfOfficeAutoDeclineMode, OutOfOfficeProperties, OwnedInbox, ProviderCalendar,ProviderCalendarTarget, ProviderEventSource, StoredGoogleCalendar, ViewerCapabilities,VisibleCalendar,};@@ -185,6 +185,10 @@ struct FakeRepo {fail_owned_inboxes: bool,/// Guest policies recorded after the provider refused an invite.recorded_guest_policies: Arc<Mutex<Vec<(Uuid, GuestPolicy)>>>,+ /// Stored details a guest's update is compared against.+ event_details: Option<EventDetails>,+ /// The occurrence key of every stored-details read.+ details_requests: Arc<Mutex<Vec<Option<String>>>>,/// What `event_export` resolves for the requester.export: Option<crate::domain::ics::CalendarEventExport>,/// Inboxes a sync was scheduled for.@@ -210,6 +214,8 @@ impl Default for FakeRepo {fail_list_visible: false,fail_owned_inboxes: false,recorded_guest_policies: Default::default(),+ event_details: None,+ details_requests: Default::default(),export: None,scheduled_syncs: Default::default(),}@@ -405,6 +411,18 @@ impl CalendarRepository for FakeRepo {Ok(self.occurrence_override_attendees.clone())}+ async fn get_event_details(+ &self,+ _event_id: Uuid,+ occurrence_key: Option<&str>,+ ) -> Result<Option<EventDetails>, rootcause::Report> {+ self.details_requests+ .lock()+ .unwrap()+ .push(occurrence_key.map(str::to_string));+ Ok(self.event_details.clone())+ }+async fn record_guest_policy(&self,event_id: Uuid,@@ -2904,5 +2922,6 @@ async fn outlook_write_pause_rejects_provider_operations_before_fetching_tokens(}mod copy;+mod details;mod invite;mod replacement;diff --git a/crates/calendar_events/src/domain/mutations/test/details.rs b/crates/calendar_events/src/domain/mutations/test/details.rsnew file mode 100644index 0000000000..1cb89a7c43--- /dev/null+++ b/crates/calendar_events/src/domain/mutations/test/details.rs@@ -0,0 +1,395 @@+use super::*;++const ORGANIZER: &str = "[email protected]";+const RECURRENCE_ID: &str = "2026-08-06T14:00:00+00:00";++const CAN_MODIFY: GuestPolicy = GuestPolicy {+ can_modify: true,+ can_invite_others: true,+ can_see_other_guests: true,+};++/// Olivia's meeting with the actor (`[email protected]`) as one of its+/// guests, under `guest_policy`.+fn guest_repo(guest_policy: GuestPolicy) -> FakeRepo {+ let mut organizer = echo_attendee(ORGANIZER, false);+ organizer.is_organizer = true;+ FakeRepo {+ mutation_target: Some(CalendarEventMutationTarget {+ organizer_email: Some(ORGANIZER.to_string()),+ guest_policy,+ ..mutation_target(false)+ }),+ stored_attendees: vec![organizer, echo_attendee("[email protected]", false)],+ event_details: Some(stored_details()),+ ..FakeRepo::default()+ }+}++fn stored_details() -> EventDetails {+ EventDetails {+ title: "Planning".to_string(),+ description: Some("Agenda".to_string()),+ location: None,+ visibility: EventVisibility::Default,+ time: Some(timed_time()),+ recurrence_lines: vec!["RRULE:FREQ=WEEKLY".to_string()],+ has_conference: true,+ }+}++fn popup_reminders() -> EventReminders {+ EventReminders {+ use_default: false,+ overrides: vec![crate::domain::models::EventReminderOverride {+ method: "popup".to_string(),+ minutes: 10,+ }],+ }+}++async fn update(+ repo: FakeRepo,+ provider: FakeProvider,+ patch: CalendarEventPatch,+ scope: CalendarUpdateScope,+) -> Result<CalendarEvent, CalendarMutationError> {+ service(repo, provider, FakeTokens::ok())+ .update_event("macro|user", Uuid::now_v7(), None, patch, scope)+ .await+}++#[tokio::test]+async fn a_guest_the_organizer_does_not_let_modify_cannot_change_details() {+ let changes = [+ CalendarEventPatch {+ title: Some("Retro".to_string()),+ ..CalendarEventPatch::default()+ },+ CalendarEventPatch {+ description: Some(String::new()),+ ..CalendarEventPatch::default()+ },+ CalendarEventPatch {+ location: Some("Room 4".to_string()),+ ..CalendarEventPatch::default()+ },+ CalendarEventPatch {+ time: Some(EventTime::AllDay {+ start_date: chrono::NaiveDate::from_ymd_opt(2026, 8, 6).unwrap(),+ end_date: chrono::NaiveDate::from_ymd_opt(2026, 8, 7).unwrap(),+ }),+ ..CalendarEventPatch::default()+ },+ CalendarEventPatch {+ recurrence_lines: Some(Vec::new()),+ ..CalendarEventPatch::default()+ },+ CalendarEventPatch {+ visibility: Some(EventVisibility::Private),+ ..CalendarEventPatch::default()+ },+ CalendarEventPatch {+ conference: Some(ConferenceChange::Removed),+ ..CalendarEventPatch::default()+ },+ ];+ for patch in changes {+ let provider = FakeProvider::new(FakeProviderBehavior::Echo);+ let calls = provider.calls.clone();++ let error = update(+ guest_repo(GuestPolicy::default()),+ provider,+ patch.clone(),+ CalendarUpdateScope::All,+ )+ .await+ .unwrap_err();++ assert!(+ matches!(error, CalendarMutationError::GuestsCannotModify),+ "{patch:?}: {error:?}"+ );+ assert!(calls.lock().unwrap().is_empty(), "{patch:?}");+ }+}++#[tokio::test]+async fn any_guest_changes_their_own_reminders_and_availability() {+ let provider = FakeProvider::new(FakeProviderBehavior::Echo);+ let patches = provider.updated_patches.clone();+ let repo = guest_repo(GuestPolicy::default());+ let details_requests = repo.details_requests.clone();++ update(+ repo,+ provider,+ CalendarEventPatch {+ reminders: Some(popup_reminders()),+ transparency: Some(EventTransparency::Transparent),+ ..CalendarEventPatch::default()+ },+ CalendarUpdateScope::All,+ )+ .await+ .unwrap();++ assert_eq!(+ patches.lock().unwrap().as_slice(),+ [CalendarEventPatch {+ reminders: Some(popup_reminders()),+ transparency: Some(EventTransparency::Transparent),+ ..CalendarEventPatch::default()+ }]+ );+ assert!(+ details_requests.lock().unwrap().is_empty(),+ "nothing to compare without a detail in the patch"+ );+}++#[tokio::test]+async fn a_guest_resending_unchanged_details_saves_only_their_own_fields() {+ let provider = FakeProvider::new(FakeProviderBehavior::Echo);+ let patches = provider.updated_patches.clone();+ let EventTime::Timed {+ starts_at, ends_at, ..+ } = timed_time()+ else {+ unreachable!("the fixture time is timed");+ };++ update(+ guest_repo(GuestPolicy::default()),+ provider,+ CalendarEventPatch {+ title: Some("Planning".to_string()),+ description: Some("Agenda".to_string()),+ location: Some(String::new()),+ // The same span, named in the guest's own zone.+ time: Some(EventTime::Timed {+ starts_at,+ ends_at,+ time_zone: Some("America/New_York".to_string()),+ }),+ recurrence_lines: Some(vec!["RRULE:FREQ=WEEKLY".to_string()]),+ visibility: Some(EventVisibility::Default),+ reminders: Some(popup_reminders()),+ ..CalendarEventPatch::default()+ },+ CalendarUpdateScope::All,+ )+ .await+ .unwrap();++ assert_eq!(+ patches.lock().unwrap().as_slice(),+ [CalendarEventPatch {+ reminders: Some(popup_reminders()),+ ..CalendarEventPatch::default()+ }],+ "Google never receives a guest's copy of the shared details"+ );+}++#[tokio::test]+async fn a_guest_resending_only_unchanged_details_changes_nothing() {+ let provider = FakeProvider::new(FakeProviderBehavior::Echo);+ let calls = provider.calls.clone();++ let error = update(+ guest_repo(GuestPolicy::default()),+ provider,+ CalendarEventPatch {+ title: Some("Planning".to_string()),+ ..CalendarEventPatch::default()+ },+ CalendarUpdateScope::All,+ )+ .await+ .unwrap_err();++ assert!(+ matches!(&error, CalendarMutationError::InvalidInput(message) if message == "the patch changes nothing"),+ "{error:?}"+ );+ assert!(calls.lock().unwrap().is_empty());+}++#[tokio::test]+async fn a_refused_detail_change_invites_nobody() {+ let provider = FakeProvider::new(FakeProviderBehavior::Echo);+ let calls = provider.calls.clone();++ let error = update(+ guest_repo(GuestPolicy::default()),+ provider,+ CalendarEventPatch {+ title: Some("Retro".to_string()),+ attendees: Some(vec![+ CalendarAttendeeInput {+ email: ORGANIZER.to_string(),+ is_optional: false,+ response_status: None,+ },+ CalendarAttendeeInput {+ email: "[email protected]".to_string(),+ is_optional: false,+ response_status: None,+ },+ ]),+ ..CalendarEventPatch::default()+ },+ CalendarUpdateScope::All,+ )+ .await+ .unwrap_err();++ assert!(matches!(error, CalendarMutationError::GuestsCannotModify));+ assert!(calls.lock().unwrap().is_empty());+}++#[tokio::test]+async fn a_guest_the_organizer_lets_modify_changes_details() {+ let provider = FakeProvider::new(FakeProviderBehavior::Echo);+ let patches = provider.updated_patches.clone();+ let repo = guest_repo(CAN_MODIFY);+ let details_requests = repo.details_requests.clone();++ update(+ repo,+ provider,+ CalendarEventPatch {+ title: Some("Retro".to_string()),+ ..CalendarEventPatch::default()+ },+ CalendarUpdateScope::All,+ )+ .await+ .unwrap();++ assert_eq!(patches.lock().unwrap()[0].title.as_deref(), Some("Retro"));+ assert!(details_requests.lock().unwrap().is_empty());+}++#[tokio::test]+async fn the_organizer_changes_details_whatever_the_guest_policy() {+ let provider = FakeProvider::new(FakeProviderBehavior::Echo);+ let patches = provider.updated_patches.clone();+ let mut repo = guest_repo(GuestPolicy::default());+ repo.mutation_target.as_mut().unwrap().organizer_email = Some("[email protected]".to_string());++ update(+ repo,+ provider,+ CalendarEventPatch {+ title: Some("Retro".to_string()),+ ..CalendarEventPatch::default()+ },+ CalendarUpdateScope::All,+ )+ .await+ .unwrap();++ assert_eq!(patches.lock().unwrap()[0].title.as_deref(), Some("Retro"));+}++#[tokio::test]+async fn someone_neither_organizing_nor_invited_is_left_to_their_calendar_access() {+ let provider = FakeProvider::new(FakeProviderBehavior::Echo);+ let patches = provider.updated_patches.clone();+ let mut repo = guest_repo(GuestPolicy::default());+ // A delegate writing to the organizer's calendar holds no seat of their own.+ repo.stored_attendees+ .retain(|attendee| attendee.is_organizer);++ update(+ repo,+ provider,+ CalendarEventPatch {+ title: Some("Retro".to_string()),+ ..CalendarEventPatch::default()+ },+ CalendarUpdateScope::All,+ )+ .await+ .unwrap();++ assert_eq!(patches.lock().unwrap()[0].title.as_deref(), Some("Retro"));+}++#[tokio::test]+async fn an_occurrence_scoped_update_is_compared_with_that_occurrence() {+ let provider = FakeProvider::new(FakeProviderBehavior::Echo);+ let patches = provider.updated_patches.clone();+ let mut repo = guest_repo(GuestPolicy::default());+ let moved_starts_at = Utc.with_ymd_and_hms(2026, 8, 6, 16, 0, 0).unwrap();+ let moved = EventTime::Timed {+ starts_at: moved_starts_at,+ ends_at: moved_starts_at + Duration::hours(1),+ time_zone: None,+ };+ repo.event_details = Some(EventDetails {+ title: "Planning (moved)".to_string(),+ time: Some(moved.clone()),+ ..stored_details()+ });+ let details_requests = repo.details_requests.clone();++ update(+ repo,+ provider,+ CalendarEventPatch {+ title: Some("Planning (moved)".to_string()),+ time: Some(moved),+ reminders: Some(popup_reminders()),+ ..CalendarEventPatch::default()+ },+ CalendarUpdateScope::ThisEvent {+ recurrence_id: RECURRENCE_ID.to_string(),+ },+ )+ .await+ .unwrap();++ assert_eq!(+ details_requests.lock().unwrap().as_slice(),+ [Some(RECURRENCE_ID.to_string())]+ );+ assert_eq!(+ patches.lock().unwrap().as_slice(),+ [CalendarEventPatch {+ reminders: Some(popup_reminders()),+ ..CalendarEventPatch::default()+ }]+ );+}++#[tokio::test]+async fn an_occurrence_time_that_is_not_stored_counts_as_a_change() {+ let provider = FakeProvider::new(FakeProviderBehavior::Echo);+ let calls = provider.calls.clone();+ let mut repo = guest_repo(GuestPolicy::default());+ repo.event_details = Some(EventDetails {+ time: None,+ ..stored_details()+ });++ let error = update(+ repo,+ provider,+ CalendarEventPatch {+ time: Some(timed_time()),+ ..CalendarEventPatch::default()+ },+ CalendarUpdateScope::ThisEvent {+ recurrence_id: RECURRENCE_ID.to_string(),+ },+ )+ .await+ .unwrap_err();++ assert!(matches!(error, CalendarMutationError::GuestsCannotModify));+ assert!(calls.lock().unwrap().is_empty());+}diff --git a/crates/calendar_events/src/domain/mutations/test/invite.rs b/crates/calendar_events/src/domain/mutations/test/invite.rsindex b0767f165b..151bc4a60b 100644--- a/crates/calendar_events/src/domain/mutations/test/invite.rs+++ b/crates/calendar_events/src/domain/mutations/test/invite.rs@@ -255,7 +255,7 @@ async fn a_guests_update_adds_through_the_invite_path_and_keeps_its_other_fieldsUuid::now_v7(),None,CalendarEventPatch {- title: Some("Planning".to_string()),+ transparency: Some(EventTransparency::Transparent),// The editor leaves the viewer's own row out of the list.attendees: Some(vec![guest(ORGANIZER), guest("[email protected]")]),..CalendarEventPatch::default()@@ -278,7 +278,7 @@ async fn a_guests_update_adds_through_the_invite_path_and_keeps_its_other_fieldssent[0].attendees, None,"the replacement list never reaches Google");- assert_eq!(sent[0].title.as_deref(), Some("Planning"));+ assert_eq!(sent[0].transparency, Some(EventTransparency::Transparent));}#[tokio::test]diff --git a/crates/calendar_events/src/domain/ports.rs b/crates/calendar_events/src/domain/ports.rsindex 82137c512c..d32b479b47 100644--- a/crates/calendar_events/src/domain/ports.rs+++ b/crates/calendar_events/src/domain/ports.rs@@ -18,10 +18,11 @@ use super::models::{CalendarGrantIntent, CalendarLinkTokenIdentity, CalendarMentionPreview,CalendarMentionRequestItem, CalendarOccurrenceCursor, CalendarReminderDeliveryOutcome,CalendarReminderDispatchMessage, CalendarReminderFiring, CalendarReminderSweepSummary,- CalendarSyncStatus, DisconnectedCalendar, DueCalendarReminder, GoogleCalendarSyncSnapshot,- GoogleEventSyncBatch, GoogleScopeSet, GoogleSyncPlan, GoogleWatchChannel, GoogleWatchConfig,- GuestPolicy, OccurrenceListing, OccurrenceRange, OwnedInbox, ProviderCalendar,- ProviderCalendarTarget, StoredGoogleCalendar, TeamOutOfOffice, VisibleCalendar,+ CalendarSyncStatus, DisconnectedCalendar, DueCalendarReminder, EventDetails,+ GoogleCalendarSyncSnapshot, GoogleEventSyncBatch, GoogleScopeSet, GoogleSyncPlan,+ GoogleWatchChannel, GoogleWatchConfig, GuestPolicy, OccurrenceListing, OccurrenceRange,+ OwnedInbox, ProviderCalendar, ProviderCalendarTarget, StoredGoogleCalendar, TeamOutOfOffice,+ VisibleCalendar,};/// Classification supplied by provider adapters to backfill policy.@@ -696,6 +697,15 @@ pub trait CalendarRepository: Send + Sync + 'static {recurrence_id: &str,) -> impl Future<Output = Result<Option<Vec<CalendarAttendee>>, Report>> + Send;+ /// The stored details of a canonical event, or of one occurrence when+ /// `occurrence_key` names it: the occurrence's own content and time where+ /// it overrides the series. `None` covers an unknown event.+ fn get_event_details(+ &self,+ event_id: Uuid,+ occurrence_key: Option<&str>,+ ) -> impl Future<Output = Result<Option<EventDetails>, Report>> + Send;+/// Store the guest policy the provider reported when it refused an/// invite, on the entity and every copy's projection. Incremental sync/// resends only changed events, so the stored policy can predate the@@ -963,6 +973,9 @@ pub enum CalendarMutationError {/// whole list a guest addition must write.#[error("guests cannot be added while the organizer hides the guest list")]GuestListHidden,+ /// The organizer does not let guests change the event's details.+ #[error("the organizer doesn't let guests change this event")]+ GuestsCannotModify,/// The meeting is already on one of the requester's calendars.#[error("the event is already on one of the requester's calendars")]AlreadyOnCalendar,diff --git a/crates/calendar_events/src/domain/service/test.rs b/crates/calendar_events/src/domain/service/test.rsindex 90db45c6a7..0161c1c0ed 100644--- a/crates/calendar_events/src/domain/service/test.rs+++ b/crates/calendar_events/src/domain/service/test.rs@@ -143,6 +143,14 @@ impl CalendarRepository for FakeRepo {unreachable!("mutation lookups are not exercised by sync tests")}+ async fn get_event_details(+ &self,+ _event_id: Uuid,+ _occurrence_key: Option<&str>,+ ) -> Result<Option<crate::domain::models::EventDetails>, Report> {+ unreachable!("mutation lookups are not exercised by sync tests")+ }+async fn record_guest_policy(&self,_event_id: Uuid,diff --git a/crates/calendar_events/src/inbound/mutation_router.rs b/crates/calendar_events/src/inbound/mutation_router.rsindex 75448022ee..9de376f279 100644--- a/crates/calendar_events/src/inbound/mutation_router.rs+++ b/crates/calendar_events/src/inbound/mutation_router.rs@@ -364,6 +364,8 @@ pub enum CalendarMutationErrorCode {GuestsCannotInvite,/// The organizer hides the guest list, so a guest cannot add guests.GuestListHidden,+ /// The organizer does not let guests change the event's details.+ GuestsCannotModify,/// The meeting is already on one of the requester's calendars.AlreadyOnCalendar,/// The request was invalid.@@ -445,6 +447,11 @@ impl From<CalendarMutationError> for CalendarMutationApiError {CalendarMutationErrorCode::GuestListHidden,"Guests cannot be added while the organizer hides the guest list.".to_string(),),+ CalendarMutationError::GuestsCannotModify => (+ StatusCode::FORBIDDEN,+ CalendarMutationErrorCode::GuestsCannotModify,+ "The organizer doesn't let guests change this event.".to_string(),+ ),CalendarMutationError::AlreadyOnCalendar => (StatusCode::CONFLICT,CalendarMutationErrorCode::AlreadyOnCalendar,diff --git a/crates/calendar_events/src/inbound/mutation_router/test.rs b/crates/calendar_events/src/inbound/mutation_router/test.rsindex cc11b0334f..d987c7270d 100644--- a/crates/calendar_events/src/inbound/mutation_router/test.rs+++ b/crates/calendar_events/src/inbound/mutation_router/test.rs@@ -47,6 +47,13 @@ fn domain_errors_map_to_distinct_transport_semantics() {CalendarMutationErrorCode::GuestListHidden));+ assert_eq!(+ transport_of(CalendarMutationError::GuestsCannotModify),+ (+ StatusCode::FORBIDDEN,+ CalendarMutationErrorCode::GuestsCannotModify+ )+ );assert_eq!(transport_of(CalendarMutationError::InvalidInput("bad".to_string())),(diff --git a/crates/calendar_events/src/inbound/toolset.rs b/crates/calendar_events/src/inbound/toolset.rsindex 6eaee04fd3..19d3abefe1 100644--- a/crates/calendar_events/src/inbound/toolset.rs+++ b/crates/calendar_events/src/inbound/toolset.rs@@ -487,6 +487,12 @@ fn mutation_tool_error(action: &str, error: CalendarMutationError) -> ToolCallErSuggest asking the organizer to add them.".to_string()}+ CalendarMutationError::GuestsCannotModify => {+ "The organizer doesn't let guests change this event, so the user can only change \+ their own reminders, add guests where the organizer allows it, and answer the \+ invitation. Suggest asking the organizer to make the change."+ .to_string()+ }CalendarMutationError::AlreadyOnCalendar => {"This event is already on one of the user's calendars.".to_string()}diff --git a/crates/calendar_events/src/inbound/toolset/update_calendar_event.rs b/crates/calendar_events/src/inbound/toolset/update_calendar_event.rsindex fcb52cd5a0..21cc8043c8 100644--- a/crates/calendar_events/src/inbound/toolset/update_calendar_event.rs+++ b/crates/calendar_events/src/inbound/toolset/update_calendar_event.rs@@ -107,6 +107,12 @@ or hides the guest list, or the event is an Outlook meeting the user doesn't orgAn empty string for `description` or `location` clears it. Fails on events from calendars \the user cannot edit.\n\\n\+A guest without modify rights (`viewerCan.editDetails` false while `viewerCan.rsvp` is \+true) may only change their own `reminders`, add guests where `viewerCan.inviteGuests` \+allows it, and answer with `rsvp`; changing the title, time, description, location, \+recurrence or conference fails because the organizer doesn't let guests change the \+event.\n\+\n\`rsvp` sets the user's own response to an invitation and is independent of the field \edits — it can be the only thing this call changes. It applies at the same `scope` as \the rest of the call and answers as the connected inbox the event's copy belongs to, so \diff --git a/crates/calendar_events/src/outbound/calendar_service_mutations.rs b/crates/calendar_events/src/outbound/calendar_service_mutations.rsindex b71586cee5..dbe387b51d 100644--- a/crates/calendar_events/src/outbound/calendar_service_mutations.rs+++ b/crates/calendar_events/src/outbound/calendar_service_mutations.rs@@ -159,6 +159,7 @@ fn error_from_response(status: StatusCode, body: Option<String>) -> CalendarMuta"not_attendee" => CalendarMutationError::NotAttendee,"guests_cannot_invite" => CalendarMutationError::GuestsCannotInvite,"guest_list_hidden" => CalendarMutationError::GuestListHidden,+ "guests_cannot_modify" => CalendarMutationError::GuestsCannotModify,"already_on_calendar" => CalendarMutationError::AlreadyOnCalendar,"invalid_input" => CalendarMutationError::InvalidInput(error.message),"reauth_required" => CalendarMutationError::ReauthRequired(error.message),diff --git a/crates/calendar_events/src/outbound/calendar_service_mutations/test.rs b/crates/calendar_events/src/outbound/calendar_service_mutations/test.rsindex 8bf3f7c74c..69423dc555 100644--- a/crates/calendar_events/src/outbound/calendar_service_mutations/test.rs+++ b/crates/calendar_events/src/outbound/calendar_service_mutations/test.rs@@ -242,6 +242,7 @@ fn router_error_bodies_round_trip_to_their_domain_failures() {CalendarMutationError::NotAttendee,CalendarMutationError::GuestsCannotInvite,CalendarMutationError::GuestListHidden,+ CalendarMutationError::GuestsCannotModify,CalendarMutationError::AlreadyOnCalendar,CalendarMutationError::InvalidInput("bad".to_string()),CalendarMutationError::ReauthRequired("expired".to_string()),diff --git a/crates/calendar_events/src/outbound/pg.rs b/crates/calendar_events/src/outbound/pg.rsindex e53bd2c750..4ae05fae06 100644--- a/crates/calendar_events/src/outbound/pg.rs+++ b/crates/calendar_events/src/outbound/pg.rs@@ -1,6 +1,7 @@//! PostgreSQL implementation of the calendar repository port.mod change_log;mod changes;+mod details;mod export;mod invitations;#[cfg(feature = "outlook")]@@ -32,11 +33,11 @@ use crate::domain::{CalendarLinkTokenIdentity, CalendarMentionEvent, CalendarMentionPreview,CalendarMentionRequestItem, CalendarOccurrence, CalendarOccurrenceCursor, CalendarProvider,CalendarReminderFiring, CalendarSyncStatus, CalendarWatchRelease, ConferenceProvider,- DisconnectedCalendar, DueCalendarReminder, EventReminderOverride, EventReminders,- EventStart, EventStatus, EventTime, EventTransparency, EventType, EventVisibility,- GOOGLE_CALENDAR_SCOPES, GoogleCalendarSyncSnapshot, GoogleScopeSet, GoogleWatchChannel,- GuestPolicy, OccurrenceException, OccurrenceListing, OccurrenceRange, OwnedInbox,- ProviderCalendar, StoredGoogleCalendar, TeamOutOfOffice, ViewerCapabilities,+ DisconnectedCalendar, DueCalendarReminder, EventDetails, EventReminderOverride,+ EventReminders, EventStart, EventStatus, EventTime, EventTransparency, EventType,+ EventVisibility, GOOGLE_CALENDAR_SCOPES, GoogleCalendarSyncSnapshot, GoogleScopeSet,+ GoogleWatchChannel, GuestPolicy, OccurrenceException, OccurrenceListing, OccurrenceRange,+ OwnedInbox, ProviderCalendar, StoredGoogleCalendar, TeamOutOfOffice, ViewerCapabilities,VisibleCalendar, is_system_calendar,},ports::{@@ -2144,6 +2145,15 @@ impl CalendarRepository for PgCalendarRepository {}))}+ #[tracing::instrument(skip(self), err)]+ async fn get_event_details(+ &self,+ event_id: Uuid,+ occurrence_key: Option<&str>,+ ) -> Result<Option<EventDetails>, Report> {+ details::event_details(&self.pool, event_id, occurrence_key).await+ }+#[tracing::instrument(skip(self), err)]async fn record_guest_policy(&self, event_id: Uuid, policy: GuestPolicy) -> Result<(), Report> {let mut tx = self.pool.begin().await.map_err(report)?;diff --git a/crates/calendar_events/src/outbound/pg/details.rs b/crates/calendar_events/src/outbound/pg/details.rsnew file mode 100644index 0000000000..a23bb05627--- /dev/null+++ b/crates/calendar_events/src/outbound/pg/details.rs@@ -0,0 +1,115 @@+//! The stored details of an event or one of its occurrences, which a guest's+//! update is compared against.++use super::*;++struct DetailsRow {+ title: String,+ description: Option<String>,+ location: Option<String>,+ visibility: String,+ starts_at: Option<DateTime<Utc>>,+ ends_at: Option<DateTime<Utc>>,+ start_date: Option<NaiveDate>,+ end_date: Option<NaiveDate>,+ time_zone: Option<String>,+ recurrence_lines: Vec<String>,+ has_conference: bool,+ has_occurrence: bool,+ override_title: Option<String>,+ override_description: Option<String>,+ override_location: Option<String>,+ occurrence_starts_at: Option<DateTime<Utc>>,+ occurrence_ends_at: Option<DateTime<Utc>>,+ occurrence_start_date: Option<NaiveDate>,+ occurrence_end_date: Option<NaiveDate>,+}++pub(super) async fn event_details(+ pool: &PgPool,+ event_id: Uuid,+ occurrence_key: Option<&str>,+) -> Result<Option<EventDetails>, Report> {+ // An occurrence's time is its materialized instance, else the exception+ // that moved it; its content is the exception's where it has one.+ let row = sqlx::query_as!(+ DetailsRow,+ r#"+ SELECT+ event.title,+ event.description,+ event.location,+ event.visibility,+ event.starts_at,+ event.ends_at,+ event.start_date,+ event.end_date,+ event.time_zone,+ event.recurrence_lines,+ event.conference_url IS NOT NULL AS "has_conference!",+ $2::text IS NOT NULL AS "has_occurrence!",+ override.title AS override_title,+ override.description AS override_description,+ override.location AS override_location,+ CASE WHEN occurrence.event_id IS NULL THEN override.starts_at+ ELSE occurrence.starts_at END AS occurrence_starts_at,+ CASE WHEN occurrence.event_id IS NULL THEN override.ends_at+ ELSE occurrence.ends_at END AS occurrence_ends_at,+ CASE WHEN occurrence.event_id IS NULL THEN override.start_date+ ELSE occurrence.start_date END AS occurrence_start_date,+ CASE WHEN occurrence.event_id IS NULL THEN override.end_date+ ELSE occurrence.end_date END AS occurrence_end_date+ FROM calendar_events event+ LEFT JOIN calendar_event_occurrences occurrence+ ON occurrence.event_id = event.id+ AND occurrence.occurrence_key = $2+ LEFT JOIN calendar_event_overrides override+ ON override.event_id = event.id+ AND override.recurrence_id = $2+ WHERE event.id = $1+ "#,+ event_id,+ occurrence_key,+ )+ .fetch_optional(pool)+ .await+ .map_err(report)?;+ let Some(row) = row else {+ return Ok(None);+ };+ let time = if row.has_occurrence {+ let stored = (+ row.occurrence_starts_at,+ row.occurrence_ends_at,+ row.occurrence_start_date,+ row.occurrence_end_date,+ );+ match stored {+ (None, None, None, None) => None,+ (starts_at, ends_at, start_date, end_date) => Some(row_time(+ starts_at,+ ends_at,+ start_date,+ end_date,+ row.time_zone,+ )?),+ }+ } else {+ Some(row_time(+ row.starts_at,+ row.ends_at,+ row.start_date,+ row.end_date,+ row.time_zone,+ )?)+ };+ Ok(Some(EventDetails {+ title: row.override_title.unwrap_or(row.title),+ description: row.override_description.or(row.description),+ location: row.override_location.or(row.location),+ visibility: event_visibility(&row.visibility),+ time,+ recurrence_lines: row.recurrence_lines,+ has_conference: row.has_conference,+ }))+}diff --git a/crates/calendar_events/src/outbound/pg/test.rs b/crates/calendar_events/src/outbound/pg/test.rsindex e25df6c3a7..100a0da7a1 100644--- a/crates/calendar_events/src/outbound/pg/test.rs+++ b/crates/calendar_events/src/outbound/pg/test.rs@@ -7026,6 +7026,7 @@ async fn retiring_an_unrelated_copy_keeps_a_fresher_schedule_written_through_ano}mod changes;+mod details;mod export;mod invitations;mod source_access;diff --git a/crates/calendar_events/src/outbound/pg/test/details.rs b/crates/calendar_events/src/outbound/pg/test/details.rsnew file mode 100644index 0000000000..52d1d1eabf--- /dev/null+++ b/crates/calendar_events/src/outbound/pg/test/details.rs@@ -0,0 +1,121 @@+use super::*;++fn moved_override(+ original_start: DateTime<Utc>,+ starts_at: DateTime<Utc>,+) -> CalendarEventOverride {+ CalendarEventOverride {+ reminders: None,+ automatic_decline: None,+ visibility: None,+ transparency: None,+ sequence: None,+ source_updated_at: None,+ recurrence_id: original_start.to_rfc3339(),+ original_time: EventStart::Timed(original_start),+ time: EventTime::Timed {+ starts_at,+ ends_at: starts_at + Duration::hours(1),+ time_zone: Some("UTC".to_string()),+ },+ title: Some("Edited title".to_string()),+ description: None,+ location: None,+ status: None,+ attendees: None,+ }+}++#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]+async fn event_details_read_the_series_or_one_occurrence(pool: PgPool) {+ let owner_id = "macro|[email protected]";+ let link_id = insert_link(&pool, owner_id).await;+ let repo = PgCalendarRepository::new(pool);+ let provider = provider_ids(&repo, link_id).await;+ let mut upsert = timed_upsert(+ owner_id,+ link_id,+ provider,+ "[email protected]",+ "Series title",+ 1,+ );+ upsert.event.description = Some("Agenda".to_string());+ upsert.event.conference_url = Some("https://meet.google.com/abc-defg-hij".to_string());+ let series_time = upsert.event.time.clone();+ // The second occurrence moved an hour later; the instance Google lists+ // carries the moved time.+ let second_start = Utc.with_ymd_and_hms(2026, 7, 25, 14, 0, 0).unwrap();+ let second_moved = second_start + Duration::hours(1);+ upsert.occurrences[1].recurrence_id = Some(second_start.to_rfc3339());+ upsert.occurrences[1].time = moved_override(second_start, second_moved).time;+ // A later exception sits outside the materialized occurrences.+ let later_start = Utc.with_ymd_and_hms(2026, 9, 1, 14, 0, 0).unwrap();+ let later_moved = later_start + Duration::hours(2);+ upsert.overrides = vec![+ moved_override(second_start, second_moved),+ moved_override(later_start, later_moved),+ ];+ let event_id = upsert.event.id;+ repo.upsert_event_fixture(upsert).await.unwrap();++ let series = repo+ .get_event_details(event_id, None)+ .await+ .unwrap()+ .expect("the event exists");+ assert_eq!(+ series,+ EventDetails {+ title: "Series title".to_string(),+ description: Some("Agenda".to_string()),+ location: None,+ visibility: EventVisibility::Default,+ time: Some(series_time),+ recurrence_lines: vec!["RRULE:FREQ=DAILY;COUNT=2".to_string()],+ has_conference: true,+ }+ );++ let second = repo+ .get_event_details(event_id, Some(&second_start.to_rfc3339()))+ .await+ .unwrap()+ .expect("the event exists");+ assert_eq!(second.title, "Edited title");+ assert_eq!(+ second.description.as_deref(),+ Some("Agenda"),+ "content the exception leaves alone is the series'"+ );+ assert_eq!(+ second.time,+ Some(moved_override(second_start, second_moved).time)+ );++ let later = repo+ .get_event_details(event_id, Some(&later_start.to_rfc3339()))+ .await+ .unwrap()+ .expect("the event exists");+ assert_eq!(+ later.time,+ Some(moved_override(later_start, later_moved).time)+ );++ let unknown_occurrence = repo+ .get_event_details(event_id, Some("2027-01-01T14:00:00+00:00"))+ .await+ .unwrap()+ .expect("the event exists");+ assert_eq!(unknown_occurrence.title, "Series title");+ assert_eq!(+ unknown_occurrence.time, None,+ "an occurrence outside the stored window has no known time"+ );++ assert_eq!(+ repo.get_event_details(Uuid::now_v7(), None).await.unwrap(),+ None+ );+}diff --git a/crates/graphql_calendar/src/mutation.rs b/crates/graphql_calendar/src/mutation.rsindex 8d6034aa80..1c16c0a07d 100644--- a/crates/graphql_calendar/src/mutation.rs+++ b/crates/graphql_calendar/src/mutation.rs@@ -231,6 +231,10 @@ pub(crate) fn mutation_error(error: CalendarMutationError) -> async_graphql::Err"guest_list_hidden","Guests cannot be added while the organizer hides the guest list.".into(),),+ CalendarMutationError::GuestsCannotModify => (+ "guests_cannot_modify",+ "The organizer doesn't let guests change this event.".into(),+ ),CalendarMutationError::AlreadyOnCalendar => ("already_on_calendar","this event is already on one of your calendars".into(),diff --git a/crates/graphql_calendar/src/mutation/test.rs b/crates/graphql_calendar/src/mutation/test.rsindex 0c7573f365..121ad05a55 100644--- a/crates/graphql_calendar/src/mutation/test.rs+++ b/crates/graphql_calendar/src/mutation/test.rs@@ -797,6 +797,11 @@ async fn every_failure_carries_its_rest_code_and_hides_provider_details() {"guest_list_hidden",false,),+ (+ CalendarMutationError::GuestsCannotModify,+ "guests_cannot_modify",+ false,+ ),(CalendarMutationError::AlreadyOnCalendar,"already_on_calendar",diff --git a/docs/agent-guide/calendar.md b/docs/agent-guide/calendar.mdindex 79b6533d39..92176f8af4 100644--- a/docs/agent-guide/calendar.md+++ b/docs/agent-guide/calendar.md@@ -427,7 +427,8 @@ existing dates, time zone, title, location, description, and repeat rule unlesschanged. To verify, open a later occurrence of an event you were invited to,change the reminder, and inspect the PATCH: it should include only `reminders`plus the calendar and scope identifiers. Also verify that intentional edits to-the start, end, all-day setting, title, location, description, or repeat rule are still sent.+the start, end, all-day setting, title, location, description, or repeat rule are still sent+by the organizer or a guest the organizer lets modify the event.Test reminder removal as well as changing its time, including a series whose storedrule contains `INTERVAL=1`, `WKST`, differently ordered weekdays, or a precise `UNTIL`:an untouched rule must not be reformatted and included in a reminder-only PATCH.@@ -459,6 +460,21 @@ guest copy stays a guest copy, marked `(you)` on that inbox's row alone, even whanother connected inbox organizes the event. An Outlook guest copy never offers `Addguests` (Outlook lets only the organizer change a meeting) and shows the sameexplanation; an Outlook organizer adds guests like a Google one.+A guest the organizer does not let modify the event (`viewerCan.editDetails` false while+`viewerCan.rsvp` is true) opens an editor whose date/time, all-day, title, description,+repeat, conferencing and location controls are disabled, each with the tooltip `Only the+organizer can change this event.`; the same line shows under the pills, which is all a+touch device shows. Notifications stay editable and Save sends only `reminders` (plus any+invitation). That guest cannot drag or resize the event on the grid either. Someone+neither organizing nor invited, such as a delegate on a shared calendar, keeps what their+calendar access allows. The update refuses a detail change from such a guest with 403+`guests_cannot_modify` (fields resent at their stored value are ignored, so the agent can+pass them); the editor then shows the line in a toast and locks its details, and a refused+drag snaps back with the same toast. The refusal covers a stale `viewerCan`, an event the+viewer still sees as editable after the organizer turned modifying off, so check it without a+Google account by answering `PATCH /events/{id}` (or the GraphQL `updateCalendarEvent`+mutation) with HTTP 403 and code `guests_cannot_modify` on an event whose+`viewerCan.editDetails` is still true: only there does the editor send a detail change at all.The details header's `Download .ics` icon button, beside `Copy event`, saves the event as aniCalendar file named after its title, so it can be passed on or added to another calendar. Thefile holds the series (its repeat rule, in the event's original time zone), title, descriptiondiff --git a/packages/sdk-docs/reference/generated/calendar/types.gen/type-aliases/CalendarMutationErrorCode.md b/packages/sdk-docs/reference/generated/calendar/types.gen/type-aliases/CalendarMutationErrorCode.mdindex a1d8eed69c..11f811e373 100644--- a/packages/sdk-docs/reference/generated/calendar/types.gen/type-aliases/CalendarMutationErrorCode.md+++ b/packages/sdk-docs/reference/generated/calendar/types.gen/type-aliases/CalendarMutationErrorCode.md@@ -1,5 +1,5 @@# Type Alias: CalendarMutationErrorCode-> **CalendarMutationErrorCode** = `"not_found"` \| `"occurrence_not_found"` \| `"read_only"` \| `"no_writable_calendar"` \| `"not_attendee"` \| `"guests_cannot_invite"` \| `"guest_list_hidden"` \| `"already_on_calendar"` \| `"invalid_input"` \| `"reauth_required"` \| `"provider_rejected"` \| `"retryable"` \| `"persist_failed"` \| `"macro_call_failed"`+> **CalendarMutationErrorCode** = `"not_found"` \| `"occurrence_not_found"` \| `"read_only"` \| `"no_writable_calendar"` \| `"not_attendee"` \| `"guests_cannot_invite"` \| `"guest_list_hidden"` \| `"guests_cannot_modify"` \| `"already_on_calendar"` \| `"invalid_input"` \| `"reauth_required"` \| `"provider_rejected"` \| `"retryable"` \| `"persist_failed"` \| `"macro_call_failed"`Machine-readable failure category for calendar mutations.diff --git a/packages/sdk/generated/calendar/types.gen.ts b/packages/sdk/generated/calendar/types.gen.tsindex 9e1ed570a3..538300e546 100644--- a/packages/sdk/generated/calendar/types.gen.ts+++ b/packages/sdk/generated/calendar/types.gen.ts@@ -360,7 +360,7 @@ export type CalendarMutationApiError = {/*** Machine-readable failure category for calendar mutations.*/-export type CalendarMutationErrorCode = 'not_found' | 'occurrence_not_found' | 'read_only' | 'no_writable_calendar' | 'not_attendee' | 'guests_cannot_invite' | 'guest_list_hidden' | 'already_on_calendar' | 'invalid_input' | 'reauth_required' | 'provider_rejected' | 'retryable' | 'persist_failed' | 'macro_call_failed';+export type CalendarMutationErrorCode = 'not_found' | 'occurrence_not_found' | 'read_only' | 'no_writable_calendar' | 'not_attendee' | 'guests_cannot_invite' | 'guest_list_hidden' | 'guests_cannot_modify' | 'already_on_calendar' | 'invalid_input' | 'reauth_required' | 'provider_rejected' | 'retryable' | 'persist_failed' | 'macro_call_failed';/*** Provider selected from the persisted calendar account and email binding.diff --git a/packages/sdk/specs/calendar.json b/packages/sdk/specs/calendar.jsonindex c8b0a089dd..2c874f74d5 100644--- a/packages/sdk/specs/calendar.json+++ b/packages/sdk/specs/calendar.json@@ -1345,6 +1345,7 @@"not_attendee","guests_cannot_invite","guest_list_hidden",+ "guests_cannot_modify","already_on_calendar","invalid_input","reauth_required",