ADR-052: The iPhone app is SwiftUI on iOS 17, built on a shared GolemKit package, and may save "Always allow" with Face ID
Date: 2026-11-13 Status: accepted, amended 2026-11-15 (no crypto dependency) Deciders: Milan Pavel
Context
Phase 14 (#745) puts golem on the iPhone: a place to watch and decide while you are away. ADR-051 says how the phone and the Mac find each other, how they trust each other, and what the relay sees. This record is the app's side: how it is built, tested, and shipped, and when the phone may approve what.
docs/vision/everywhere.md already chose a native app in SwiftUI, with one shared Swift package for the protocol types, the connection, and the view state, so that a Mac app can reuse it later. Four things were still open:
- the iOS floor, and the layout of the repo
- how the Swift types stay in step with the Python and TypeScript ones
- how the Xcode project is kept, how CI builds it, and how it reaches a phone
- which approvals the phone may answer, and with what proof that the owner is holding it
docs/vision/security.md said "always allow" is off on the phone by default. That was a safe first guess. In use it sends the owner to the Mac every time a routine meets a tool they have already decided about, which is the trip the phone exists to save.
Decision
The app
- SwiftUI and the Apple frameworks only. No UIKit screens unless SwiftUI cannot do the thing (the camera scanner may wrap VisionKit). No third-party UI, networking, or state libraries.
- Minimum iOS 17.0. iOS 17 gives
@Observable(the Observation framework, so GolemKit's view state is plain Swift types without Combine), interactive Live Activities and widgets (Allow and Deny buttons on a Live Activity), and, from 17.2, push-to-start for a Live Activity (14.6.3). iOS 16 would need a second state model and would lose both. The phones that stop at iOS 16 (iPhone 8 and X) are nine years old, and the user of this app is a developer with a Mac. - No dependency besides Apple's frameworks. The Noise handshake is written by hand on CryptoKit and checked against the published vectors ADR-051 keeps in
packages/protocol(amended 2026-11-15; this line first allowed one crypto library). Nothing is added without an amendment to this record.
Repo layout
apps/apple/
GolemKit/ Swift package: types, connection, view state
Package.swift
Sources/GolemKit/
Generated/ written by `just gen`; committed; never edited
Tests/GolemKitTests/
Golem/ the iPhone app: sources, assets, entitlements
... its Notification Service Extension (14.6.1)
... its widget extension for Live Activities (14.6.3)
project.yml XcodeGen input
README.md build, run, TestFlightGolemKit is a package, not an app target, so swift test runs it on a Mac with no simulator. It has no UI code and builds for macOS as well as iOS, which keeps a Mac app possible. The app and both extensions link it and share one Keychain access group.
The Xcode project is generated, not checked in
apps/apple/project.yml is the source, and XcodeGen (MIT) writes Golem.xcodeproj from it. The .xcodeproj is in .gitignore. just ios runs xcodegen first, so a clean checkout builds.
A checked-in .xcodeproj is one machine-written file that merges badly. Every added source file touches it, and two parallel tickets (the roadmap runs several per wave) conflict in it for no reason a person can resolve by reading. project.yml is short text, reads in a diff, and lists the targets, entitlements, and extensions in one place. Tuist does the same and more, and is a heavier tool (manifests in Swift, its own cache and server) than one app and two extensions need. If the project outgrows XcodeGen, moving to Tuist is a change of one file.
Swift types come from the same schemas
just gen already exports packages/protocol/gen/*.schema.json and runs json2ts over each. It gains a second step that writes apps/apple/GolemKit/Sources/GolemKit/Generated/ from the same JSON Schema files with quicktype (--src-lang schema --lang swift, licence Apache-2.0). quicktype is a pinned dev dependency in the pnpm workspace, like json-schema-to-typescript, so it runs offline from the lockfile and adds no tool to a contributor's machine.
- One quicktype run over all the schemas, not one per file. The TypeScript step runs per file because
json2tsinlines a shared definition into each output. Run per file, quicktype would write the same type into one module many times, and Swift refuses duplicates. 14.4.1 settles the exact flags. If quicktype cannot produce a module that compiles,just genpost-processes its output; nobody edits it by hand. - The generated files carry the same banner as the TypeScript ones: "Generated by
just gen. Do not edit." - The method access table and the protocol version get Swift counterparts, written by the same Python exporters that write
browser-methods.tsandversion.ts, so the app knows which methods it may call (ADR-051 says which set a device gets) and checks the version onhello. - The drift check covers them.
just checkalready runsjust genand fails on a diff inpackages/protocol/gen. The Swift files are checked in the same way, on Linux, with no Mac needed. - Unknown input never crashes. An event type or a field the app does not know decodes to a fallback case. An older app must keep working against a newer daemon, since the protocol grows by minor versions.
Why quicktype. It reads JSON Schema, writes Swift Codable types, and is an npm package like the tool we already use. Apache-2.0 allows use and redistribution, and it is a build step that ships in nothing. Why not the Swift OpenAPI generator: the protocol is JSON-RPC described by JSON Schema, not OpenAPI. Why not a hand-written port: that is the drift the generated Python and TypeScript were built to avoid. Fallback: if quicktype's Swift cannot be made to compile cleanly, a small generator in golem_protocol/codegen.py can write Codable types from the same schemas, behind the same just gen. That would amend this record.
CI
A new job in .github/workflows/ci.yml on macos-15 (the runner dist already uses) runs when apps/apple/**, packages/protocol/gen/**, or the workflow file change:
swift testinapps/apple/GolemKit.xcodegen, thenxcodebuild buildof the app for the iOS simulator with signing off (CODE_SIGNING_ALLOWED=NO).
The path filter must not leave a required check missing on a pull request that skips the job, so 14.4.1 wires it the way the repo's ruleset needs (a filter step inside the job, not a paths: trigger, if the job becomes required). The existing Linux check job keeps the drift check. The job holds no secrets, and a pull request from a fork never sees signing keys.
Shipping
TestFlight first, App Store later. The first builds are uploaded by hand from Xcode (Archive, then Distribute), which needs only the owner's Apple Developer account. Once that works, a release job on macos-15, run by a version tag, archives and uploads with an App Store Connect API key kept as GitHub Actions secrets (key id, issuer id, the .p8, the signing certificate and profile). Secrets never enter the repo or a log. The App Store comes when the app is stable, because review adds delay and rules about what the app says it does. How to upload is in apps/apple/README.md (14.5.1).
A self-hosted relay's push needs the host's own Apple team and app build (ADR-051), so the bundle id and team are build settings in project.yml, not constants in code.
When the phone may approve what
The phone answers through the same approval.respond as the terminal and the web, with allow, allow_always, or deny. What differs is the proof that the owner, and not a thief holding an unlocked phone, is answering. That proof is Face ID (LocalAuthentication, deviceOwnerAuthentication, so the device passcode works when Face ID is not set up or fails).
| Answer | Where | Face ID |
|---|---|---|
| Deny | app, lock screen | never |
| Allow once, a tool that is not risky | app, lock screen | not in the app; the lock-screen action needs the phone unlocked (.authenticationRequired) |
| Allow once, a risky tool | app only | always |
| Always allow | app only | always, for every tool |
Risky tools can run code or change something beyond the session's folder:
shellandshell_unsandboxedwrite_fileandedit_fileon a path outside the session's folder- every MCP tool that is not read-only (a tool the server marks read-only, under ADR-048's trust, is not risky)
- any tool the app does not recognise
The reads (read_file, list_dir, glob, grep, git_status, git_diff, git_log, web_fetch, web_search, read_artifact, todo_write) are not risky.
The list lives in one place in GolemKit, as a function of the approval event (the tool's name, the paths in its arguments, whether an MCP tool is read-only). The approval sheet (14.5.3) and the lock-screen action (14.6.2) both call it. It is a list of tools, not a setting: the point is that a stolen phone, unlocked, cannot be made to run code by tapping.
The lock screen is stricter than the app, on purpose. A lock-screen action runs without the app's full view of the request, so it offers only Allow and Deny. A risky tool has no Allow there, only Review, which opens the approval sheet and asks for Face ID. "Always allow" is not on the lock screen at all, because a rule outlives the request and deserves the whole request in front of you.
A phone with neither Face ID nor a passcode cannot save a rule or allow a risky tool. Those buttons are hidden, and Deny stays.
"Always allow" from the phone is on
The phone may save an "Always allow" rule, after Face ID. This replaces "off on the phone by default" in docs/vision/security.md.
- The sheet shows the rule it will write, as the web's approval chip does, so you confirm the rule and not only the call.
- The rule records the device. The daemon writes the rule in
config.tomlas it does for any client (SessionManager._remember), and notes which device asked, through the mechanism ADR-051 names for telling the daemon which device answered. Tool rules lists it as "from iPhone of Milan". - Revoking a device leaves its rules and marks them "from a revoked device" in Settings, Tool rules, so they can be reviewed in one place and removed. Deleting them on revoke would silently change what golem does, since they were the owner's decisions made with Face ID. Keeping them unmarked would leave rules nobody can account for.
- It is the same rule as one saved on the Mac. The daemon does not tell them apart when it decides; only the list does.
Alternatives Considered
Alternative 1: Keep "Always allow" off on the phone
- Pros: A stolen, unlocked phone could never widen what golem may do.
- Cons: A routine that meets a tool you have already decided about sends you to the Mac. It makes the phone a worse client than the terminal.
- Why not: Face ID on every rule, a rule that names its device, and a marked trail on revoke keep most of the protection and keep the phone useful. The owner decided so.
Alternative 2: Face ID for every approval
- Pros: One rule, nothing to explain.
- Cons: People answer less when answering is a chore, and a routine waits for the answer.
- Why not: The proof is worth its friction where a wrong answer costs something, and no more.
Alternative 3: Check in the .xcodeproj
- Pros: No extra tool; Xcode opens it as is.
- Cons: It merges badly, hides changes in a diff, and conflicts between parallel tickets.
- Why not: See the decision.
Alternative 4: Tuist
- Pros: A richer project model and a build cache.
- Cons: Manifests in Swift, a larger tool, and caching that one app does not need.
- Why not: Over-built for one app and two extensions. The move later is one file.
Alternative 5: Support iOS 16
- Pros: Reaches a few more phones.
- Cons: No
@Observable, no interactive Live Activities, no push-to-start. - Why not: See the decision.
Alternative 6: Hand-written Swift types, or a web-view app
- Pros: No generator; or one codebase with the web UI.
- Cons: Hand-written types drift from the schema. A web view cannot do lock-screen actions, Face ID, Live Activities, or push, which are the reason for the app.
- Why not: Both lose what the app is for.
Consequences
Positive
- The Swift types are produced by the build and checked by the drift check on Linux, so a protocol change that breaks the app breaks CI first.
- GolemKit's tests run with
swift test, no simulator, and a Mac menu-bar app can reuse the package. - There is no project file to conflict in.
- The phone can do the whole approval job, and the strongest proof is asked only where a wrong answer costs most.
Negative
- The repo gains a second language, a macOS CI job (slower and dearer than Linux), and an Apple Developer account as a prerequisite for shipping.
- A contributor on Linux cannot build the app. They can still change the protocol:
just genwrites the Swift, and CI checks it. - The risky list is a decision to keep up. A new tool that changes things must be added to it, and until it is, the app treats it as risky.
- XcodeGen is a tool to install on a Mac (
brew install xcodegen);just iossays so when it is missing.
Risks
- quicktype's Swift may not compile cleanly for every schema (unions, defaults, shared definitions). 14.4.1 finds out; the fallback is named above.
- An attacker who knows the passcode can pass Face ID's fallback and save a rule from an unlocked phone. The Mac's Devices list and one revoke command end that, the rule notes its device, and the marked rules make it reviewable afterwards.
- Apple's rules for Live Activities and push can change. 14.6 needs iOS 17.2 and the push entitlement.
- The shipping job holds the App Store Connect key. It runs only for a tag, on the repository's own runners, and the key is a repository secret that can be rotated in App Store Connect.