For developers
Build a connector.
A connector copies data from one place, like a chat app, an export file or a folder of transcripts, into SafeContext. Every item is scrubbed on the Mac before it's stored.
- Built inGmailGoogle CalendariMessage
- Coming soonWhatsAppCall recordings
Anyone can write one. They ship inside the app.
There's no plugin folder, and SafeContext never loads code from outside the app. A connector sees raw data before the scrubber does, so every one is reviewed before it reaches anyone's Mac. That's what keeps the promise that your data is scrubbed on your Mac.
-
Open a pull request
Add your reader and connector, register it, and pass the conformance kit.
-
It's reviewed
We check it against the seven rules below. A pull request that breaks one isn't merged.
-
It ships in the next release
Merged connectors go out in the next signed, notarized build of SafeContext.
The rules
These protect what SafeContext promises its users. A pull request that breaks one isn't merged.
- Read-onlyNever send, change or delete anything at the source.
- Nothing leaves the MacNo network calls, except to a service's own official API for a sign-in connector. No analytics and no phoning home.
- Everything goes through the scrubberReturn
RawItems fromto_itemand letReaderSourcedo the rest. Never write to the store or overridesync(); the registry refuses a connector that does. - No raw data in logsLog ids and counts only. Never message text, names, numbers or addresses.
- Ask, don't takeDeclare every permission in
requirementswith a plain reason. Check access without triggering a macOS prompt, and raiseNeedsPermissionwith help that tells the user what to do. - Fixture data only in testsBuild fake databases or files in a temp folder. Never read real user data, not even your own.
- No new dependenciesNot without asking first in the pull request.
How to build one
Connectors are Python. Start from tests/example_connector.py, a complete working connector for a chat export file.
1. The reader
In src/safecontext/readers/. It knows the source's format and nothing about SafeContext: a function or class that yields plain records, oldest first, starting after a cursor.
2. The connector
In src/safecontext/sources/. Subclass ReaderSource. Batching, scrubbing, storing, resuming from the cursor, progress and error handling all come for free.
idLowercase and stable. Items are stored under it, so it never changes.name,descriptionShown on the Sources screen.kindsOne or more ofmessage,event,chat,transcript. The scrubber picks its rules by kind, so new kinds aren't allowed.api_version1, the current connector API.requirementsWhat the connector needs, each with a reason for the user.read(cursor)Records aftercursor(Nonemeans everything), oldest first.to_item(record)One record to oneRawItem, orNoneto skip it.cursor_of(record)A string that makesreadresume after this record.check_access()Optional. RaiseNeedsPermissionwhen access is missing.
tests/example_connector.pyclass ChatExportSource(ReaderSource):
id = "chat_export"
name = "Chat export"
description = "Chats from an exported JSON Lines file you choose."
kinds = ("chat",)
api_version = 1
requirements = (Requirement(FILE, "", "A file you choose",
"SafeContext reads only the export file you pick, read-only."),)
def read(self, cursor):
return read_export(self.path, int(cursor or 0))
def cursor_of(self, record):
return str(record.line_no)
def to_item(self, r):
if not r.text.strip():
return None # nothing to keep
return RawItem(id=r.id, kind="chat", thread_id=r.chat,
date_ms=r.ts_ms, sender=r.sender,
participants=[r.sender], title=r.chat,
text=r.text)
3. Register it
Add your class to CONNECTORS in sources/__init__.py. One line.
4. Pass the conformance kit
Add a ConnectorFixture to tests/test_connector_conformance.py, add your own tests for to_item, and run .venv/bin/pytest. Every test must pass.
The kit's nine checks
- The declaration is valid and registered
- A first sync adds up, with only declared kinds
- A second sync resumes without duplicates
- A bad record is dropped and the sync goes on
- A crash while reading is reported and retried
- An undeclared kind is never stored
- Missing access raises a permission the app can explain
- Disconnecting deletes the connector's data and cursor
- Card numbers and one-time codes never reach the store's files
Connectors that need a sign-in, like Gmail and Google Calendar, sync through their service's API and aren't covered by the kit yet. Open an issue before you start one, so sign-in and token storage can be designed with you.