Skip to content

Add recurrence and completion details to reminders - #272

Merged
mattt merged 38 commits into
mattt:mainfrom
bradhallett:reminders-recurrence
Oct 13, 2026
Merged

mattt merged 38 commits into
mattt:mainfrom
bradhallett:reminders-recurrence

Conversation

@bradhallett

@bradhallett bradhallett commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #267

Stacked on #271 (shared file/README line; rebased onto its current tip, happy to rebase again once it merges).

What

  • reminders_create and reminders_update accept a recurrence object: {frequency: daily|weekly|monthly|yearly, interval, daysOfTheWeek, daysOfTheMonth, monthsOfTheYear, weeksOfTheYear, daysOfTheYear, setPositions, end: {date} | {count}} — the full EKRecurrenceRule surface. Day names take ordinals for one-weekday-of-the-month rules ("second tuesday", "last friday"); date-only end dates include that whole day, matching the existing date-range conventions; end takes a date or a count, never both; null clears the rule on update.
  • reminders_fetch returns the same recurrence fields EventKit reports (emitted shapes stay inside the accepted vocabulary, so a fetched rule can be passed back to create/update), plus completedAt (ISO 8601, local timezone) layered onto the existing PlanAction fields. completedAt is omitted when unknown — EventKit can report a completed reminder without a completion date when it was completed by another client.
  • Completed occurrences remain fetchable through the existing completed filter, which matches by completion date; date ranges for incomplete reminders match by due date, unchanged.

Hardening

  • Rules synced from foreign calendars can carry values outside the schema's vocabulary (a month outside 1–12, a BYDAY ordinal beyond ±5). Those degrade to "unknown" in the output instead of trapping the service or emitting a misleading value that silently changes the rule on a round-trip.
  • Every integer parameter accepts the integral doubles JSON Schema counts as integers (2.0), converting with Int(exactly:) so a schema-legal but out-of-range value errors instead of trapping; zero is rejected where it has no meaning, and the descriptions say so.
  • An end object with neither date nor count — or both — is an error naming what to pass, never a silently infinite rule.
  • Every nested field rejects a present value of the wrong shape: daysOfTheWeek and monthsOfTheYear must be arrays, the integer arrays must be arrays, end must be an object, and a non-string frequency reports its type — never a value silently parsed as absent (2e2a4ad).

Testing

  • swift format lint --strict and xcodebuild -scheme iMCP build pass.
  • Live EventKit script on macOS 27.2, 18/18 checks: mapping round-trips (EKRecurrenceFrequency parse/string, EKRecurrenceDayOfWeek names, priority, lenient date-only parse with end-of-day normalization); created a daily reminder with a 3-occurrence end, completed one occurrence — the series advanced by exactly one day, the completed occurrence was retained with a completion date and fetched via predicateForCompletedReminders, and the history occurrence survived deletion of the advanced series item. List create/rename/delete also verified.

reminders_update edits an existing reminder by identifier with the same
properties as reminders_create plus completion state; omitted properties
are unchanged and null clears them. reminders_delete removes a reminder.
reminders_lists_create, reminders_lists_rename, and reminders_lists_delete
manage lists, which now expose an identifier. reminders_create also gains
URL and start-date properties, and its alarms parameter accepts relative,
absolute, and proximity alarms like events_create.

EventKit accepts EKCalendarItem.location on reminders but the store does
not persist it, so it is not exposed.

Fixes mattt#140
- Alarms accept bare integers again (minutes before due), so callers
  written against the original schema keep working; unparseable alarm
  configurations are now an error instead of being silently dropped
- Proximity alarms take a free-text location, geocoded with Maps, as an
  alternative to explicit coordinates
- Numeric alarm fields accept whole numbers for latitude, longitude,
  and radius alike
- Nullable properties (notes, url, start, due, alarms) accept null in
  their schemas, matching the documented clear-on-null behavior
- List lookup by name errors when several lists share the name instead
  of acting on an arbitrary match
- Alarm objects now require "type": without it, absolute and proximity
  configurations were schema-valid but routed as relative and rejected
  with an error about minutes the caller never sent
- A proximity alarm's radius falls back to the documented 200 m instead
  of EKStructuredLocation's zero-radius default, which never triggers
- reminders_update resolves and validates everything before mutating
  the reminder, and moves the list change after apply: EventKit keeps
  unsaved mutations in its shared store, so a failed call could
  otherwise be committed by the next successful save
- The "list" argument accepts a list identifier, so the ambiguous-name
  error's instruction is no longer a dead end for create and update
