Skip to content

Reminders: named views, search paging, batch writes, strict address alarms, and list colors - #378

Merged
mattt merged 5 commits into
mattt:mainfrom
oliverames:pr/reminders
Nov 22, 2026
Merged

mattt merged 5 commits into
mattt:mainfrom
oliverames:pr/reminders

Conversation

@oliverames

@oliverames oliverames commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

This is #359 cut as one PR so it can merge on its own. It is public EventKit and MapKit only: the private ReminderKit tools stay on my fork and are not part of this PR. No stacking: this is based on current main and depends on no other open PR.

iMCP's Reminders tools cover the basics, but an agent can't ask for today's or overdue reminders, page through search results, look up one reminder or list, or complete and delete in batches. viticci/remctl was the design reference for what a Reminders MCP should cover. None of its code is used.

What changed

  • New tools: reminders_today, reminders_upcoming, reminders_overdue, reminders_search (titles, notes and URLs, ignoring case and accents, with limit, offset, total, hasMore and nextOffset), reminders_get, reminders_lists_get, reminders_lists_update, reminders_complete and reminders_delete_batch (up to 50 identifiers, per-id results, no retry of a write that may have landed), and reminders_resolve_location, which refuses ambiguous or imprecise addresses.
  • Existing tools keep their schemas and accept more: due as an all-day date, a timed date or ISO with an offset; priority by name or Apple number; recurrence as strings such as weekly mon,wed,fri or monthly 4th-fri; alarms as 15m, 1h, 1d or a date; completion_date; and list color.
  • Behavior change: a date-only due is now all-day. It used to mean local midnight.
  • The pure logic lives in RemindersQuery.swift, with unit tests.

Review fixes

  • Reading a stored relative alarm clamps the offset to the same 100-year limit that parsing uses, instead of trapping, and the "after due date" label is built from the magnitude, so an offset of exactly 2^63 seconds or one far past the due date can't trap either.
  • All-day and timed dues carry the reminder's own calendar and time zone, and timed dues keep their seconds. Views read a due date in its stored time zone instead of replacing it.
  • A location alarm's house number is part of the street match, and a bare locality such as "Rome" is no longer accepted as a place.
  • reminders_complete is gated by reminders_update, and a list rename by reminders_lists_rename. Both refuse before EventKit is touched.
  • A complete whose readback finds no reminder reports an uncertain result, and the batch stops.
  • reminders_update accepts completion_date.
  • The batch-delete test drives the tool itself rather than the settings helper, so removing the guard fails it.
  • When a delete in a batch fails or can't be confirmed, the batch resets its event store before going on, so a later commit in the same batch can't apply a delete that was reported as failed.

Testing

  • imcp-serverTests: 216 tests, 1 skipped (pre-existing), 0 failures. RemindersQueryTests covers the tool-level gating, the address, due-date and alarm cases, extreme stored alarm offsets, and a stored time zone read with view and calendar zones that differ from it. swift format lint --strict is clean on the changed files.
  • CI: both jobs pass.

Not verified

  • The iMCP app scheme could not be built on my Mac from this branch: the iMCP Helper target uses Mattt's team for signing and this Mac has no profile for it. The test target compiles the changed service files, so the code is type-checked, but the full app build is left to CI.
  • Batches of more than one id, including the store reset after a failed delete, which needs a real EventKit failure. Location alarms against the live geocoder, and reminders_resolve_location beyond the synthetic-candidate tests.
  • List colors: whether Reminders keeps an arbitrary hex color.
  • Completing a repeating reminder leaves a separate completed copy behind, which is how EventKit handles it. A caller that completes and then deletes has to remove that copy too.

Replaces #359.

…larms, list colors

Adds reminders_today, reminders_upcoming, reminders_overdue, reminders_search,
reminders_get, reminders_lists_get, reminders_lists_update, reminders_complete,
reminders_delete_batch, and reminders_resolve_location. Extends create/update
with all-day and timed due strings, priority numbers, recurrence strings,
alarm strings, address-based location alarms, and completion_date. Pure logic
lives in RemindersQuery.swift with unit tests.

