2026-11-08: The Postbox That Lied in a Millisecond

A doorbell can ring while the bolt stays thrown. Yesterday’s repair in The Postbox That Slept Behind the Curtain taught Jocasta to knock on Mail.app’s door every hour (check for new mail), drain background activity count to zero, and cap quiet-inbox rescue at eighteen hours so upstream stalls would still page Force Flow. At 07:41 Sunday morning on manoir, that fuse fired. crm-freshness paged CRITICAL (email: 33.5h since last message, SLA 6h). The bell had lied. Asking a hidden macOS app whether it checked the mail is very different from proving a packet ever crossed the wire.
1. The 1-millisecond false green inside MCTaskManager
Section titled “1. The 1-millisecond false green inside MCTaskManager”Mail.app (PID 33259) had launched headless via open -gj -a Mail on Friday afternoon with NSAppSleepDisabled unset. Seven hours later (2026-11-07 03:08:49Z), its internal MCTaskManager worker queue deadlocked completely while the main Cocoa runloop stayed responsive:
- Push events arrived and vanished.
EWSStreamingSubscriptionkept receiving Exchange push wakes every five seconds (Syncing 2 folders in response to 5 events). ZeroMFEWSMailboxSyncTaskjobs started. check for new maillied in0.001s. Every hour, Jocasta’s AppleEvent loggedStarting a manual fetchat.963andBackground fetch completedat.964— a 1-millisecond roundtrip that queuedIMAPMailboxSyncTaskentries onto the frozen queue whilebackground activity countanswered0.- Ninety-four weekend emails waited upstream. Quitting
PID 33259and launching a fresh hiddenMail.app(PID 48278) reconciled every account in under fifteen seconds: 94 queued weekend emails,97total through Sunday noon.
Two secondary traps surfaced during live recovery. First, yesterday’s rolling cursor rule (cutoffs[acc] < now - 36h) matched active accounts too, because per_account_cutoffs() already subtracts the 36-hour overlap from each DuckDB watermark. While Mail.app sat frozen, that rule crept mail-jxa-cursor.json forward past Friday evening’s Exchange watermarks. Deleting the cursor file saved every Friday message. Second, harvesting a 48-hour catch-up slice on the largest inbox hit the 300s JXA timeout twice in a row.
2. Ground-truth wire witness and a 13x JXA speedup
Section titled “2. Ground-truth wire witness and a 13x JXA speedup”Sampling Mail.app’s main thread (sample Mail 1) pinpointed why dense catch-up slices crossed five minutes after The Read That Would Not Die. MFMailbox(ScriptingSupport) lacks indexed Key-Value Coding accessors. Keeping an unevaluated NSIndexSpecifier (var msg = mb.messages[i]) forced Foundation to call -[MFLibraryStore copyOfAllMessagesWithOptions:] — materializing every SQLite row in the mailbox — on every property and recipient lookup (5 to 15 full-table scans per message). Evaluating var msg = mb.messages[i]() once resolves the index into an O(1) messages.byId(uid) primary-key specifier. Pairing it with bulk msg.toRecipients.address() dropped that catch-up slice from >300s to 23.64s. Thirteen times faster.
To witness genuine Exchange wire activity without granting interpreter-wide Full Disk Access (cfprefsd gates ~/Library/Containers/com.apple.mail behind FDA under launchd), Jocasta now reads MFExchangeAccount’s Default-level unified log events (MFEWSLastSyncDate-<UUID> wrote last sync date to user defaults on the main thread). Apple marks those events %{public}@ and emits them only after MFEWSMailboxSyncTask finishes reconciling folders on the wire:
Fault uncovered on 2026-11-08 |
Root mechanism on manoir |
Permanent defense in sanctum-crm |
|---|---|---|
check for new mail 1ms false-green (38h freeze) |
Headless MCTaskManager deadlocked while AppleEvents still returned 0 active tasks |
Verify min(MFEWSLastSyncDate-*) <= 1800s across active Exchange tenants (cfprefsd + zero-FDA /usr/bin/log fallback), pin NSAppSleepDisabled=YES, and auto-relaunch Mail.app when stale |
300s catch-up timeout on the largest inbox |
Unevaluated mb.messages[i] re-scanned every SQLite row in the mailbox per property + per recipient |
Resolve mb.messages[i]() once to O(1) byId(uid) + bulk msg.toRecipients.address() (>300s -> 23.64s), narrow timed-out >=8h slices to 12h, and relaunch before sibling accounts on double timeout |
| Rolling cursor creeping past frozen active accounts | cutoffs[acc] = watermark - 36h always trailed now - 36h, writing cursors onto active accounts |
Retain rolling cursors strictly when server_sync is verified and cutoffs[acc] < now - 48h (dormant accounts such as iCloud only) |
Weekend quiet SLA vs deadlocked Mail.app |
Unverified 18h rescue rightly paged at 33.5h, while un-witnessed extension would mask freezes |
Extend weekend quiet rescue to 48h strictly when ews_last_sync_at proves wire sync within 2.5h |
Jocasta no longer takes the postbox’s word that the mail carrier stopped by. Every hourly beat verifies the timestamp stamped by the Exchange engine itself, heals a wedged Mail.app before messages pile up, and sweeps the deepest trays in seconds.