- An integral-double minutes value (30.0) is accepted like JSON Schema's
  integer does; an unknown alarm sound throws instead of silently
  arming a silent alarm
- reminders_update checks list modifiability before mutating anything:
  the reminder's list (or the move target) is known up front, and
  throwing after apply would leave unsaved mutations in the shared
  store for the next successful save to commit
- The bare alarm form accepts an integral double (30.0), like the
  object form already did; both convert with Int(exactly:) so a
  schema-legal but out-of-range value errors instead of trapping
- The update tool no longer advertises priority's create-time default
  of "none": omitting a property means leave unchanged, and a client
  honoring the advertised default would wipe priorities untouched
- OrderedDictionary.merging calls uniquingKeysWith as (existing,
  incoming); the closures passed (new, old), so the update tool's
  priority entry — added to drop create's default — was discarded and
  the default kept being advertised. Swap the argument order at all
  three call sites
- Alarm minutes convert to Double before scaling by 60: a
  schema-legal Int64 like 9_223_372_036_854_775_807 passed Int(exactly:)
  but trapped in minutes * 60, killing the process — and Int.min also
  trapped on the leading negation
- The shared list description is neutral; create documents its
  unmatched-name fallback to the default list and update documents
  that the name must match an existing list

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Recurrence inputs can bypass advertised schema constraints and silently produce different schedules.

1 open finding
What changed in this PR

Adds recurring reminder support and completion metadata while extending reminder management capabilities.

Changes:

  • Adds recurrence parsing, serialization, and completion timestamps.
  • Adds recurrence frequency and weekday conversions.
  • Updates Reminders documentation.
File Description
README.md Documents expanded reminder capabilities.
App/​Services/​Reminders.swift Implements recurrence, completion details, updates, deletion, and list management.
App/​Extensions/​EventKit+Extensions.swift Adds recurrence value mappings.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread App/Services/Reminders.swift Resolved
Validate every supplied create/update property instead of treating
wrong-typed values as omitted: title, notes, url, start, due, priority
(including enum membership), completed, alarms, and list now throw
before anything is mutated. Explicit proximity-alarm coordinates are
checked against geographic ranges, negative radii are rejected (zero
stays the system-default request), and the schemas advertise the same
bounds. Create/update are marked openWorldHint because proximity
alarms can geocode through Maps.
@bradhallett

Copy link
Copy Markdown
Contributor Author

Follow-up hardening in 2e2a4ad: the wrong-shape rejection now covers nested recurrence fields too — daysOfTheWeek/monthsOfTheYear/daysOfTheMonth/weeksOfTheYear/daysOfTheYear/setPositions must be arrays when present, end must be an object, and a non-string frequency now reports its type instead of claiming to be missing. Previously a present-but-wrong-shape nested value parsed as absent and built a rule without it — the same bug class as the top-level case.

due and start already normalize date-only values to local midnight, and
the alarm configurations advertise parity with events_create, whose
builder does the same — but the absolute branch rejected them. Accept
date-only datetimes as midnight on that same rule.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Runtime recurrence validation currently permits unknown properties and out-of-range values that can silently alter saved rules.

2 open findings
1 resolved since last review

🧠 Review effort: Balanced

