What "nothing leaves the Mac" means in code for a local-first app
The meeting-notes app I've been building for myself makes one promise, which is that nothing about a meeting leaves the Mac, so no cloud, no telemetry, no bot in the call, and the audio, the transcript, the summary and the names of the people in it stay on the machine. Getting the audio out of macOS was a story of its own, and this post is about the promise itself, because a sentence like that in a README doesn't do anything on its own, and most of what I learned was about turning it into rules that something checks.
It started as a list in the instructions the coding agents read ("never log transcript text, titles or people's names", "no plaintext HTTP to anything but localhost"), and for the reasons in the post on agent rules, every one of those ended up needing something that fails when it's broken.
The sandbox, and what it leaves open
The first and biggest rule is the App Sandbox, which stays on. In the XcodeGen spec that's three lines:
ENABLE_APP_SANDBOX: YES ENABLE_OUTGOING_NETWORK_CONNECTIONS: YES ENABLE_INCOMING_NETWORK_CONNECTIONS: NO Keeping it has a cost that's worth knowing before you commit to it. A few meeting-notes apps read the participant list and the active speaker straight out of the Zoom or Teams window through the Accessibility API, which is the easiest way to put names next to voices, and Apple's DTS position is that Accessibility APIs can't be used from a sandboxed app (there's no entitlement for it). So the choice was between dropping the sandbox for an app that records audio and reads the calendar, or getting names some other way, and I went with the other way, an opt-in voice memory plus suggestions from the calendar invitees, which is more work and less accurate on the first meeting with someone new.
The sandbox doesn't cover the network tho. Outgoing connections are allowed, because the summary comes from a local LLM server the app talks to over HTTP on localhost, because a remote provider is available as an explicit opt-in, and because the models and the LLM server's installer are downloaded when you ask for them in setup. That means the sandbox would let a transcript go to any host in plaintext, so the cleartext rule has to live in code. The local backend's URL is checked by resolving the host and refusing plain HTTP unless every address it resolves to is loopback:
guard scheme == "http" else { throw LocalNoteError.insecureConnection(host: host) } // https returned earlier let status = getaddrinfo(host, nil, &hints, &result) // ... while let addr = current { defer { current = addr.pointee.ai_next } if addr.pointee.ai_family == AF_INET { // 127.0.0.0/8 only guard (ip >> 24) == 127 else { throw LocalNoteError.insecureConnection(host: host) } } else if addr.pointee.ai_family == AF_INET6 { // exactly ::1 guard isLoopback else { throw LocalNoteError.insecureConnection(host: host) } } else { throw LocalNoteError.insecureConnection(host: host) } } We resolve instead of comparing the host string because localhost can be pointed elsewhere and a name can resolve to a mix of addresses, and an unknown address family throws instead of being skipped. HTTPS to any host passes this check, since the rule is about cleartext, and remote providers go through a stricter version that wants HTTPS with no loopback exception at all. A resolve-then-connect check like this one only holds as long as the connection uses the address that was checked (the networking stack resolves again when it connects), so the stronger form is to connect to the literal loopback address. With the defaults, no meeting data goes anywhere but 127.0.0.1, and the other traffic is the model and installer downloads (plus the LLM server pulling its own models and updating itself, from its own process), none of which carry anything about a meeting.
Checking what a system framework does
The app also uses Apple's on-device SoundAnalysis classifier to notice that nobody has spoken for a while. Apple says the classification runs locally (WWDC21 session 10036), but with outgoing network allowed the sandbox wouldn't stop a framework from connecting somewhere, and "Apple says so" felt thin for a feature that runs on every recording by default.
The first check was lsof on the app during a 60-minute probe, which showed no sockets, and a review pointed out two gaps, that lsof sees only the moment it runs, and that a system service could connect under its own process rather than the app's. The validation then became nettop -p <pid> every 30 seconds through a full recording with the feature on, compared with a baseline run with it off, with the pass condition being no socket the baseline run lacked, and on an installed Release build there was no socket in any of the 61 and 62 snapshots. That's more samples, but it's still sampling, and -p still lists only the app's own sockets, so it rules out a lasting connection from the app's process and says nothing about a short one or one a daemon makes for us. A classifier run under a sandbox profile that denies the network, where classification has to keep working, would close the first gap (a short connection from our process would show up as a denial), but a system service connecting for us would still be out of sight. I haven't run it yet, so for now the evidence is Apple's statement plus a sampled check of our own process.
Logs
Logs are where we break a privacy rule most easily, because a log line is the first thing anyone (agent or human) adds while debugging, and logger.info("Saved \(meeting.title)") looks harmless. The rule is that logs carry operation types, durations, byte counts and IDs, never content, and in June an agent added grep-style pre-commit gates for it, the logging gate among them, in a commit that said the gates "pass clean".
They did pass clean, for four months and 216 non-merge commits, because three of the eight used \b for a word boundary, the logging gate being one of the three, and macOS awk (version 20200816) has no \b. It reads it as a backspace character, so a pattern bounded by \b can never match:
awk 'BEGIN{print ("import Combine" ~ /\bCombine\b/)}' # 0 An agent noticed while adding people's names to the logging gate, because the new pattern couldn't fire either. The first fix swapped \b for an explicit non-identifier class and added a self-test, and the review of that fix still got through with two shapes it hadn't tried, a meeting title in the second interpolation of a log call, and a logger not named exactly logger. The gate now flags a sensitive name in any interpolation of a one-line call on any logger whose name ends in logger or Logger (a call whose message starts on the next line is out of its reach), and since awk also has no lookahead, the one allowed exception, a sensitive value's .count or .isEmpty, is spelled out letter by letter (abbreviated here):
not_a_count='([^A-Za-z0-9_.]|\.[^ci]|\.c[^o]|\.co[^u]|\.cou[^n]|\.coun[^t]|\.count[A-Za-z0-9_]|\.i[^s]|...)' What makes it trustworthy is selftest.sh, which feeds every gate a known violation and a near miss, and a gate that doesn't flag the violation fails the run:
expect fail "$logging" no-user-content-logging 'logger.info("Loaded \(items.count) items for \(meeting.title)")' expect fail "$logging" no-user-content-logging 'perfLogger.debug("Opened \(meeting.title)")' expect pass "$logging" no-user-content-logging 'logger.info("Meeting \(meeting.id.uuidString)")' When the patterns could finally match, the tree had no violations, so nothing had leaked, but for four months nothing would have been caught either.
A gate that matches nothing looks exactly like a clean tree. So a gate isn't done until a line that should fail it does.
What <private> hides
os_log pulls the opposite way. Interpolated strings and objects in a Logger call are redacted to <private> by default (numbers and Bools aren't), which sounds like it does the privacy rule for us, and for content it mostly does. It also redacts the app's own errors, tho. The microphone in this app was silently dropped for months, and the warning that would have named the cause was logged as <private>, and when a broken local LLM install returned 500 on every request, the app logged Resummarization failed: <private> and the real error only showed up after replaying the request with curl. If we rely on the default, we're logging content and hoping it's hidden, and we lose the things we need to see. So the gate keeps content out, and fields that say nothing about a meeting are marked public on purpose:
logger.error( "Speech classifier setup failed: domain \(nsError.domain, privacy: .public) code \(nsError.code)" ) An error domain and code, a type name or a count says nothing about a meeting, and this way it's readable in Console when something breaks.
Biometric data that has to go away
The app can recognize a voice across meetings, which means storing a voice vector per speaker (256 floats from the diarization model), and that's biometric data, so the rules there are stricter. Vectors are stored only while an off-by-default setting is on, and turning it off deletes every one of them.
"Stored only while it's on" has one enforcement point. The flag lives in the database under a key only the store can write, and saving a diarization result reads it inside the same write transaction that inserts the speakers:
try await db.write { db in // ... delete the meeting's old segments and speakers let keepVoiceVectors = try Self.isVoiceMemoryEnabled(db) for speaker in speakers { var stored = speaker if !keepVoiceVectors { stored.voiceVector = nil } try stored.insert(db) } // ... } The database serializes writes, so a diarization run racing the switch can't leave a vector behind. If its write lands after the switch, it reads the flag as off and stores none, and if it lands first, the switch's own transaction deletes what it stored.
Turning the setting off first ran an UPDATE ... SET voiceVector = NULL, which is correct for every query, and the review pointed out that a delete in SQLite doesn't mean the bytes are gone. Apple's SQLite ships with secure_delete set to 2 (FAST), which zeroes freed space in pages it rewrites anyway but not pages that go to the freelist, and the write-ahead log keeps old page images until they're overwritten or the log is truncated. A 1,024-byte vector sitting in a free page is still a voiceprint on disk. The fix has two parts, secure_delete on every connection:
config.prepareDatabase { db in try db.execute(sql: "PRAGMA secure_delete = ON") } and a truncating checkpoint after the delete, outside any transaction:
try await db.writeWithoutTransaction { db in _ = try db.checkpoint(.truncate) } The checkpoint is best effort. With GRDB's default busy mode it fails at once if a reader is in the middle of a transaction, and the old frames then stay in the log until a later checkpoint truncates it or the last connection closes, so if you copy this, give the writer a busy timeout or retry the checkpoint. secure_delete = ON writes zeros over every page a delete frees, so its extra I/O grows with how much a delete frees (and in WAL mode each zeroed page goes through the log too), which is nothing for one person's meetings and not free for bulk deletes on a large database. All of this covers SQLite's own files and nothing below them. A truncated WAL frees its blocks without overwriting them, APFS and the SSD can keep old copies, and a local snapshot taken before the delete still has the vector, which is what FileVault is for, and it's below anything the app can promise.
The same review caught one more way out, which was the synthesized Codable on the vector type, so any future JSON export of a speaker would have written all 256 floats into it. Now the vector refuses:
public func encode(to encoder: any Encoder) throws { throw EncodingError.invalidValue(self, EncodingError.Context( codingPath: encoder.codingPath, debugDescription: "A voice vector is written only to its database column." )) } The vector's description prints only the dimension count, so it can't end up in a log line by accident either, and a test checks that the production configuration really has secure_delete on, which is the kind of setting that disappears in a refactor without anyone noticing.
Emails we only need to compare
To show notes from the last meeting with the same people, the app needs to tell that two calendar events have the same invitees, which means comparing email addresses, but it never needs to show or send one. The first design stored a SHA-256 of each normalized address, and the review rejected it, because a plain hash stored next to the person's display name is easy to guess (firstname.lastname@ plus a handful of domains), and it's the same "hashed email" that ad-tech uses to join lists, so the stored value would be linkable with data from elsewhere.
What shipped is an HMAC with a random key that's made on first use and stays in this Mac's Keychain:
func hash(_ normalizedEmail: String) -> String { HMAC<SHA256>.authenticationCode(for: Data(normalizedEmail.utf8), using: SymmetricKey(data: key)) .map { String(format: "%02x", $0) } .joined() } Equal addresses still give equal hashes on this machine, but without the key a stored hash can't be checked against a guess or matched with anything outside the app. The key is stored with kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly and isn't synchronizable, so it doesn't move to another device. When the key can't be read or made, the app stores invitees by name only and turns same-people matching off instead of falling back to the plain hash the review rejected. In my own builds that's what happens today, because the data-protection Keychain fails with -34018 (errSecMissingEntitlement) without a provisioning profile, and a fallback to the weaker hash would have undone the rule in exactly those builds.
Screen sharing is a way out too
The data doesn't have to go over the network to leave the Mac, it can also go out through a screen share. During a recording the app shows a small floating panel, and the card with notes and action items from the last meeting with the same people starts folded to a heading with no past title, and opens only when asked, from a badge on the pill or from the card's own heading. The panel isn't excluded from screen capture, and a card that popped open on its own would show last week's action items to everyone in today's call. Meeting titles in notifications are behind a setting, off by default, for the same reason, since a banner during a presentation is on everyone's screen.
Summary
Most of the promise ended up as small rules with one place each that enforces them, and the first version of almost every rule saw less than it claimed. The gates matched nothing until each had to catch a known bad line, the delete left the bytes until secure_delete and a checkpoint, and a plain hash was one anyone could recompute. Where a check could be made to fail on purpose, or the bytes on disk could be read, that settled it, and where it couldn't (the network check on a system framework) the honest thing is to say what the check covers and what it doesn't, rather than call it proof.