Behavior follows viticci/remctl (MIT).
@mattt

mattt commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Following up from #364, the two main fixes for 798d07f: a large relative alarm overflows in parseAlarm, and the batch tool can delete when reminders_delete is disabled.

@oliverames oliverames changed the title Reminders: views, search, batches, richer fields, and private ReminderKit tools Reminders: named views, search paging, batch writes, strict address alarms, and list colors Nov 20, 2026
@oliverames

oliverames commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

@mattt Dropped the ReminderKit commit (keeping that on my fork) and fixed both issues in the EventKit commit: parseAlarm now checks for integer overflow on large relative alarms instead of trapping, and reminders_delete_batch refuses to run when reminders_delete is disabled, with unit tests for both. Ready for another look.

@mattt

mattt commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Thanks, @oliverames. Both fixes are in. I only passed along two findings last time, and I should have sent the rest then. Sorry about that. Here's what's left before I merge:

  • Reading a stored alarm can still trap. A numeric alarm skips the new limit, and Int((-alarm.relativeOffset / 60).rounded()) traps on a value that's out of range.
  • Due dates: all-day components have no calendar, which EKReminder requires, and timed ones use the user's calendar and drop seconds. Views also overwrite the stored time zone.
  • A location alarm ignores the house number, and a bare locality like "Rome" passes as both place and town.
  • reminders_complete still works when reminders_update is disabled, and reminders_lists_update can rename when reminders_lists_rename is disabled.
  • reminders_complete keeps going after a reminder is missing on readback. It should report an uncertain result and stop.
  • reminders_update rejects completion_date.

The test for reminders_delete_batch also passes with the handler's guard removed, since it only calls the settings helper. Could it go through the tool?

Mattt's pre-merge findings on mattt#378:

- Read a stored relative alarm without trapping: an offset too large for
  an Int clamps instead of crashing.
- All-day and timed dues carry the reminder's calendar and time zone, and
  timed dues keep their seconds. Views read a due date in its stored time
  zone instead of overwriting it.
- A location alarm's house number is part of the street match, and a bare
  locality such as "Rome" is no longer accepted as a place.
- reminders_complete is gated by reminders_update, and a list rename by
  reminders_lists_rename. Both refuse before touching EventKit.
- A complete whose readback finds no reminder reports an uncertain result
  and stops the batch.
- reminders_update accepts completion_date.
- The batch-delete test drives the tool itself instead of the settings
  helper, so removing the guard fails it.

The test target now compiles Reminders.swift and the two extension files
it needs, so the tool-level tests exercise the real handlers.
oliverames pushed a commit to oliverames/iMCP that referenced this pull request Nov 20, 2026
@oliverames

oliverames commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks @mattt. All seven are fixed.

Reading a stored relative alarm clamps an offset that doesn't fit an Int instead of trapping. All-day and timed dues carry the reminder's own calendar and time zone now, and timed dues keep their seconds. Views read a due date in the time zone it was stored with instead of replacing it.

The house number is part of the street match, and a bare locality like "Rome" isn't accepted as a place anymore. reminders_complete is gated by reminders_update, and a list rename is gated by reminders_lists_rename, both before EventKit gets touched. A complete that can't find the reminder on readback reports an uncertain result and stops the batch. reminders_update takes completion_date. The batch-delete test goes through the tool itself now, so removing the guard fails it.

imcp-serverTests is at 215 tests with 1 skipped and no failures, and format is clean. The branch is public EventKit only; the private ReminderKit commit was never on it.

@oliverames

oliverames commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

@mattt The macOS 26 job is failing on the stale Helper module cache described in #393, which is the runner image moving to Xcode 26.0.1. The macOS 27 job passes, and #393's macOS 26 job is green. Once #393 lands I'll rebase onto main and this job should go green.

