Letting the Network In Without Letting the Data Out
October 2026 · 13 min read
In July I wrote that Atlas, my on-device AI second brain, made exactly one network request: it downloaded the model, once, and that was it. A test called NetworkEgressIsolationTests scanned every source file and failed the build if networking code showed up anywhere else. I was proud of that sentence, and for a few months it was true.
It stopped being true in September. Atlas can now talk to a cloud model on your own API key, read your Outlook mailbox over Microsoft Graph, and, if you say yes to a specific photo, send that photo to the model you chose. This post is about how I let those three things in while keeping the promise enforceable, and about the deep review in late October that found two ways health data could still reach a cloud model after all.
Atlas series
- Fitting a Second Brain Into 8,192 Tokens (the July original)
- Taming Small Models That Don't Speak Your Tool Protocol
- Retrieve, Then Generate: Closing the Speed Gap on a Phone
- Letting the Network In Without Letting the Data Out
- Ears and Eyes on a Phone: Voice and Vision in Atlas
- The Experiments I Didn't Ship
- Atlas, July to November
Why open the door at all
In early September I did a strategic audit of the whole app, and it reached an uncomfortable conclusion. The part of Atlas that was actually different from everything else on the App Store was the memory layer: the ingest pipeline, the hybrid index, the graph, the retrieval rules. The weakest layer, and the one I had the least control over, was the small language model at the end of it. Gemma E2B was failing the groundedness gate in my own eval suite. I could keep polishing prompts for a 2B model, or I could let people who already pay for a frontier model plug it in, while the memory stays exactly where it was.
I chose the second option and kept every on-device runtime. The model is a swappable component behind one LLMBackend protocol, so a cloud backend became the third implementation next to LiteRT-LM and MLX. It is built on Hugging Face's AnyLanguageModel package and speaks to Gemini, OpenAI, Anthropic, any Open Responses endpoint, or an Ollama server on your own network.
Mail came in a few days later for a blunter reason. On the Mac, Atlas reads Apple Mail straight off disk from ~/Library/Mail. On iOS there is no readable mail store and no API to read one. If you want your phone's second brain to know about your inbox, a remote provider is the only option there is.
What the old rule actually checked
The July test is deliberately dumb, and I still think that's its best quality. It does a raw-text scan of every .swift file under Sources/ and looks for tokens that open a connection: URLSession and its task types, .data(from:, NWConnection, CFStream. It also bans Process(, so nobody can shell out to curl, and CLGeocoder, because reverse geocoding would quietly send your location visits to Apple's servers. Atlas stores raw coordinates instead. There's no syntax tree and no clever analysis. A doc comment that writes URLSession in the wrong file fails the build, and I accept that false positive, because the fix costs one rename and a real leak can never land silently.
So the question for each new feature was never "is this safe?" in the abstract. It was "which file gets to contain the token, and under what condition does that file's code ever run?"
Three lanes, each with one gate
The invariant (number 6 in the project's list of laws) now reads: network egress is a weight download, a user-enabled remote model, or a user-connected mail account, and nothing else. Each of the three lanes has exactly one file allowed to open it and a condition that has to be true before that file's code is even constructed. Try the toggles below.
Both off (the default). The only lane that ever opens is the weight download, and it carries no user content.
Lane (a): weights
This is the July lane, slightly wider. LLMModelManager.downloadModel fetches model bundles over HTTPS from a host allowlist in the manifest and verifies a streaming SHA-256 against the value compiled into the app. A test checks that every downloadable manifest entry passes its own allowlist, so a typo in a URL fails the build. Voice models arrived later and are the honest exception: WhisperKit and FluidAudio (Parakeet, Nemotron and the diarizers) download public weights through their own clients, which the source scan can't see. FluidAudio's downloads only start from a Download tap. Neither is SHA-pinned. I wrote that trade down in the invariant itself rather than pretend the scan covers it.
Lane (b): a cloud model on your own key
RemoteLLMService is the only file allowed to import AnyLanguageModel, and the scan enforces that just like it enforces URLSession. It is off by default. LLMBackendFactory builds it only when the remote config is enabled and the provider's key is in the Keychain, stored as kSecAttrAccessibleWhenUnlockedThisDeviceOnly and never in UserDefaults or a log. If either condition fails, the "remote" model degrades to the same "no model" placeholder as a missing bundle, and a test proves the Keychain is not even read while the feature is disabled. Turning it on goes through a data notice. While it's active, the chat shows a banner that doesn't go away, and the empty state stops claiming everything stays on the device.
What it sends is the prompt of each chat turn: your question, the conversation, and the excerpts retrieval picked. The memory layer never uses it. Ingest, indexing, the graph, MCP and background enrichment all stay local, because enrichment would ship whole documents to a provider without you asking for anything. Standing questions skip while the remote model is selected.
Lane (c): your mailbox, inbound only
GraphMailProvider reads your Outlook or Microsoft 365 mailbox. Nothing goes up except the access token and Graph's own query parameters. It's off by default, gated on a config flag plus a refresh token in the Keychain, and it syncs only while the app is in the foreground, so your mail can be a little stale until you open Atlas. I'm fine with that trade.
The part I like most is structural. The file is sanctioned by name in the scan, but its only real connection lives in a single live(...) transport factory. Everything else in the file is parsing. That's why all eleven of its tests run against an injected stub and never open a socket, and why a reviewer can audit the network surface of the mail feature by reading one function.
The entitlement that proved nothing
Writing the mail lane taught me something embarrassing about the July post. One of the egress tests, networkEntitlementOnlyOnMacApp, checked that only the macOS app carries the com.apple.security.network.client entitlement, and I had counted that as evidence the iOS app couldn't reach the network.
It never was. That key belongs to the macOS App Sandbox, and iOS ignores it entirely: any iOS app can make outbound HTTPS calls. The test would have stayed green when Graph mail landed on iPhone, which is exactly when it should have complained. On iOS the two real constraints are which file may connect (the source scan) and whether that code is ever constructed (the config and Keychain gate). I rewrote the test in place so its name and message say that, because a green test asserting something false is worse than no test.
A green test that asserts something false is worse than having no test.
A photo is the narrowest door
In October, cloud models got photos. Of everything that can leave the device, a photo is the most personal, so this part of lane (b) is the most locked down. A photo goes to the provider only when you attached it to that turn and approved that one photo in a dialog that names the recipient, like "Send this photo to Anthropic?". There's no "always allow" option.
Before the dialog appears, ImageAttachmentPreparer turns the photo upright, scales its long edge down to at most 1,568 pixels, keeps it under 2 MB and re-encodes it as a JPEG with GPS, EXIF, TIFF and IPTC metadata stripped. The dialog shows those exact bytes, which are also the bytes that get sent.
The approval itself is a default-deny @TaskLocal called ImageEgressConsent. Only the in-app chat binds it, with a handler that says yes once and only to those bytes. Siri, MCP, the demo and enrichment never bind it, and the source scan checks that the one-shot approval appears in ChatView.swift and nowhere else. If the consent is missing or declined, the turn ends with an error and nothing is sent. It does not quietly fall back to a text-only answer, because Atlas has a separate rule against silent retries. Tool rounds inside the approved turn may re-send the photo to the same provider. Later turns never do, since history keeps only the text.
Two boundaries that used to be one
Adding mail forced me to split a rule I'd thought of as a single thing. Atlas already kept health, location and observation data out of the knowledge graph. Email needed to stay out of the graph too, for a different reason: it's attacker-authored. Anyone who knows your address can write a message, and if senders, companies and claims from message bodies could mint graph nodes, anyone could write into your knowledge graph.
But email should not be hidden from the off-device surfaces. A local MCP client searching your mail on your behalf is the whole point of indexing it. So Atlas now has two constants that used to be one set:
| Source | Kept out of the graph | Kept off-device (MCP, Siri, Spotlight, widget, cloud model) |
|---|---|---|
| Health, location, observations | Yes | Yes |
| Look's camera memory | Yes | Yes |
| Yes (attacker-authored) | No, searching it is the product | |
| Notes, files, calendar | No | No |
A cloud model counts as an off-device surface. Every backend reports sendsPromptsOffDevice, and only the remote one says true. When it does, agentQuery unions the off-device exclusions into whatever filter the caller passed, so health, observations and location never ride the pre-retrieved excerpts, the model's own search_knowledge calls or the health tool. A surface's exclusions always win over an include, so an MCP client asking for sources: health gets an empty result instead of a wider search.
That union shipped on October 24. Five days later, a review showed me it had two holes.
Then I had the whole thing reviewed
Between October 25 and 29 I ran a full-codebase review as a multi-agent workflow in Claude Code. Finder agents read each subsystem, and every finding had to survive two independent adversarial verifiers, plus a tie-breaker when they disagreed, before it counted. It confirmed 152 findings. Merging the ones that shared a root cause left 135.
Two of the three criticals broke the boundary I had just built.
C1 was the calendar shortcut from the July post. When a question names a time period, Atlas injects dated "day cards" straight from one SQL range query, with a high score and a boost, bypassing the retriever. The exclusion filter was applied in both retrieval legs, FTS and vectors, but that injection never received it. So with HealthKit ingestion and a cloud model both on, the perfectly ordinary question "what did I do this week?" sent the week's health summary and workout cards to the provider.
C2 was a timing bug in two places. Briefing narration checked whether the backend was off-device before the chat path resumed a suspended model, and a suspended backend is a placeholder that reports false. Suspends are routine: an ingest memory gate or a memory-pressure warning both cause one. In the chat path, agentQuery read the off-device flag near the top but only captured the backend for streaming much later, with several awaits in between, so switching from a local model to a cloud model mid-turn could stream excerpts retrieved under on-device rules.
The review's summary of the pattern stung because it was accurate: trust boundaries were enforced per surface instead of at one choke point. Smaller findings fit the same theme. Switching provider while remote was enabled skipped the new provider's data notice (H10), and a briefing narrated by a cloud model still said "Written on this device" (M5).
Email, the source I had just labelled hostile, reached privileged sinks too. A ```chart fence is untrusted JSON, and the charting library wrote string tooltip formatters into innerHTML under a content policy that allowed inline handlers, so a crafted chart could run script (H2). The confirmation card for act-tools showed a label and a date but hid the payload you were approving, so a prompt-injected email could get a false fact remembered behind a blind "Allow" (H3). Email identity was keyed on the sender-controlled Message-ID, so someone who knew a real message's ID could send a new one that overwrote it in the index, fake payment details included (M3).
Fixing it in one day, one batch at a time
On October 29 I worked through the plan in 31 batches, one commit each, starting with the boundary. Every batch began with a regression test that failed on main. The first batch passes the turn's filter into the calendar injection, makes agentQuery read its backend exactly once for the exclusion, window, tools and stream, decides briefing egress from the selected model as well as the live one, and revokes consent at the one place a provider or base URL is saved.
It also adds the choke point the review asked for. RemoteLLMService now withholds any tool result or history turn whose citations name an off-device-excluded document. If some future surface forgets the filter again, the last file before the network still refuses. The second batch strips chart options down to safe fields before rendering, drops 'unsafe-inline' from the script policy, and makes confirmation cards list every argument the tool will write. A later batch keys email on the provider's own identity and keeps Message-ID for threading only.
Some findings were about the tests themselves. The MCP exclusion test re-implemented the wiring with a literal instead of testing the real code (L6), and the rule that interactive search never calls the LLM had no enforcing test at all (L7). A rule is only as good as the thing that checks it.
One thing remains deliberately out of scope, and the policy and the enable notice both say so. If you switch to a cloud model in the middle of a conversation, the earlier turns are already in that conversation's history and get sent as history, minus anything citing an excluded source.
The doors that open inward
Privacy also covers who can open the app. October added App Lock: Face ID, Touch ID or your passcode when you return, immediately or after 1, 5 or 15 minutes. LAContext lives in exactly one file, AppLockController.swift, and a source scan keeps it there. The first biometric prompt you ever see is the one triggered by turning the lock on, which also proves you can get back in. Siri can't be shielded by an in-app lock, so the intents that read your library now require an unlocked device.
The same "only after you asked" rule now covers permission prompts. Passive surfaces like the briefing card, observation detectors or the Meeting screen's upcoming list read reminders and calendar only if access was already granted. The review caught the calendar side still prompting from a passive surface (M2), so opening an empty chat could pop a permission sheet. Now only an action you took can trigger one.
What I'd tell July me
The raw-text scan held up. Every new lane was easy to reason about because the scan forced a single answer to "which file?", and I'd build it the same way again. What I underestimated was everything after the file. Deciding whether a lane is open and what is allowed through it can't be spread across every caller that builds a prompt, because one of those callers will be a shortcut you wrote months ago for a different reason. The calendar injection in C1 is a feature I described proudly in July.
So the rule I work by now has two halves. Each kind of egress gets one file, enforced by a dumb scan. Each trust decision gets one choke point right before that file, enforced by a test that runs the real code path, because the copies are where the holes were.
Try Atlas
Get Atlas for iPhone & iPad or get Atlas for Mac on the App Store. Cloud models and mail are off until you turn them on.
References
- AnyLanguageModel (Hugging Face): The Swift package behind Atlas's cloud backend. One API for Gemini, OpenAI, Anthropic, Open Responses and Ollama, which meant the remote lane could live in a single file the egress scan can name.
- Microsoft Graph mail API: How Atlas reads an Outlook or Microsoft 365 mailbox on iOS, where no local mail store is readable. Atlas only reads; nothing is ever uploaded.
- kSecAttrAccessibleWhenUnlockedThisDeviceOnly: The Keychain accessibility class for provider keys and mail refresh tokens. The secrets are readable only while the device is unlocked and never migrate to another device through a backup.
- com.apple.security.network.client: The macOS App Sandbox entitlement I once mistook for an iOS network guard. It is a sandbox key, so on iOS it constrains nothing.
- LocalAuthentication: The framework behind App Lock. Atlas always uses device-owner authentication, so the passcode remains a way back in when biometrics fail.
- OWASP LLM01: Prompt Injection: The threat model behind treating email as attacker-authored. A message body is written by someone other than the user, so it must never reach the graph or a privileged sink unchecked.
- Model Context Protocol (MCP): Atlas's local, read-only server. It's an off-device surface for health and location, and an intended way to search your mail.