Comment thread App/Services/Reminders.swift Resolved
Comment thread App/Services/Reminders.swift Resolved
A present-but-malformed list identifier fell through to the name
fallback, so {identifier: 123, name: \"Work\"} deleted the named list
instead of rejecting the preferred selector; both selectors now reject
a present value of the wrong shape before any resolution. Nested alarm
objects get the same treatment the top level already had: a non-string
type no longer folds into the relative default, unknown keys are
rejected per the advertised additionalProperties: false, a string
radius no longer silently becomes the 200 m default, an unsupported
proximity string no longer folds into .enter, non-string sound and
emailAddress are errors, and mixing the location query and coordinate
variants is rejected. URLs must be absolute (carry a scheme), matching
the .uri format the schema already advertises, and reminders_create
now rejects update-only properties like completed because inputSchema
is advertised, not enforced. The rename and delete list schemas carry
an anyOf requirement for identifier or name so a request carrying
neither is advertised as invalid, which the handler already enforced.
reminders_create accepts a recurrence rule with a frequency, interval,
and an optional end date or occurrence count, and reminders_fetch and
reminders_create now return the recurrence details and completion date
alongside the existing PlanAction fields. Completed occurrences of
recurring reminders remain fetchable with the completed filter, which
matches by completion date.

Fixes mattt#267
- completedAt and recurrence end dates are emitted as bare ISO 8601
  strings: the ontology encoder wraps root-level DateTime values in a
  JSON-LD object, which the recurrence input schema rejects, so a
  listed rule could not be passed back to reminders_update
- daysOfTheWeek accepts and emits ordinal-prefixed names ("second
  tuesday", "last friday"), so rules from Reminders.app that repeat
  on one weekday of the month survive a read-modify-write
- daysOfTheMonth, monthsOfTheYear, weeksOfTheYear, daysOfTheYear and
  setPositions are accepted and emitted, covering the EKRecurrenceRule
  surface instead of silently dropping those parts
- a date-only recurrence end date covers that whole day: EKRecurrenceEnd
  treats its date as the last allowed start (inclusive, like RFC 5545
  UNTIL), so stopping at midnight could drop the day's occurrence
- a non-integer interval is rejected like count instead of silently
  falling back to 1
- interval, end.count and the integer array parameters accept the
  integral doubles JSON Schema counts as integers (2.0), converting
  with Int(exactly:) so an out-of-range value errors instead of
  trapping
- A monthsOfTheYear value outside 1-12, as rules synced from foreign
  calendars can carry, degrades to "unknown" instead of crashing
  reminders_fetch
- The integer-array descriptions say nonzero, matching the runtime
  rejection of 0 that the numeric ranges alone cannot express
- An empty end object reports that date or count is required, not that
  both were passed
A week number beyond the ±5/last vocabulary (which foreign calendars
can carry, the same path that motivated the months guard) is not
representable; emitting the bare day name silently turned
"second-to-last tuesday" into "every tuesday" on a round-trip.
Emit "unknown" like the other foreign-value degrades.
weekNumber 0 is the bare every-week form, not an out-of-vocabulary
ordinal; the unknown degrade must not touch it. Emit the bare day
name before the ordinal switch so weekly rules round-trip and
reminders_fetch keeps emitting "tuesday" rather than "unknown".
A supplied recurrence of any shape other than object or null was
treated as if the field were omitted, silently creating or leaving a
non-recurring reminder. The input schema is advertised, not enforced,
so apply now distinguishes an absent key from an invalid value and
throws for the latter.
The recurrence fix rejected a wrong-shaped recurrence value itself, but
inside the object, daysOfTheWeek: "tuesday", monthsOfTheYear: "january",
end: "2027-01-01", or a scalar in place of any other array still parsed
as absent — building a rule without them. Same class, same fix: every
nested field now distinguishes absent from present-and-wrong-shape, and
frequency: 5 reports its type instead of claiming to be missing.
The recurrence object declares additionalProperties: false, but the
parser ignored unknown keys, so {interva: 2} built an interval-1 rule
and reported success. Keys outside the recurrence vocabulary — and
inside the end object — are now errors, matching what the schema
advertises. The integer arrays also enforce their advertised bounds:
EventKit silently drops out-of-range recurrence values, so
daysOfTheMonth: [32], weeksOfTheYear: [54], or setPositions: [367]
previously saved a rule different from the request while the tool
reported success; each field now rejects values outside the range its
schema entry advertises.
Apple's documentation for EKStructuredLocation.radius says
to set it to 0 to use the default radius, and gives no value for that default.
An absent radius now stays 0 instead of becoming 200 meters,
and the alarm schemas no longer advertise a 200-meter default.
Present values are validated as before.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Valid negative weekday ordinals cannot currently be represented or round-tripped.

1 open finding
2 resolved since last review

🧠 Review effort: Balanced

Comment thread App/Services/Reminders.swift Resolved
reminders_delete, reminders_lists_create, reminders_lists_rename,
and reminders_lists_delete advertise additionalProperties: false but
never enforced it at runtime, so a typo key rode along while the
request still deleted or created what it named. Each handler now
rejects unknown keys before resolving or touching anything, matching
the schema exactly.
reminders_create accepts a recurrence rule with a frequency, interval,
and an optional end date or occurrence count, and reminders_fetch and
reminders_create now return the recurrence details and completion date
alongside the existing PlanAction fields. Completed occurrences of
recurring reminders remain fetchable with the completed filter, which
matches by completion date.

Fixes mattt#267
- completedAt and recurrence end dates are emitted as bare ISO 8601
  strings: the ontology encoder wraps root-level DateTime values in a
  JSON-LD object, which the recurrence input schema rejects, so a
  listed rule could not be passed back to reminders_update
- daysOfTheWeek accepts and emits ordinal-prefixed names ("second
  tuesday", "last friday"), so rules from Reminders.app that repeat
  on one weekday of the month survive a read-modify-write
- daysOfTheMonth, monthsOfTheYear, weeksOfTheYear, daysOfTheYear and
  setPositions are accepted and emitted, covering the EKRecurrenceRule
  surface instead of silently dropping those parts
- a date-only recurrence end date covers that whole day: EKRecurrenceEnd
  treats its date as the last allowed start (inclusive, like RFC 5545
  UNTIL), so stopping at midnight could drop the day's occurrence
- a non-integer interval is rejected like count instead of silently
  falling back to 1
- interval, end.count and the integer array parameters accept the
  integral doubles JSON Schema counts as integers (2.0), converting
  with Int(exactly:) so an out-of-range value errors instead of
  trapping
- A monthsOfTheYear value outside 1-12, as rules synced from foreign
  calendars can carry, degrades to "unknown" instead of crashing
  reminders_fetch
- The integer-array descriptions say nonzero, matching the runtime
  rejection of 0 that the numeric ranges alone cannot express
- An empty end object reports that date or count is required, not that
  both were passed
A week number beyond the ±5/last vocabulary (which foreign calendars
can carry, the same path that motivated the months guard) is not
representable; emitting the bare day name silently turned
"second-to-last tuesday" into "every tuesday" on a round-trip.
Emit "unknown" like the other foreign-value degrades.
weekNumber 0 is the bare every-week form, not an out-of-vocabulary
ordinal; the unknown degrade must not touch it. Emit the bare day
name before the ordinal switch so weekly rules round-trip and
reminders_fetch keeps emitting "tuesday" rather than "unknown".
A supplied recurrence of any shape other than object or null was
treated as if the field were omitted, silently creating or leaving a
non-recurring reminder. The input schema is advertised, not enforced,
so apply now distinguishes an absent key from an invalid value and
throws for the latter.
The recurrence fix rejected a wrong-shaped recurrence value itself, but
inside the object, daysOfTheWeek: "tuesday", monthsOfTheYear: "january",
end: "2027-01-01", or a scalar in place of any other array still parsed
as absent — building a rule without them. Same class, same fix: every
nested field now distinguishes absent from present-and-wrong-shape, and
frequency: 5 reports its type instead of claiming to be missing.
The recurrence object declares additionalProperties: false, but the
parser ignored unknown keys, so {interva: 2} built an interval-1 rule
and reported success. Keys outside the recurrence vocabulary — and
inside the end object — are now errors, matching what the schema
advertises. The integer arrays also enforce their advertised bounds:
EventKit silently drops out-of-range recurrence values, so
daysOfTheMonth: [32], weeksOfTheYear: [54], or setPositions: [367]
previously saved a rule different from the request while the tool
reported success; each field now rejects values outside the range its
schema entry advertises.
EventKit accepts weekNumber -2 through -5 for the second-to-last
through fifth-to-last weekday of a month, but the vocabulary named
only first through fifth and last: namedValue emitted "unknown" for
those rules and day(named:) could not parse them back, so a foreign
calendar's rule could not round-trip. Both directions now carry
second-to-last through fifth-to-last, the schema enum and
descriptions advertise them, and ordinals beyond ±5 still degrade.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The extensive stacked EventKit changes and documented round-trip caveat merit final human review.

1 open finding
Previously missed (1)

In code that hasn't changed since last review

Low severity Clarify round-trip guarantee excludes unrepresentable rules

App/​Services/​Reminders.swift:1493

This round-trip guarantee is not true for every emitted rule: value(for:) emits "unknown" for an out-of-range month, and namedValue does the same for unsupported weekday ordinals, while recurrenceRule(from:) rejects both values. Since that degradation is intentional, qualify this documentation so callers know that only representable rules can be passed back unchanged.

🧠 Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A failed list rename can remain pending and be committed by a later EventKit save.

1 open finding
1 resolved since last review

🧠 Review effort: Balanced

Comment thread App/Services/Reminders.swift Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Unsupported recurrence field combinations can be silently discarded by EventKit, producing schedules different from the request.

0 open findings

1 resolved since last review
Previously missed (1)

In code that hasn't changed since last review

Medium severity Validate recurrence fields against frequency before constructing rules

App/​Services/​Reminders.swift:1429

This constructor accepts combinations that EventKit explicitly ignores, so the tool can report success after saving a different schedule. For example, frequency: "daily" with daysOfTheWeek, or setPositions without any selector array, is accepted here but EventKit drops those fields; daysOfTheMonth is monthly-only, while the month/week/year arrays are yearly-only. Validate the field/frequency combinations (including ordinal weekdays) before constructing the rule and reject unsupported combinations instead of silently narrowing them.

🧠 Review effort: Balanced

@mattt
mattt merged commit 1dad0c6 into mattt:main Oct 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support recurring reminders and completion history

3 participants