Skip to content

v5.0.0

Latest

Choose a tag to compare

@kiki830621 kiki830621 released this 22 Nov 16:20
· 1 commit to main since this release

Fixed

  • send_draft finds a draft by message_id on iCloud
    (#752).
    iCloud's HEADER Message-ID search matches only the whole value with its
    angle brackets (measured 2026-11-22); the tools searched without them, so a
    draft made by append_draft could not be sent by its message_id, the
    check for an existing sent copy could never find one, and append_draft's
    search after an unknown outcome could never confirm the draft. Every
    Message-ID search now asks for both forms in one OR and compares each hit
    in full, as before. The server_reply in send_draft results no longer
    repeats the reply code (250 250 2.0.0 Ok).
  • send_draft and append_draft can use a server that does not mark its
    drafts and sent mailboxes, when direct-transport.json names them
    (#748).
    The first run against iCloud stopped at "the server marks no mailbox
    \Drafts": the plain mailbox list marked no \Drafts, and the server did not
    advertise SPECIAL-USE before login (what it advertises after login was not
    observed). The tools now try,
    in order: the plain list's mark; when the server advertises SPECIAL-USE, a
    LIST ... RETURN (SPECIAL-USE); the exact name given by the new optional
    drafts_mailbox / sent_mailbox keys in direct-transport.json, if the
    server lists that mailbox. A mailbox is never chosen by guessing from its
    name, and a configured name must match the server's scalar by scalar. When
    the configured name cannot be used either, the refusal says how many
    mailboxes were listed and whether SPECIAL-USE is advertised; results note
    how each mailbox was found. When the sent and drafts mailboxes are the same
    mailbox (compared without regard to ASCII case), the sent copy stays
    pending and the draft is kept. A pending removal is done only in the drafts
    mailbox the draft was submitted from. When the drafts mailbox is looked up,
    a marked mailbox that cannot be selected, capabilities that cannot be read,
    or a failed special-use request refuse the call; when the sent mailbox is
    looked up after submission, they leave the sent copy pending.

Added

  • send_draft refuses a draft Mail saved
    (#745). The
    Mail draft compared for #745 had an empty plain-text part, the body in HTML
    and draft-only headers such as X-Uniform-Type-Identifier: com.apple.mail-draft,
    while a message Mail sent was a single plain-text part. send_draft sends
    drafts as stored, so a new submission of a draft carrying that mark is now
    refused before connecting to the SMTP server (only the mark is checked); make the draft with append_draft, or send it from Mail. Pending
    stages of a draft submitted earlier are still completed.

  • append_draft: create a draft on the mail server over IMAP, without Mail
    (#744, second
    stage of #729).
    Not yet run against a real mail server; the tool description says so until
    the result is recorded on #744. Same accounts, credential and connection rules
    as send_draft. The tool builds one text/plain part in UTF-8 with a new
    Message-ID and appends it to the mailbox the server marks \Drafts, with
    \Draft and \Seen. Recipients are bare addresses only. The outcome is
    appended, not_appended (including a failed connection, login or
    drafts-mailbox lookup before the APPEND was sent) or unknown; after unknown
    it tries one search for the Message-ID and never appends again. Calls are not
    de-duplicated. The message is deliberately not in the
    layout Mail gives its own drafts
    (#745).

  • send_draft accepts message_id as a third way to choose the draft, beside
    draft_id and subject_match, so a draft made by append_draft can be sent
    while Mail is closed (#744).

  • send_draft: send an existing draft over SMTP, without Mail
    (#742, first
    stage of #729).
    Not yet run against a real mail server; the tool description says so until
    the result is recorded on #742. Only for accounts listed in
    ~/.claude/.mail/direct-transport.json, with a password stored in the
    server's own keychain item by --direct-transport-set-credential <address>
    (read from standard input; no tool can read or change it, and Mail's
    passwords are never read). The draft is chosen by draft_id or by exact
    subject_match in the server's \Drafts mailbox; the tool accepts no body,
    recipient or attachment argument. Before submitting it checks the Message-ID
    against a record of sent drafts, the From address, the recipients and the
    header; it submits the draft without its Bcc fields, over TLS only (implicit
    on 465/993, required STARTTLS elsewhere). The outcome is submitted,
    not_sent or unknown; an unknown send is not retried and is cleared only by
    --direct-transport-forget '<message-id>'. After a submission the sent copy
    and the draft's removal are separate stages that a later call resumes without
    submitting again, only from the same account and only while the draft is
    byte for byte the one submitted. One call runs at a time, and the SMTP server
    is contacted only to submit. Errors and server replies are redacted of the
    password. Mail's local index is not changed. New dependency: SwiftMail
    1.17.0, pinned by revision.

  • search_emails can return each row's Message-ID
    (#682). The new
    include_message_id (boolean, default false) adds message_id to every
    full or summary row, read from the .emlx header block with the parser
    get_email and the batch export use. A non-empty string is the Message-ID and
    equals what get_email reports (the header block ends at the first blank
    line, see #715);
    "" means the message has no such header, or an empty one. A missing key means unknown, in
    these cases only: no readable .emlx for the row; the file could not be read
    or its length line could not be parsed (including one longer than 4096
    bytes); the header block does not end within the first 256 KiB of the message
    (including a larger message whose lines end in lone CR); the value is longer
    than 4096 UTF-8 bytes; or the row came from the AppleScript fallback. In the
    middle three get_email may still report a value, because it reads the whole
    file. The read stops at the end of the header block, never looks at more than
    the first 256 KiB of a message (the first 4096 bytes of the file are also read to find the
    length line, whatever they hold) and looks up each mailbox's store folder
    once per call; without the flag no file is read and rows are unchanged. true
    with ids or count and a non-boolean value are parameter errors. A call
    whose rows could not all be read writes one stderr line with a count and a
    fixed reason. Not yet run against a real mail store; the issue stays open for
    that check. A plugin release that relies on the field must set
    binary_version to a binary that contains it.

  • forward_email can save the forward as a draft
    (#599). The new
    save_as_draft (boolean, default false) saves a forward that carries a body
    with ⌘S through the same paste path instead of sending it, like
    reply_email's draft mode. A forward without a body and
    save_as_draft: true is refused by name before any Mail call, because the
    bodyless forward is Mail's native forward verb followed by send; a
    bodyless draft mode is tracked in
    #673. Without
    save_as_draft the call sends, as before, and the tool description now says
    so in its first sentence; it also advises reading a saved draft's To
    recipients and body back before sending it. null means the same as an
    omitted save_as_draft, as for reply_email; any other non-boolean value is
    refused. A timeout on the draft path is not reported as an unknown send
    state; the send path's handling is unchanged. The draft mode has not been run
    against Mail yet.

  • get_mail_log_events can filter by event name
    (#466). The new
    events parameter (1 to 20 values) keeps only events whose event field is
    exactly one of the values: a template, imap.append_uid_received, or
    <template withheld>. It works in brief and detailed output, so the upload
    receipt no longer has to be paged out of hundreds of IMAPConnection lines.
    The comparison is against the name the output shows, by the same function, so
    a withheld template cannot be selected by its own text, and nothing but exact
    equality selects an event. An imap. value that is not a known event is an
    error, so a typo does not read as "the event did not happen". Paging counts
    only matching events. The values are not echoed: the response reports how
    many were applied as event_filter_count, so a large filter cannot push it
    past the 64 KiB cap and caller text never comes back in brief output.

  • The .mcpb install can set the destination policy
    (#574). The
    bundle's manifest had no way to set CHE_MAIL_EXPORT_ALLOWED_ROOTS, so a
    Claude Desktop user could not save attachments or export outside the home
    folder (an external disk, for example). The extension now has an optional
    Allowed save and export folders setting that maps onto the variable; it
    takes the same colon-separated absolute paths and, when set, replaces the
    home default. The README lists where to set the variable for each install
    method. A value that is exactly the manifest's placeholder counts as unset, so
    a host that passes an unset setting through literally keeps the home default.
    How Claude Desktop passes an empty setting was not checked on a real install;
    the setting has an empty default, and the save_attachment and output_dir
    descriptions state the limit. Behaviour change: any other entry that is not
    an absolute path now matches nothing, with a note on stderr. A relative entry
    used to be resolved against the server's working directory; a nonempty value
    with no absolute path in it now denies every destination.

Changed

  • BREAKING: requires macOS 26
    (#742). The
    minimum system goes from macOS 13 to macOS 26; macOS 13, 14 and 15 stay on
    v4.x. The cause is a new dependency, SwiftMail (SMTP and IMAP, for sending
    without Mail, #729), which needs macOS 15, and below macOS 26 the release
    binary would also need libswiftCompatibilitySpan.dylib, which macOS 15 does
    not ship. The tools that use it are send_draft and append_draft.
    Package.resolved is now under version control, so a release binary can be
    rebuilt from the same dependency versions (24 packages, up from 7).

  • get_mail_log_events signals the log child's whole process group
    (#646).
    The runner now starts /usr/bin/log with posix_spawn in a process group of
    its own (POSIX_SPAWN_SETPGROUP), with only stdin (/dev/null), stdout and
    stderr inherited (POSIX_SPAWN_CLOEXEC_DEFAULT) and default signal handling,
    and reaps it itself. Every stop sends SIGTERM to the group, gives the leader
    two seconds, sends SIGKILL to the group, and only then reaps the leader, so
    the group number cannot belong to anyone else while it is signalled. A
    descendant that held the child's stderr (or stdout) can no longer keep the
    stderr reader thread and its descriptor alive: on a natural end the leader is
    observed without being reaped, and if stderr has not closed within the
    existing 2 s the group gets SIGKILL before the reap. The group is also swept
    on a normal exit, so a descendant that holds neither pipe does not outlive the
    call. The two-slot cap, the cancellation behaviour and the exit-status
    semantics (-1 for a child that could not be reaped) are unchanged. A spawn
    failure still reports spawnFailed with the executable path and the reason
    posix_spawn gave. Remaining limit: a descendant that calls setsid or setpgid
    leaves the group and is not reached, and no test covers that case. No such
    descendant is known for log show --style ndjson; the tests use descendants
    that stay in the group.

  • Attachment paths must be regular files
    (#543).
    compose_email and create_draft validated attachments only by existence,
    symlink resolution, the deny-list and the optional allow-list, so a
    directory, a FIFO or a device such as /dev/zero passed. A path that is not a
    regular file after symlink resolution is now rejected as
    not a regular file (<kind>), in the same aggregated error and before Mail is
    touched; the type is read without opening the path. update_draft gets the
    same checks, now before its draft scans. A path with a . or .. component
    is refused as contains a '.' or '..' path component: Mail receives the
    caller's text through the open panel's Go-to-folder field, and without such
    components every reading of the path names the same file. Components are compared as the filesystem sees them (the bytes between slashes), and a path that holds a NUL byte is refused by name. Resolution no
    longer applies .standardized first (it removed .. from the text before
    following links, so the deny-list, the allow-list and the type check could
    judge a different file from the one named). A relative path still counts from
    the server's working directory. Behaviour change: directories are rejected
    too, including package documents such as .rtfd or .app bundles that Mail
    might have attached before, and so are paths with . or .. components.

  • Direct-write trigger: the timed path is pinned as text
    (#650). Tests and
    docs only; nothing under Sources/ changed. ComposeTiming.prelude and
    ComposeTiming.markStatement were not compared with fixed text on the timed
    path, so a toggle, a branch or a delay placed in the mark handler would have
    run between the two read-status toggles whenever timing is on and passed every
    test. Three new tests pin the prelude, markStatement for every label the
    trigger uses, and the whole timed script (four marks, their places and
    indentation). They pin the text the builder hands to the script transport (for one row id), not the bytes osascript receives and not Mail's reaction to it;
    the rule's known-gap bullet is replaced by the test names and a note that
    Mail's behaviour for the pinned script, the transport below the test seam and
    the other non-text channels are a documented limit, not a pending live check.
    The prelude is shared with the compose path's timing, so changing that now
    means updating the pin.

  • A handler test with an address as account_name no longer reads the machine's
    accounts
    (#633).
    A server built with accountMapping now resolves an address from that mapping.
    Without one, nothing changes: the server still reads AccountsMap.plist on each call.
    This covers account_name; the direct-write path's from_address lookup is
    covered by #654 below.

  • create_draft's direct-write path answers its account gate from an injected
    mapping
    (#654).
    A server built with accountMapping now gives the opt-in direct-write path that
    mapping for from_address, and treats the account's signature list as
    unreadable (the mapping holds none), so signature: mail_default takes the GUI
    path there. Without a mapping, nothing changes: on each call the account lookup
    reads AccountsMap.plist, and the signature lookup reads it too unless
    iCloud-synced signatures exist (then the list counts as unreadable, as before).

  • list_vip_senders can read an injected VIP list
    (#656).
    EnvelopeIndexReader and the server's init take an optional VIP list path,
    so a handler test reads only the file it wrote, as long as the reader opens.
    Without one, the reader reads the same VIPMailboxes.plist as before; the path
    is now built from the mail storage path, so it follows a test's override of
    that path (production never sets one). When the reader is not open, the
    handler still falls back to AppleScript, as before.

  • BREAKING: reply_email refuses attachments for now
    (#534).
    With a non-empty attachments, the reply script pasted the new body through
    Mail's editor and then attached the file through Mail's scripting object
    model. That insertion writes the reply's content, which holds neither the
    pasted body nor the quote Mail's reply verb built, so the saved draft kept
    only the attachment and the signature while the call returned
    Reply saved as draft (paste path) (send mode used the same script). Any
    non-empty attachments is now refused before any Mail action, attachment-file
    check or AppleScript, in draft and send mode alike, with invalidParameter
    naming the reason and the recipe: reply with save_as_draft: true and without
    attachments, then open the saved reply from Drafts in Mail and drag the
    files in. This is a temporary ninth refusal reason that applies to
    reply_email only; it goes when
    #608 attaches
    through Mail's editor. The parameter stays in the schema so such a call is
    refused by name. Argument parsing at the tool boundary still runs first, so
    format: "markdown" or "html" with attachments reports the format refusal.
    Reply and forward scripts without attachments are unchanged.

  • reply_email reports its refusal before an invalid cc_additional
    (#534). The
    cc_additional check now runs after the pre-flight refusal, so a refused
    reply reports the attachments refusal or the missing Accessibility grant
    first, where an invalid cc_additional used to be reported first; it is now
    reported once the call would otherwise proceed. The format refusal was already
    first, because the tool parses format before calling into Mail. Both orders
    have no side effects.

  • The object-model attachment code is removed, not bypassed
    (#534).
    attachmentFragment, its paced delays and the reply/forward attach drain are
    gone, and NoObjectModelAttachmentGuardTests fails if any source file under
    Sources/CheAppleMailMCP/ inserts an attachment through Mail's object model
    again. CHE_MAIL_ATTACHMENT_DELAY_BETWEEN and
    CHE_MAIL_ATTACHMENT_DELAY_TRAILING are no longer read: they only paced that
    code, and compose attachments have gone through ⇧⌘A with the
    CHE_MAIL_MAILTO_* delays since #304.

  • The four tools that can send mail declare it in their MCP annotations
    (#601).
    compose_email, reply_email, forward_email and redirect_email now carry
    readOnlyHint: false, destructiveHint: true (a sent message cannot be
    recalled), idempotentHint: false (a retry sends a second message, #242) and
    openWorldHint: true (mail leaves for third parties). These are the values a
    client conforming to the MCP spec already assumes for a tool without
    annotations, so such a client behaves the same; the change makes them explicit
    and keeps them if a client or SDK default changes. Annotations are static, so
    reply_email declares the send case even when it is called with
    save_as_draft: true, so a client that asks before destructive tools will ask
    before a draft-only reply too. Whether any client prompts on these hints was
    not verified.

  • Every tool now says what it does in its MCP annotations
    (#621). Without
    them a client read every tool as possibly destructive, so it could not tell a
    read from a delete. Each tool now sits in one class of a closed table
    (ToolAccess), and a test fails on a new tool with no class. Reads of accounts
    and settings are read-only and closed world. Reads of mail are read-only and
    open world, because third parties wrote that text. create_draft and
    open_mailto send nothing but are open world, because a draft syncs to the
    server and open_mailto hands over to the default mail client. Tools that
    change, move, remove or import are destructive, as are save_attachment and
    the exports (an attachment of the same name is replaced). update_draft is
    destructive and open world. The classification tools and check_compose_length
    keep the annotations they already had.

    A client that runs readOnlyHint tools without asking will now read mail
    without a prompt
    , and text in a message can then steer what gets read next.
    The hint states a fact about the tool: it changes no mailbox, though a read can
    make Mail fetch a body from the server (#274). Acting on it is the client's
    policy. The MCP specification tells clients to treat annotations as untrusted
    unless the server is trusted, and openWorldHint does not make a client ask.
    Whether any client acts on these hints was not verified.

  • get_mail_log_events runs at most two reads at once and stops when the
    client cancels
    (#467).
    Each call started its own log show child (237–350 MB) with no limit, and a
    cancelled call left the child running until its 30-second deadline. A third
    concurrent call now returns at once with status: unavailable,
    reason: busy and starts nothing; a caller retries. A cancel stops reading
    within one poll slice (250 ms), then terminates and reaps the child (at most
    about 4 seconds for a child that ignores SIGTERM), and returns
    reason: cancelled. The slot stays taken until then. A descendant
    that holds the stderr pipe can still outlive the call, as before; putting the
    child in its own process group is not part of this change.

  • Removed attachment code that #402 left unused
    (#575).
    MailController.verifySavedAttachmentOnDisk, AttachmentWriteProblem.statFailed
    and EmlxParser.saveAttachment(..., destination:) had no production caller; the
    last wrote to a plain URL with no containment, so any future caller would have
    reopened #402. The #314 and #347 tests now run against saveUsingScript, the
    step that does this work, and a new structural test pins that a Tier-1
    publication failure ends the call instead of reaching AppleScript. The tool's
    behaviour does not change.

Fixed

  • forward_email no longer sends a bare forward when body has the wrong type
    (#674). body
    is optional, and a value that was present but not a string (a number, a
    boolean, an array, an object) was read as no body: without save_as_draft the
    forward was sent without the note, and with it the call was refused for the
    wrong reason. Such a call is now refused before any Mail action with
    'body' must be a string, got: <type>, checked before the account is resolved.
    An explicit body: null is refused the same way (got: null): callers that
    passed null to mean "no note" must now leave the key out. A missing body is
    still a forward without a body, and a string (the empty string included)
    behaves as before. One case reads oddly: a
    string that parses as a data: URL is decoded as binary data by the MCP SDK
    before it reaches the tool, so it is refused as got: data, and the message
    says so.

  • Header and fallback body decoding do linear work
    (#720). Two
    decoders did work that grew with the square of the value's length: the RFC 2047
    encoded-word decode that parseHeaderBlock applies to every header value
    except content-*, and the quoted-printable decode of the HTML body on the
    AppleScript fallback path. Both now do work linear in the length of the value.
    This is a performance fix only: the decoded output is unchanged (a differential
    test compares both decoders with the previous algorithm, kept as a test-only
    reference), and which text counts as an encoded-word, the charset run handling
    (#352) and the content-* exemption (#115) are untouched. The tests count the
    work through a seam instead of timing it.

  • A message's header block ends at its first blank line
    (#715).
    RFC822Parser.parseHeaders and headerBodySplitOffset looked for a CRLF blank
    line over the whole message first and used an LF blank line only when no CRLF
    blank line existed anywhere. A message whose header block ended with an LF blank
    line and that had a CRLF blank line later was split at the later one, so body
    lines were read as headers (the last Subject:-style line won) and the body
    started in the wrong place; this reached get_email, get_emails_batch, get_email_headers, the
    Markdown export, attachment lookup, the MIME child parts and the classification
    tools. Both functions now
    use one scan that ends the header block at the blank line that starts first.
    Messages with consistent line endings, messages with no blank line and the
    slice behaviour from #72 are unchanged. A blank line written \r\n\n ends the
    header block at its \n\n; \n\r\n is still not read as a blank line. Whether
    mixed line endings occur in real mail stores has not been measured.
    The Message-ID recipe in the repair command, which mirrors the parser, ends the
    header block the same way, and the shared spelling fixture follows.

  • The attachment deny-list no longer depends on how a path is spelled
    (#671). The
    deny-list compared the resolved path with each sensitive directory as text, so
    a spelling that resolution keeps and the kernel still accepts (a root-level
    prefix such as /.nofollow or /.resolve/<n>) named a deny-listed file
    without matching. The check now also compares the device and inode of each
    prefix of the resolved path with those of each deny-listed directory, so any
    spelling of a deny-listed directory is refused, including spellings that
    differ only in letter case. A prefix or a deny-listed directory that cannot be
    examined rejects the path; a deny-listed directory that does not exist is
    skipped. When a deny-listed directory exists but cannot be examined, every
    attachment is refused with a message that says the deny-list check could not
    be completed and names the directory and the system's reason. Hard links to a
    deny-listed file are still not recognised (see
    SECURITY.md). Tests use a temporary directory as the deny-listed root through
    an internal parameter of the validator.

  • A failed read of a direct draft's read flag says why
    (#653). After the
    upload, the direct-write path looks at the draft's local read flag; a read that
    failed and a draft row that was gone both came back as "cannot tell", and the
    cause of the failure was dropped. A failed read now writes
    DraftStoreWriter: messages.read read failed (<cause>) to stderr, up to 12
    lines for one draft (4 looks, then 8 after the re-assert); a row that is gone
    still writes nothing. The result is unchanged: either case still counts as not
    able to read the flag.

  • A failed direct write no longer leaves empty directories behind
    (#503). When the
    opt-in direct write failed after placing the .emlx (or while placing it), or
    was reversed after the upload request failed, it removed the file (and its
    rows, except those #628 tracks) but left the Messages directory, and any hash
    directories above it, that it had created. That happens whenever the draft is
    the first row of the Drafts mailbox in its 1,000-row block: row ids are shared
    by all mailboxes while each mailbox has its own hash directories, so for a
    Drafts mailbox with few messages it is the common case. It now removes the
    directories it created, deepest first, and only while they are empty. Only a
    level its own mkdir made is recorded, so a level that existed, or that
    another process created first, is not removed; a directory Mail wrote into
    meanwhile stays, with everything above it. A recorded directory that is
    already gone is skipped. A removal that fails for any other reason than the
    directory not being empty or already gone is noted on stderr and stops the
    cleanup. Cleanup never replaces the error a failed write reports and never
    makes a reversal fail. One error text did change: when a directory cannot be
    created, the emlxWrite reason now names the level and the system error
    (could not create <path>: <reason>), so the fallback note carries that path,
    as it already did for an existing .emlx. A narrow race remains: if Mail has
    found a directory this write created and has not yet written into it, the
    cleanup can remove it first. Two related gaps are tracked in
    #666.

  • A signed or fullwidth digit pair is no longer decoded as a hex escape
    (#641). The
    quoted-printable decoders and the percent decoder read the two characters after
    = or % with UInt8(_, radix: 16), which accepts a leading sign, so =+5
    decoded to the control byte 0x05, =-0 to NUL and %+5 to 0x05. All three
    decoders (RFC822Parser for bodies and RFC 2047 Q words, MIMEParser for RFC
    5987 / RFC 2231 file names, and the AppleScript fallback in MailController) now
    read one shared HexEscape.byte(_:_:), which takes ASCII 0-9A-Fa-f only, so a
    sign, a space or a fullwidth digit leaves the = as text and %+5 returns nil
    like any other malformed percent escape; lowercase escapes decode as before. The
    AppleScript fallback also stops dropping the two characters after a malformed
    =: =ZZ keeps ZZ. A guard test fails on a radix: 16 parse in Sources.

  • A draft is not reported as uploaded when its queued action could not be read
    (#630). While
    waiting for the upload, the direct-write path treats a remote id with no queued
    action as uploaded, and a failed read of the queued action counted as "none".
    A failed read now counts as still queued, so the wait keeps looking and ends as
    pending unless a later read confirms the upload. Both reads now say why they
    failed on stderr, up to two lines per poll, about 200 lines per draft if they
    keep failing. A read that keeps failing costs more than it did: the draft takes
    the full wait instead of ending at once, longer if a held lock makes each read
    wait out the 5-second busy timeout. A draft Mail did upload is then reported as
    pending, and the read repair, which runs only after a confirmed upload, does not
    run, so its local copy can stay unread. The 10-second limit itself is unchanged.

  • A refused export path no longer says where it resolved
    (#625). When
    batch_export_emails_markdown refused output_dir or
    skip_message_ids_path, the error printed the validator's reason, which held
    the symlink-resolved path and named the kind of refusal. Resolution runs before
    the check, so a caller with only MCP tools could learn where a link points or
    whether a protected folder exists. Both parameters now get one fixed message
    whatever the kind, and the reason goes to stderr, as save_attachment has done
    since #576. The <parameter> rejected by write-safety check: lead is unchanged;
    only the text after it differs.

  • Accounts added or renamed while the server runs resolve without a restart
    (#554). The
    SQLite reader built its account mapping from AccountsMap.plist once, when it
    opened, so a name-scoped read (list_mailboxes, list_emails,
    search_emails with account_name) for an account added later failed with
    accountNotResolvable, results named that account by its UUID, and a renamed
    account resolved only under its old name. A lookup that misses now re-reads
    the plist once and retries, at most once every 5 seconds, so a name that never
    resolves costs one plist read per interval rather than one per call. A read
    that returns no accounts (an unreadable plist) keeps the accounts already
    known. The mapping is now guarded by a lock, because the reader is shared by
    concurrent request handlers; the plist itself is read outside the lock.
    Lookups by account_id were not affected. A lookup that finds what it asked
    for also checks, at most once every 5 seconds, whether the plist's modification
    date changed, and re-reads it if so
    (#615), so an
    account whose email changed gets its new name in results and its old name stops
    resolving, without a miss. The names are the account emails taken from
    AccountsMap.plist, so renaming an account's description in Mail does not
    change them.

  • A failed read in the direct-write draft path no longer reads as an empty
    answer
    (#618).
    The check that refuses to roll back a draft Mail has already uploaded treated
    a failed read as "not uploaded", so unless a later statement failed too, the
    rollback went on to delete a draft that could be on the server. It now
    refuses, and the result reports the draft as created with its upload not
    confirmed. A mailbox scan that stops part-way answers nothing instead of
    passing the single-mailbox gate on the rows it saw, with the SQLite error on
    stderr, and a read that fails inside insert reports that error instead of
    "row missing". Experimental path only (CHE_MAIL_EXPERIMENTAL_DIRECT_DRAFT=1).

  • A read that the Envelope Index stops part-way through is an error, not a
    shorter answer
    (#549).
    Every SQLite read stepped through its rows with
    while sqlite3_step(stmt) == SQLITE_ROW, so any result other than a row
    (SQLITE_BUSY after the busy timeout, SQLITE_IOERR, SQLITE_CORRUPT)
    read as "no more rows": a truncated mailbox list, search page or recipient
    list came back as if complete, and an unread count or search count as 0,
    with nothing on stderr. Every multi-row read in the reader now checks that
    SQLite reported the end of the results, and the one-row reads (unread count,
    search count, message lookup, metadata, draft status) tell "no row" from a
    failure; a failure throws queryFailed naming SQLite's message and result
    code. A recipient read that fails now fails its search page, where it used to
    leave the recipients empty.
    list_mailboxes, get_unread_count, list_attachments and search_emails
    (projection: "full") used to pass index errors to the caller; on a failed
    read they now log it to stderr and use the AppleScript path, like the other
    read tools. The SQLite-only search_emails projections (ids, count,
    summary) report the failure. Account and mailbox resolution errors are
    answers, not failures, and still come back unchanged. The direct-write
    create_draft path names a failed mailbox read as the reason it was not
    attempted, where it used to report "no Drafts mailbox path"; it still uses
    the GUI path in that case. More AppleScript fallbacks may now run when the
    index is busy or damaged, which is slower but no longer wrong.

  • The Automation pre-flight no longer takes one empty running-application
    list as "Mail is not running"

    (#499). A test
    harness saw NSRunningApplication come back empty for a running Mail under
    load (1 to 4 runs in 33), which every GUI-path call would report as a false
    "Mail is not running". An empty list is now re-read up to twice, 150 ms apart,
    and only a list that stays empty reports not running, so a Mail that really is
    closed gets that answer 300 ms later than before; nothing else about it changes.
    A recovery goes to stderr, so the server's own rate can be seen; whether the
    server sees this at all was not established.

  • Saving an attachment works through a search-only folder, says less, cleans
    up after a kill and drops inherited ACLs

    (#576). Four
    edge cases in the publisher #402 added:

    • The walk from / opened each directory with read access, so an ancestor at
      -wx--x--x failed every save with destination_write_failed, where the
      path-based write before #402 needed only search permission. It now opens
      with O_SEARCH, and falls back to read access on a filesystem that refuses
      that. O_SEARCH was not tested on network or FUSE mounts. The Markdown
      export shares the walk and gets the same change.
    • A refused path now gets one fixed message that names no path. It used to
      carry the resolved path, so a caller could learn where a symlink points or
      whether a protected folder exists. The reason stays on stderr. A path that
      fails to resolve outside the policy gets the same message; inside the policy
      it keeps its specific reason.
    • A save now removes temporaries a killed server left in that folder: files
      named by this writer, owned by this user, whose server is gone or which are
      over a day old. Temporary names stay unique per save rather than fixed per
      destination as the issue proposed, because concurrent saves must not touch
      each other's file (#402); the name now carries the server's pid and a tag
      for this Mac, so a shared or synced folder's file from another Mac goes by
      age alone. A folder that cannot be listed is left alone.
    • A saved file no longer keeps an ACL inherited from its folder: a folder's
      inheritable read entry made the 0600 temporary, and so the published file,
      readable through it. A save fails if the ACL cannot be read on a volume that
      may hold ACLs, or will not clear. Behaviour change: a file saved into a
      folder that shares through an inherited ACL, or over a file with its own ACL,
      ends up with no ACL.

Fixed

  • A quoted-printable soft break at the very end of a part no longer leaves a
    stray =
    (#626).
    The decoder's end-of-input guard ran before its soft-break test, so = plus a
    line break that was the last thing in the input was written out verbatim.
    Multipart text keeps the line break before the boundary (#546), which made this
    visible at the end of a body. A lone = or a truncated escape such as =4
    still stays literal.

  • A header value no longer ends at a Unicode line character
    (#555).
    The header parser split lines with CharacterSet.newlines, which besides CR
    and LF holds U+000B, U+000C, U+0085, U+2028 and U+2029. A value containing
    one of them was cut there, and a tail shaped like Name: value was stored as
    another header, so a sender could forge Message-ID, From or Date (and a
    MIME part's Content-Type) from inside their own Subject. Lines now end
    only at CR or LF (a bare CR still ends a line, as before), and those
    characters stay in the value. Archives exported earlier with a forged
    message_id are not repaired.

  • One non-UTF-8 part no longer blanks a multipart message's text and html
    (#546).
    The text/html walk behind get_email, get_emails_batch and both export
    tools turned the whole multipart body into one String, so a single byte that
    is neither UTF-8 nor ASCII (a raw 8bit Big5 part, a lone 0xE9) returned no
    text and no html, the valid sibling part included. Parts are now split at the
    byte level and decoded one by one under their own charset. The walk also stops
    at the same nesting depth as the attachment walk (8), where it used to recurse
    without a limit at quadratic cost. Well-formed UTF-8 mail returns the same
    bodies as before, trailing line break included.

  • A multipart preamble ending in a blank line no longer empties the text body
    (#560).
    The text before the first boundary (often This is a multi-part message in MIME format.) was walked as a part. When a blank line followed it, it parsed
    as an empty text/plain, and the real plain part was then skipped, so
    get_email returned text_body: "" and the exported Markdown body was empty
    even though the message had a plain and an html part. The preamble is now
    skipped, as the attachment walk already did.

  • The opt-in direct write no longer writes lines over 998 octets
    (#588).
    With CHE_MAIL_EXPERIMENTAL_DIRECT_DRAFT=1, an ASCII-only body went out as a
    7bit html part without folding, so a body line longer than 998 octets (the
    RFC 5322 §2.1.1 limit) made the draft an invalid message that servers or
    clients may rewrite or reject. Such a body now goes out as quoted-printable,
    which soft-wraps at 76 characters, like non-ASCII bodies already did. Bodies
    whose lines all fit keep the 7bit layout Mail itself writes, and the
    create_draft description now states this behaviour.

  • Decoding no longer depends on how Foundation treats .ascii
    (#561).
    String(data:encoding: .ascii) succeeds on non-ASCII bytes in the shipped
    binary (stamped sdk 13.0) and fails under swift test, so code that used it
    did something different from what the tests saw. Every call site now says
    what it means, and the results are the same under both stamps. What changes
    for the shipped binary: a 7bit/8bit text part with non-ASCII bytes is no
    longer taken for mislabelled quoted-printable; a quoted-printable part with
    raw 8-bit bytes keeps those bytes instead of re-encoding each one as UTF-8
    (caf\xC3\xA9=20x is café x, not mojibake); an encoded-word or RFC 2231
    filename labelled us-ascii that carries valid UTF-8 now reads as UTF-8, the
    rule bodies follow since #538. Non-UTF-8 bytes under an ASCII label still read
    as Latin-1.

  • Batch export dates now match the SOP recipe for old years and a bare CST
    (#547).
    The frontmatter date of Tue, 30 Jun 55 10:00:00 +0800 was
    0055-06-30T10:00:00+08:00; two- and three-digit years now follow RFC 5322
    §4.3 (55 is 1955, 49 is 2049, 126 is 2026), as the recipe does. A bare
    CST, which names both US Central and China Standard Time, was silently read
    as US Central and could move the calendar day; a date ending in CST or any
    other zone name the recipe refuses now stays as written in date, and its
    default filename uses unknown-date. Files already exported are not repaired.

  • skip_message_ids_path no longer splits a Message-ID at a Unicode line
    character
    (#613).
    The skip file was read with CharacterSet.newlines, so an ID holding U+2028
    or a similar character (kept by the header parser since #555) became two
    entries that matched nothing, and the mail was exported again. Lines now end
    only at CR or LF.

  • Frontmatter values can no longer start another line
    (#616). YAML 1.1
    readers and Python's str.splitlines() end a line at U+0085, U+2028 and U+2029,
    which survived into the frontmatter, including the unquoted sender and
    date. These and the other C1 controls are now flattened to a space, like the
    ASCII controls. A Message-ID holding one of them is spelled with a space in
    the frontmatter, as VT and FF already were.

  • The opt-in direct write folds long Subject: and To: lines
    (#622). A long
    recipient list or ASCII subject could pass the 998-octet line limit. To:
    folds after a comma, Subject: at a space, and a subject folding cannot bring
    under the limit goes out as encoded words. Headers that fit are unchanged byte
    for byte. A to address over 254 octets, the SMTP path limit, takes the GUI
    path, because folding cannot split an address.

  • reply_email and forward_email no longer say the send keystroke fired
    when the GUI flow timed out

    (#550). After
    a 90-second timeout of the send flow, both tools reported "the send keystroke
    was already dispatched", but the script had not finished, so the keystroke may
    not have been pressed. A timeout now gets the same statement compose_email
    already made: the keystroke may or may not have fired, the send state is
    UNKNOWN, NOT retrying, check the Sent mailbox, Outbox, the original thread and
    any leftover compose window. A failure after the keystroke (POSTDISPATCH) keeps
    its wording unchanged. Neither tool retries, and the error's classification is
    unchanged.

  • TemplateExtractorTests no longer fails on a loaded machine
    (#502).
    testTheDataShapeBackstopIsBoundedAndSharesTheRedactionPattern timed two
    1,024-byte looksLikeData scans with the wall clock and required them to
    finish within 0.2 s; at a load of about 160 they took 0.32 s and the suite
    failed, although the healthy cost is 5–6 ms. The timing now uses a monotonic
    clock and the 5 s ceiling of the adversarial test in the same file, with the
    elapsed time in the failure message. The deterministic guard (nothing over
    1,024 bytes is scanned) is unchanged. Test-only change.

  • LogShowRunnerTests keeps its timing checks clear of machine load
    (#468).
    The tests time the real spawn/read/terminate/reap path with a monotonic
    clock instead of the wall clock. The grandchild-holds-the-pipe test was the
    tight one: with a 3 s hold against a 2.5 s ceiling, the healthy path (about
    1.3 s) had about 1.2 s of headroom, and the broken read-until-EOF design
    (3 s) was only 1.7 s away from it. The grandchild now holds the pipe 20 s
    and the ceiling is 10 s, so the two outcomes are far apart; the orphaned
    sleep is killed when the test ends.
    The two endless children are exec yes <line> instead of a shell
    while true; do echo ...; done loop, so they block on a full pipe instead of
    spinning a core. Test-only change.

  • The osascript fixtures in two test files refuse the known ways of addressing an application
    (#572).
    ComposeCleanupSheetTests and PostIdentificationCleanupTests run fragments
    cut out of production scripts through /usr/bin/osascript, and at most a check
    for the literal tell application kept them away from Mail; tell app "Mail",
    … of application "Mail" and activate application "Mail" passed it. Every
    osascript run in those two files now checks the exact text it executes with
    OsascriptFixtureGuard, which removes comments and empties string literals
    (reading Unicode scalars and ¬ continuations) and then refuses the words
    app, application, process in any case, raw «…» codes, |…| identifiers, run script,
    do shell script, load script, store script, open location and use
    statements. It is a deny list, not a proof; a false positive only fails a test.
    Test-only change.

  • Timing CSV: script marks stay with the run that produced them
    (#483). The
    marks a script sends back were kept in one process-wide buffer. The upload
    trigger's marks wait there across an await, so a second create_draft run, or
    a compose_email taking the whole buffer, could take them and write them under
    the wrong run_id. Inside a run the marks now stay with that run, and marks
    the run does not take are dropped with it. The shared buffer is left for calls
    outside a run, where the only script that sends marks is compose_email's,
    which captures and takes them in one actor job. This only touches diagnostics,
    and only with CHE_MAIL_COMPOSE_TIMING_CSV set.

  • The osascript fixtures in four more test files use the shared guard
    (#617). Every
    osascript run in ClassificationTrashScriptTests, ComposeSignatureScriptTests,
    DraftIDBaselineTests and RecipientReceiptMetadataFailureTests now checks
    the text it executes with OsascriptFixtureGuard. Handlers that really use the
    Foundation bridge pass through an explicit allowance: use framework "Foundation", use scripting additions, current application's followed by a
    closed list of the names these handlers use, and three piped words. NSPredicate
    passes only with the one format string they use, as the whole argument, because a
    format string can run code. Any other class-shaped name, selectors by name, and the ways to name a class
    in a string are refused. Handlers a test does not call lose their tell application blocks before the script runs, and a block that never closes is
    refused instead of dropping the rest of the script. The list bounds the class names a fixture
    can write, not what the methods of those classes do: they can read and write
    files and fetch URLs. OsascriptFixtureGuardScanTests scans Tests/, so a new osascript run that
    skips the guard fails a test; the two helpers gated by CHE_MAIL_LIVE_TEST are
    listed by name with their reason. Test-only change.

  • A server built in a test can take an account mapping
    (#612).
    CheAppleMailMCPServer.init gained an optional accountMapping, passed to
    EnvelopeIndexReader, so a handler test over a fixture index no longer reads
    the developer's AccountsMap.plist. Without it the server behaves as before.

  • The six ways around the direct-write guard tests now fail a test
    (#492). A new
    outcome test has Mail apply the read repair 0.6 s later, so looks that do not
    wait, as with a declared Task that turns the sleeps into nothing, use up their
    tries. The timed trigger script has to equal the pinned untimed one plus its
    marks, and the store is opened and written in one place. Each evasion was made
    in the source and turned a test red. Test-only change; the frozen text is
    untouched.

  • More timing assertions kept clear of machine load
    (#611). The
    four assertions left over from #502 use a monotonic clock and a 5 s ceiling.
    RedactionTests also grew its inputs so that the ceiling can still catch a
    quadratic scan: with the pattern's lookbehind removed, a scan took 0.6 s on
    8,192 characters, which a 5 s ceiling would miss, and 9.4 s on 32,768.
    Test-only change.

  • The direct-write path's outcomes after the write are tested without Mail
    (#484).
    DirectDraftPath now reaches Mail through a small protocol, and takes the OS
    version and the account lookups as settable values. No behaviour changes, and
    the code after the write is untouched. DirectDraftPathOutcomeTests runs the
    real path and the real DraftStoreWriter against a test SQLite store with a
    stand-in for Mail: upload confirmed, upload not confirmed in time, failed
    trigger rolled back, failed trigger after Mail already uploaded, failed trigger
    that cannot be rolled back, and the read repair, each with its outcome code and
    direct step sequence. Two new tests take the timing CSV's flock from a
    separate process. These show the branches, not what the real Mail does.

  • The stdio probe is pinned to initialize
    (#623). The
    probe keeps HOME on its environment allow list, so a tool call through it
    could reach the real Mail data. A new test scans its own source and fails if
    any JSON-RPC method other than initialize is written there, and its message
    lists what to inject first. The scan is textual, so a frame assembled from a
    variable gets past it. The injection points stay deferred until a test needs
    them; this is test code only.

  • The stdio shutdown probe starts with an allow-listed environment and checks its own assumptions
    (#578). The
    probe now starts with a small allow-listed environment (PATH, HOME,
    TMPDIR, USER, LOGNAME, DYLD_*), so switches such as
    CHE_MAIL_EXPERIMENTAL_DIRECT_DRAFT or MAIL_APP_INTEGRATION_TESTS no longer
    reach it. A probe that never started is reported without writing to its stdin.
    A new canary fails when LIBDISPATCH_COOPERATIVE_POOL_STRICT stops narrowing
    the cooperative pool to one thread, which would silently turn the strict
    shutdown tests into ordinary-pool tests. StdioProbeBuildPlan compares
    resolved paths, so a checkout reached through a symlink (/tmp is one) finds
    its link command. Test-only change. The probe still fakes only scriptRunner
    and refusal, because it sends nothing past initialize
    (#623 tracks the
    rest).

Documentation

  • r-must-direct-db.md no longer teaches the banned stderr call
    (#553). Both
    Hybrid pattern examples used the non-throwing FileHandle.write(_:), which
    NoNonThrowingStderrWriteGuardTests forbids because it aborts the process on
    a bad descriptor; they now use Diagnostics.emit. Stale file:line
    references became symbol names.