You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds events_update, following the shape of events_delete (#209):
Partial updates: only provided properties change; null clears location, notes, url, and alarms
Full events_create parity: title, start, end, calendar, location, notes, url, isAllDay, availability, alarms
Recurring events: occurrence start date + span (thisEvent | futureEvents, default thisEvent), exactly like events_delete; the recurring-without-occurrence error names the parameter to pass
Strict calendar moves: an unmatched calendar name is an error, not a silent default, and the target must allow modifications — a move into a read-only (e.g. subscribed) calendar throws before anything is mutated, instead of sitting unsaved in the shared store until the next successful save commits it
Shared helpers extracted inside CalendarService:
Alarm configuration parsing (relative/absolute/proximity + sound/email) now lives in one static builder used by both events_create and events_update
Occurrence resolution is prefix-tolerant: a detached exception from an earlier thisEvent edit carries <series-id>/RID=<n> instead of the series identifier, so events_delete's exact-match predicate could never find an already-edited occurrence again. One shared resolver (eventPossiblyDetached) serves both tools, so events_update and events_delete both accept the identifiers events_list exposes and events_update returns.
Hardening
All validation — identifier, span, occurrence, start/end, calendar and its editability, url, every alarm — completes before the first mutation, for the same reason as the calendar guard above: a throw after mutating EventKit's shared store strands the change in every later save.
Proximity alarms accept integer coordinates, which number validates and whole-degree positions make common; previously they were silently dropped (erasing an event's existing alarms on update) while the same builder bridged integer radii three lines below. Alarm type is now required in the absolute and proximity branches — a typeless {datetime} object used to validate but silently discard — while relative keeps its default.
Alarm minutes scale in Double: schema-legal large integers no longer trap the process, and the description now says which side of the event they land on (positive = before start, matching the builder and the reminders tools).
events_create rejects a present-but-wrong-shaped alarms or url the same way the update handler does (f416f84) — previously it silently ignored them.
Testing
swift format + xcodebuild (Xcode 27.0) clean
28/28 live EventKit checks against the real store, covering: property round-trips, null-clears, all three alarm kinds, all-day boundary snapping, calendar moves, thisEvent edits (target only, neighbors untouched), re-editing a detached exception, and futureEvents splits (tail day +1 edited, prior days untouched)
Notes
iCloud rotates event identifiers when an event moves calendars, and a futureEvents split creates a new tail series identifier. The tool returns the saved event's identifier, so callers always get the authoritative one back.
Error codes mirror events_delete: 1 = not authorized, 2 = validation, 3 = not found.
Adds events_update with events_create's full property surface in
partial-update form: omitted properties are unchanged, null clears
optional properties (location, notes, url, alarms). Recurring events
take an occurrence start date plus span (thisEvent/futureEvents),
mirroring events_delete.
- Extracts the alarm configuration parser from events_create into a
shared static builder used by create and update
- Extracts occurrence resolution into a prefix-tolerant helper shared
with events_delete: detached exceptions from earlier thisEvent edits
carry <series-id>/RID=<n> instead of the series identifier, so exact
matching could never find them again
- Calendar moves are strict: an unmatched calendar name is an error
- The saved event's identifier is returned, which matters because
iCloud rotates identifiers when an event moves calendars and
futureEvents splits create a new tail series identifier
- Schemas accept null for title, location, notes, url, and alarms,
matching the documented clear-on-null behavior; title null clears
- The description names exactly which properties null clears
- Identifiers returned with a detached-occurrence suffix
(<series>/RID=<n>) now resolve: when the direct lookup fails, the
series prefix is retried and the occurrence date still selects the
exact occurrence
- events_update parses start, end, calendar and url before touching the
fetched event. EventKit retains unsaved mutations in its shared store,
so a failed call could otherwise leave changes that the next
successful save commits without anyone asking for them
- a date-only absolute alarm datetime now means local midnight, as the
schema already documents for every other date parameter, instead of
being dropped with a log line — in the update path a dropped alarm
config would remove existing alarms and report success
- events_delete accepts the detached-exception identifiers
events_list exposes and events_update produces: the direct lookup
falls back to the series prefix, and the start date still selects
the exact occurrence, mirroring events_update
- The recurring-event error names the occurrence parameter, so a
client retrying with the message's guidance no longer hits the same
error through start, which means the new start time
…aring
- Proximity alarms accept integer latitude/longitude, which .number()
validates and whole-degree coordinates make common; the shared
builder dropped them (silently erasing an event's existing alarms
in events_update) while bridging radius three lines below
- The absolute and proximity branches now require type: without it a
validating client's {"datetime": ...} object fell through to the
relative default and was silently discarded. The relative branch
keeps type optional since it carries the default
…detached resolver
- The calendar-name match for a move now requires
allowsContentModifications, so a read-only target (a subscribed
calendar) throws before any mutation instead of leaving the move
unsaved in the shared store for the next successful save to commit
- Alarm minutes scale in Double, matching the reminders fix: Int
arithmetic traps at Int.min and past ~1.5e17, crashing the whole
server on one tool call
- The /RID= detached-identifier fallback is one helper now,
eventPossiblyDetached(_:), instead of the same 12-line closure
twice in events_update and events_delete
The builder maps minutes to -minutes * 60 seconds, so positive
minutes fire before the event start and negative after — the
opposite of the old description in both schema copies. Align the
text with the behavior and with the reminders tools' "minutes
before" wording.
inputSchema is advertised, not enforced, so the update handler now
type-checks every present argument (span, occurrence, start, end,
calendar, url, title, location, notes, availability including enum
membership, isAllDay, alarms) and throws before anything is resolved
or mutated. An event whose current calendar disallows modifications
is rejected up front, and the effective start/end range is checked
before mutation so EventKit cannot fail at save with the shared event
already changed. The alarm builder is now throwing and builds the
complete replacement list before the first mutation in both
events_update and events_create, so a malformed entry can no longer
quietly wipe alarms through compactMap. URLs must carry a scheme,
matching the advertised .uri format, and proximity coordinates and
radii are bounds-checked in code and schema.
The update handler rejects a present argument of the wrong shape;
create silently ignored alarms: "bad" or url: 42. Same class of bug,
same fix: throw instead of creating an event without them.
Follow-up in f416f84: events_create now rejects wrong-shaped alarms (non-array) and url (non-string) instead of silently ignoring them — the same present-but-wrong-shape rejection the update handler got.
Alarm builder errors carried code 4, but this PR's documented contract
(and events_delete) uses 1/2/3; every alarm(from:) failure is now code
2. A present non-string alarm type no longer folds into the relative
default, matching the schemas the tools advertise. Proximity radius
distinguishes an absent value — now applying the 200 m default the
schema documents, instead of leaving a zero-radius geofence — from a
malformed one, which is rejected. Whole-day boundary normalization
follows the event's effective all-day state, so an already-all-day
event whose end moves without isAllDay being resent snaps to 23:59:59
instead of keeping a local-midnight end that can make it zero-length.
additionalProperties: false is only advertised; this handler never rejects unknown argument names. A request such as {identifier, notes, notez} therefore succeeds while silently ignoring the typo, even though Service.call forwards the dictionary without schema validation. Validate the key set before processing so partial updates cannot report success after dropping requested input.
Reject recurring updates with no mutable event fields
App/Services/Calendar.swift:1167
A recurring update is allowed to contain only identifier and occurrence/span, so this mutation block eventually saves an unchanged occurrence. Saving with .thisEvent can create a detached exception, while .futureEvents can split the series, meaning a request with no property update still changes recurrence structure. Reject requests that contain none of the mutable event fields before touching the event.
Reject unknown or inapplicable alarm fields
App/Services/Calendar.swift:1317
The alarm schemas also rely on additionalProperties: false, but the builder validates only fields it reads. Extra or branch-inapplicable fields are silently ignored—for example, a valid relative alarm with a misspelled emailAdress is saved without email while the call reports success. Reject keys not allowed for the selected alarm type before constructing it.
Resolve calendar by title before checking editability
App/Services/Calendar.swift:1073
Filtering on editability inside the title lookup conflates two distinct failures. If a subscribed calendar with this exact title exists, the tool reports No calendar named ..., which is false and prevents callers from understanding why the move was rejected. Resolve by title first, then issue the existing non-modifiable-calendar error when appropriate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #129
What
Adds
events_update, following the shape ofevents_delete(#209):nullclearslocation,notes,url, andalarmsevents_createparity: title, start, end, calendar, location, notes, url, isAllDay, availability, alarmsoccurrencestart date +span(thisEvent|futureEvents, defaultthisEvent), exactly likeevents_delete; the recurring-without-occurrenceerror names the parameter to passShared helpers extracted inside
CalendarService:events_createandevents_updatethisEventedit carries<series-id>/RID=<n>instead of the series identifier, soevents_delete's exact-match predicate could never find an already-edited occurrence again. One shared resolver (eventPossiblyDetached) serves both tools, soevents_updateandevents_deleteboth accept the identifiersevents_listexposes andevents_updatereturns.Hardening
numbervalidates and whole-degree positions make common; previously they were silently dropped (erasing an event's existing alarms on update) while the same builder bridged integer radii three lines below. Alarmtypeis now required in the absolute and proximity branches — a typeless{datetime}object used to validate but silently discard — while relative keeps its default.Double: schema-legal large integers no longer trap the process, and the description now says which side of the event they land on (positive = before start, matching the builder and the reminders tools).events_createrejects a present-but-wrong-shapedalarmsorurlthe same way the update handler does (f416f84) — previously it silently ignored them.Testing
swift format+xcodebuild(Xcode 27.0) cleanthisEventedits (target only, neighbors untouched), re-editing a detached exception, andfutureEventssplits (tail day +1 edited, prior days untouched)Notes
futureEventssplit creates a new tail series identifier. The tool returns the saved event's identifier, so callers always get the authoritative one back.events_delete: 1 = not authorized, 2 = validation, 3 = not found.