Repository navigation
Add Notes read filters, accounts, stats, attachments, and create - #384
Conversation
|
Following up from #364, for |
|
@mattt Rebased onto the updated #377, kept only the read filters and create commits (keeping edit and NotesShared on my fork), and made all four fixes: bounded metadata scans for |
…d and Notes editing
|
Thanks, @oliverames. All four changes are in. A few things left before I merge:
This also needs a rebase onto |
Mattt's pre-merge findings on mattt#384: - The scan budget counts the notes the search examined (scannedNoteCount), not the notes it returned, and the page request is capped by what is left of the budget, so a text query with few matches cannot scan far past it. - Unreadable notes are reported whether or not they matched, so the warning is not dropped for a plain text search. - Tag filters read the same database tag records that keywords does, and keywords is no longer overwritten by tags parsed from the note text. - The Markdown table converter does not pad a short row to the header's width. - TagTally and its test are gone; notes_tags uses the database records. The filters now run inside notes_fetch's snapshot, alongside the search, instead of in a second pass over the results.
|
Thanks @mattt. I rebased onto The scan budget counts The PR is read filters plus create only; the private NotesShared and edit tools stay on my fork.
|
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.
|
@mattt I went back over this and found that two of the fixes from my last round were only partly done, plus one real bug in create. The scan budget capped
I fixed a few smaller things too. A tag filter on a database that can't supply tag records now reports an error instead of returning nothing, link addresses with parentheses keep their full URL, and I took out a README sentence that still said notes can't be created. The description was out of date on the entitlements too, and it's fixed. |
Mattt's pre-merge findings on mattt#384: - The scan budget counts the notes the search examined (scannedNoteCount), not the notes it returned, and the page request is capped by what is left of the budget, so a text query with few matches cannot scan far past it. - Unreadable notes are reported whether or not they matched, so the warning is not dropped for a plain text search. - Tag filters read the same database tag records that keywords does, and keywords is no longer overwritten by tags parsed from the note text. - The Markdown table converter does not pad a short row to the header's width. - TagTally and its test are gone; notes_tags uses the database records. The filters now run inside notes_fetch's snapshot, alongside the search, instead of in a second pass over the results.
|
Thanks, @oliverames. The search limits, the warnings, the table expansion, and the merge with the Notes code on
One smaller thing: the test for the incomplete-search warning passes without the fix, because its fake returns the unreadable note as a match. |
|
@mattt I fixed the link recursion and the warning test in
You were right about the fake. It now returns an unreadable note only when its number matches, the way a real text query can't match a note it can't read. The warning test has one unreadable note that matches and one that doesn't, and it fails without the fix. The rebase waits on #390, as you suggested. Its CI is green now that #393 is in. |
|
Thanks, @oliverames. The depth limit, the scan stop, and the warning test all look good. Two things left before I merge:
|
Mattt's pre-merge findings on mattt#384: - The scan budget counts the notes the search examined (scannedNoteCount), not the notes it returned, and the page request is capped by what is left of the budget, so a text query with few matches cannot scan far past it. - Unreadable notes are reported whether or not they matched, so the warning is not dropped for a plain text search. - Tag filters read the same database tag records that keywords does, and keywords is no longer overwritten by tags parsed from the note text. - The Markdown table converter does not pad a short row to the header's width. - TagTally and its test are gone; notes_tags uses the database records. The filters now run inside notes_fetch's snapshot, alongside the search, instead of in a second pass over the results.
|
@mattt Both are done, and the branch is rebased on
For the scan, I also ran the old and new converters against each other on 600,000 random lines, and the output was the same on all of them. The branch still includes the three commits from #377. |
|
Thanks, @oliverames! The one-pass matching looks great, and nothing else needs to change. I merged #377 first, so this branch now conflicts with |
…t, leave notes_tags to mattt#351
Mattt's pre-merge findings on mattt#384: - The scan budget counts the notes the search examined (scannedNoteCount), not the notes it returned, and the page request is capped by what is left of the budget, so a text query with few matches cannot scan far past it. - Unreadable notes are reported whether or not they matched, so the warning is not dropped for a plain text search. - Tag filters read the same database tag records that keywords does, and keywords is no longer overwritten by tags parsed from the note text. - The Markdown table converter does not pad a short row to the header's width. - TagTally and its test are gone; notes_tags uses the database records. The filters now run inside notes_fetch's snapshot, alongside the search, instead of in a second pass over the results.
…ated ids, balance link parens - notes_fetch search is now searchNotes over a NoteSearchSource, so tests drive it; each request's scanLimit is capped by the remaining scan budget - unreadable note IDs are reported once; a tag filter throws when tag records can't be read - notes_create and notes_create_folder return the scripting id as scriptIdentifier and the database id as identifier only when one note or folder matches - Markdown link targets keep balanced parentheses - README: drop the stale create and smart folder sentence; the 2,000-note budget covers every notes_fetch scan
…et, test unreadable notes that don't match
The fork already carries this work. Conflicts keep the fork's exact id lookup (NotesIDMapper) over upstream's title matching, so the tree does not change.
This adds the read parity and create layers of what a Notes MCP needs. Notes is read-only in iMCP today: a client can fetch and read notes but cannot filter them by tag or checklist, or create one. sweetrb/apple-notes-mcp was the design reference for what to cover, and none of its code is used. It follows the order you suggested on #311: read parity, then create.
The private NotesShared tools and the edit, move, delete, export and attachment tools stay on my fork and are not part of this PR.
Every tool that changes something is gated by the Allow writes setting from #377 (
writesEnabledByDefaultis false for Notes). While it is off, those tools are not listed and a direct call is refused. Tools that only read are markedreadOnlyHint: true.What changed
notes_fetchgainstag,has,pinned,locked, word-count, created-date andincludeRecentlyDeletedfilters. Notes carry aurland tags. New:notes_accounts,notes_stats,notes_attachments. No new entitlements and no writes.notes_createandnotes_create_folder, through a fixed AppleScript that takes each value as a handler argument (an Apple event descriptor), never as script text. Addscom.apple.Notesto the Apple Events exception list in both entitlements files (theAUTOMATION_APPLE_EVENTSbuild setting already supplies the Apple Events entitlement) and updates the Apple Events usage string. Both tools return the scripting id asscriptIdentifier, and returnidentifieronly when the new note or folder can be found in the database, so it works with the read tools. README documents what Notes drops when a note is written through scripting (link addresses, checklists, numbered lists).Review fixes
scannedNoteCount), not the notes it returned, and bothlimitandscanLimiton each request are capped by what is left of the budget, so a text query with a sparse filter can't scan past it.keywordsdoes, insidenotes_fetch's snapshot, instead of tags parsed from the note text.keywordsis no longer overwritten by tags parsed from the note text.TagTallyand its test are gone, andnotes_tagsstays with Add Notes smart folders, tags and note links #351.notes_fetchcall.Testing
swift format lint --strictis clean on the changed files.imcp-serverTests: 308 tests, 1 skipped (pre-existing), 0 failures.NotesTestsandNotesWriteTestscover the filter, the tag records, the table converter, the scan budget with a sparse filter, unreadable notes, the cursor, and the create results. The search loop now runs over a small protocol so these run without a real Notes database.Not verified
identifieris left out.notes://showNote?identifier=has not been confirmed to open the right note.