oliverames pushed a commit to oliverames/iMCP that referenced this pull request Nov 20, 2026
The fork's integration build still had the pre-review code for the
Reminders, Notes and AppleScript helper work. Bring in the same fixes
Mattt is reviewing upstream:

- Reminders: clamp stored relative alarms instead of trapping; carry the
  reminder's calendar and time zone on all-day and timed dues and keep
  seconds; read views in the stored time zone; include the house number
  in the street match and reject a bare locality; gate complete by
  reminders_update and rename by reminders_lists_rename; report an
  uncertain result when a complete's readback finds no reminder; accept
  completion_date on update; use the database tag records for notes_tags.
- Notes: count scannedNoteCount against the scan budget and cap the page
  request by what is left; keep unreadableNoteIDs whether or not they
  matched; read tag filters from the database tag records; stop
  overwriting keywords from note text; don't pad short table rows; drop
  TagTally.
- AppleScript: make beforeSending @sendable, drop nonisolated(unsafe),
  and check cancellation after the hook returns.

781 tests, 0 failures; format clean; the app builds.
oliverames pushed a commit to oliverames/iMCP that referenced this pull request Nov 20, 2026
…, pin the view time zone test

Clamp relativeAlarmMinutes to the parsing cap and build the label from the magnitude so extreme stored offsets cannot trap. Reset the shared store after a failed or uncertain batch delete so a later commit cannot apply it. Make the view time zone test independent of the machine zone.
@oliverames

Copy link
Copy Markdown
Contributor Author

@mattt I went back over this before your next pass and found two more things, both fixed.

The stored-alarm clamp I added could still trap. Double(Int.max) rounds up to 2^63, so an offset of exactly that size got past the check, and a large offset after the due date clamped to Int.min and then trapped when the label negated it. Stored alarms now clamp to the same 100-year limit that parsing uses, and the label is built from the magnitude. There are tests for 2^63, both infinities and NaN.

reminders_delete_batch shares one event store across the batch, so a remove that threw could stay pending and get committed by the next item's delete, deleting something the result said had failed. The batch now resets the store after a failed or unconfirmed delete. I couldn't drive a real EventKit failure in a test, and the description says so.

I also made the time zone view test use fixed zones, since it passed on my Mac in Eastern time whether or not the fix was there. imcp-serverTests is at 216 with 1 skipped and no failures.

@mattt

mattt commented Nov 21, 2026

Copy link
Copy Markdown
Owner

Thanks, @oliverames. The alarm, disabled-tool, readback, and completion_date fixes all look good. One thing is left before I merge.

calendar(for:) now uses reminder.timeZone ?? .current, so a due of YYYY-MM-DD HH:MM is read in the reminder's stored time zone, not in local time as the schema says. For a reminder saved in Los Angeles and edited on a Mac in Tokyo, "09:00" becomes 09:00 in Los Angeles. A date-only start can also land on the day before when the stored zone is west of the Mac's. And all-day due components now carry a timeZone, so they're no longer floating; EKReminder.h says a nil time zone means a floating date.

Could you build the Gregorian calendar with .current, leave timeZone nil on date-only components, and update testDueComponentsCarryCalendarAndSeconds to match?

@oliverames

oliverames commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor Author

@mattt I made all three changes in 82ac301. calendar(for:) is gone, and I now read new dates in a Gregorian calendar set to .current, so "09:00" means 09:00 on the Mac that sent it. Date-only due and start components keep the calendar but leave timeZone nil, so they're floating again. testDueComponentsCarryCalendarAndSeconds now checks that an all-day due has no time zone and keeps its day.

oliverames pushed a commit to oliverames/iMCP that referenced this pull request Nov 21, 2026
@mattt
mattt merged commit 82a5284 into mattt:main Nov 22, 2026
2 checks passed
@oliverames
oliverames deleted the pr/reminders branch November 25, 2026 15:12
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.

2 participants