Shared keychain access group (net-new surface next to keychain.rs's default-group items): per-device notification P-256 keypair generated in Rust, private key stored with kSecAttrAccessibleAfterFirstUnlock in the shared group (the NSE must decrypt while locked, no biometric prompt — Signal-style; the key protects notification content only, never identity material). Pinned sender-key set stored beside it. Stable device_uuid generated once.
Registration: obtain the APNs device token; call POST /v1/notifications/register at onboarding completion (post-promotion, over OAuth/DPoP) and again on every APNs token-change callback.
Re-pinning: refresh GET /v1/notifications/sender-keys on every successful app↔Custos contact — the property that keeps the sender-key compromise window short (design doc, Key lifecycle).
iOS 17 minimum: raise bundle > iOS > minimumSystemVersion to 17.0 for both apps (CryptoKit HPKE requires it; current deployment target rides tauri-cli's 13.0 default; neither app has an installed base below 17).
Post-reboot AfterFirstUnlock gap and reconcile-on-unlock behavior per the design doc (accepted for v1).
Acceptance
Keypair + pinned set persist in the shared group with the correct accessibility class; registration fires at onboarding completion and on token change (harness-verifiable via the browser test harness's fake IPC seam for the flow logic; keychain specifics unit-tested against the in-memory double).
Re-pin updates the stored set when the server rotates (add-new / retire / revoke all reflected).
pnpm check + Rust unit tests green in the ios-pr-check lane.
Problem
Self-hosted Custos instances need to deliver push notifications to the official iOS apps (Obsign, admin-companion). APNs auth keys are bundle-ID-bound, so self-hosters cannot push directly — a relay is structurally required. The design makes that relay a blind courier: trusted for availability only.
Architecture (see design doc for full detail)
Confidentiality: payloads HPKE-sealed (RFC 9180, DHKEM-P256 + AES-GCM) to a per-device notification key; decrypted on-device by a Notification Service Extension (mutable-content: 1). Neither the relay nor Apple sees plaintext.
Integrity: HPKE Auth mode with pinned, versioned per-instance sender keys — the relay cannot forge authenticated content (it can generate detectable junk pushes and replay; v1 accepts duplicates as benign).
Assistant
I'll start by activating the Linear workflow skill, since this is an MM-issue task.
Assistant
The branch already exists and its base includes MM-418 (the blocking issue). Let me confirm the Linear state and start reading the design doc.
Assistant
Issue is already In Progress and assigned; base is current with origin/main (MM-418 is in). Now let me read the design doc and the relevant wallet surfaces.
Assistant
Now let me examine the server side that MM-418 landed — the exact wire contract I need to match.
Assistant
★ Insight ─────────────────────────────────────
The keychain access group is already solved here: keychain.rs writes to $(AppIdentifierPrefix)org.obsign.shared (first in the entitlement array), which is precisely the group an NSE target will share. So the net-new keychain surface for MM-419 isn't the group — it's the accessibility class. Default items are kSecAttrAccessibleWhenUnlocked; an NSE decrypting a push on a locked screen needs kSecAttrAccessibleAfterFirstUnlock.
The server contract from MM-418 is already pinned: apnsToken must be pure hex, apnsTopic must look like a bundle id, and notificationPublicKey is decoded server-side as a P-256 did:key — so the wallet must emit the same did:key multicodec form the device key uses, not a raw point.
─────────────────────────────────────────────────
Assistant
Let me set up a task list and finish surveying the frontend seams.
Assistant
Now I'll implement. Starting with the keychain surface.
Assistant
Now the write accessor itself, placed beside the device-local family:
Assistant
Now the core module. Let me check the /v1/*-over-session call pattern in agents.rs first.
Assistant
Now the notifications module itself.
Assistant
Now register the module and its commands, and extend the keychain deny-list assertion.
Assistant
Let me compile and run the Rust tests now, before layering on the iOS bridge.
Assistant
★ Insight ─────────────────────────────────────
34/34 green. Notice the shape the tests take: the pin-store behaviour (a_501_leaves_the_pinned_set_exactly_as_it_was, pinning_replaces_a_hosts_set_wholesale) is where the security property lives — revocation on this device is implemented purely by "a successful fetch replaces wholesale", so those two tests are the compromise-window guarantee, not just CRUD coverage.
The kid collision across hosts is a real hazard the design doc's flat set glosses over: two Custos instances both start their AUTOINCREMENT at 1. Keying the pin store by hosting server makes the later NSE's candidate-trial safe, since HPKE Auth mode fails closed on a wrong sender key.
─────────────────────────────────────────────────
Assistant
Now let me refactor the command body into a reusable core, then add the iOS bridge.
Assistant
Now the iOS APNs bridge:
Assistant
Now wire it into lib.rs and add the iOS-only dependencies.
Assistant
Now the entitlements and Info.plist for push, plus the iOS 17 minimum for both apps.
Assistant
iOS cross-compile passes. Fixing the one dead-code warning (clippy runs with -D warnings):
Assistant
Now the frontend IPC wrappers.
Assistant
Those diagnostics are just the missing node_modules in this worktree (they'd fire on every existing IPC module too). Now the harness fakes:
Assistant
Now the registry handlers:
Assistant
Now the flow wiring. Let me find the completion + app-open hooks in +page.svelte.
Assistant
Now let me install frontend deps and run pnpm check + tests.
Assistant
Now the AGENTS.md updates:
Assistant
Now the invariants section:
Assistant
Now the CI gates. Formatting first (per the worktree cargo fmt --all gotcha), then the checks:
Assistant
Now the full gate sweep — clippy, host tests, iOS cross-compile, and the script checks:
Assistant
Clippy clean. Now the script gates and the iOS cross-compile re-check:
Assistant
Everything green. Committing and opening the PR.
Assistant
User
we've got conflicts with main
Assistant
Two overlapping files (AGENTS.md, +page.svelte). Let me rebase onto the new main.
Assistant
The merge is semantically clean — main's new checkAndLand() alarm takeover sits above the loop and doesn't interact with the notification sweep. Let me verify and continue the rebase.
Assistant
All my changes are intact on top of main. Re-running the affected gates:
Assistant
Conflicts resolved — GitHub just needed a moment to recompute. Let me check CI.
Assistant
Frontend checks are green. The iOS and PDS lanes are still running — let me watch them in the background.
Only one hunk, in +page.svelte:60: main's MM-467 alarm-takeover PR (#470) added type IdentityStatus to the same $lib/ipc import line I'd added registerForNotifications to. Resolved by keeping both, plus main's new decideAlarmLanding import.
The other three overlaps merged cleanly, and I checked the merged result rather than trusting the auto-merge:
User
CodeRabbit has left several comments that we should address
Assistant
I'll use the PR review comments skill to fetch the whole batch at once.
Assistant
Let me verify two claims against the actual code before deciding.
Assistant
All nine verified against the code. Here's the disposition — then I'll apply them as one batch (a single commit, so CI and CodeRabbit re-run once).
#
Thread
Classification
Assistant
Now #2 needs a regression test, and #1's read-back changes a path. Let me add coverage:
Assistant
Now the harness fixes (#6, #7) and the test comment (#5):
Assistant
Now the harness test — #5's comment plus the new levers:
Assistant
Now #8 — re-register after both migration branches:
Assistant
Now #9 — the changelog's overclaim:
Assistant
All green (249 frontend tests, up from 247; 26 Rust notification tests, up from 22). Committing and pushing as one batch:
Assistant
All nine threads addressed and resolved in one commit (608f9ef8). Let me check the earlier CI poll.
Assistant
Metadata minimization: opaque push handles bound to the instance's iroh node id (no DIDs/handles/raw tokens at the relay), fixed-size padding budgeted against the serialized APNs request, optional content-free ping mode.
Transport: Custos ↔ relay over iroh, new ezpds/notify/0 ALPN, reusing the persisted node identity (iroh_identity) and iroh_tunnel.rs patterns; back-channel carries APNs 410 Unregistered pruning feedback.
Sovereignty: relay is an open-source workspace crate (crates/notify-relay/); any instance points at any relay via [notifications] relay = "<node id>". Official relay requires a claim-code enrollment grant; open enrollment is a config option for self-run relays. Caveat: official bundle IDs require the official relay's APNs key.
Suggested phasing
Relay crate + Custos sender — crates/notify-relay/ (claim-code enrollment grants, handle store with per-handle APNs topic, APNs HTTP/2 client, per-node rate limits, serialized-request size validation with 4 KB boundary test) + [notifications] config, device notification-key registration route, versioned sender-key set, sealed-send on first trigger (agent claim pending). Loopback iroh e2e tests with mock APNs.
Delivery receipts over the iroh back-channel (out of scope v1)
Android/FCM later (envelope is provider-agnostic)
Not yet scheduled into a wave; split into per-phase issues when picked up.
Please open a PR linked to the linear issue when complete
MM-419 is done — PR #472 is open and Linear is in In Review with the PR attached.
What shipped
notifications.rs — the device half: stable device_uuid, per-device P-256 notification keypair, per-host pinned sender-key set, registration against POST /v1/notifications/register, and the re-pin against GET /v1/notifications/sender-keys.
Plus the keychain accessor, IPC wrappers, harness fakes, flow wiring at all three onboarding completions + app open, iOS 17 for both apps, aps-environment, docs, and a changelog fragment.
★ Insight ─────────────────────────────────────
Two places where the issue's framing and the codebase disagreed, and the code won:
The issue calls the keychain work a "shared access group (net-new surface)". It isn't — ADR-0030 already made org.obsign.shared the write target for every item. The net-new thing is the protection class, and the subtle trap there is that SecItemUpdate can't change one, so add-or-update would silently keep whatever class the first write set. Delete-then-add isn't a style choice; it's the only way the accessor's contract holds across the re-pin that rewrites the set on every contact.
The design doc describes one flat pinned set. That breaks on a multi-identity wallet, because kid is an AUTOINCREMENT column per instance — two Custos hosts both hand out kid: 1. Keying by host is safe precisely because HPKE Auth mode fails closed, so the extension can try candidates without a disambiguator.
─────────────────────────────────────────────────
Verification
718 Rust tests (34 new), clippy clean, iOS cross-compile clean for both apps, pnpm check 0 errors, 236 frontend tests (7 new harness tests), and all ten script gates pass.
Two things I want to flag rather than bury:
Not verified without a device. The delegate installation, the permission prompt, and a real APNs token round-tripping have no automated check beyond the cross-compile. That's inherent to the surface, but it means the feature is compile-proven, not behaviour-proven, until MM-420's on-device demo.
Apple Developer portal work is required before this can build signed. The aps-environment entitlement needs Push Notifications enabled on the App ID and the provisioning profile regenerated — otherwise TestFlight signing fails with an entitlements mismatch. Unlike keychain-access-groups, the team-prefix wildcard doesn't cover it.
AGENTS.md — auto-merged; my 12 added lines are all present alongside main's 3.
The mount block — main inserted void checkAndLand() (the alarm takeover) directly above the opportunistic-pass loop my syncNotifications(did) lives in. Verified they don't interact: checkAndLand is unawaited and only swaps step, while the loop is per-identity fire-and-forget.
The claim/recovery completion hooks — untouched by main.
All five call sites survived, confirmed by grep rather than assumption.
Test count went 236 → 247 because main's PR brought its own alarm-landing.test.ts; my 7 harness tests are still in there.
On CI, Frontend check for both apps has already passed. The PDS gate and the two iOS compile jobs are still running — the iOS compile (identity-wallet) one is the one that matters most here, since it's the only automated check apns.rs gets. I've got a background poll watching them and will report when they settle.
Fix. The sibling key writer reads back for exactly this reason, and the doc says a non-persisting UUID means a dead server row + live relay handle per launch
Fix. Confirmed: wrong-length self-heals, wrong-value returns KeyGenerationFailed on every call with nothing to replace the slot
3
notifications.rs:462 — concurrent re-pin lost update
Correctness — real
Fix. +page.svelte fires syncNotifications per identity without awaiting, and Tauri's runtime is multi-threaded, so two sync read-modify-writes genuinely overlap on one shared document
registry.ts:1365 — relay support inferred from sovereignSessions
Correctness — real
Fix, via a state flag not a capability string (see below)
7
registry.ts:1401 — diagnostics key id gated on APNs token
Correctness — real
Fix. Rust derives it from the stored scalar; the harness diverges from the thing Settings gets written against
8
+page.svelte:646 — no re-register after migration
Correctness — real
Fix. A migration moves the identity to a Custos that has never seen this device
9
mm-419.added.md — overclaims privacy
Accuracy — real
Fix the wording. Decline the attached MD041 lint: every fragment in changelog.d/ is a bare paragraph by convention
One deviation on #6: CodeRabbit offered "a notifications capability string, or a state flag". I checked capabilities.rs — the server advertises no notifications capability, because the 501 comes from [notifications] relay being unset, not from anything on the wire. Inventing a capability string in the harness would model a protocol that doesn't exist, so I'm taking the state-flag option.
All nine CodeRabbit threads addressed in one commit and resolved. CodeRabbit now shows "Review approved."
★ Insight ─────────────────────────────────────
The most interesting finding was the concurrent-re-pin one, because it's a bug my own code created — and the vector was a line I wrote two files away. syncNotifications fires per identity in a loop without awaiting, so on Tauri's multi-thread runtime two synchronous load → insert → store passes over one shared keychain document genuinely overlap. The consequence isn't a stale cache entry: if the discarded write was the one that dropped a revoked sender key, that host goes back to trusting it — reopening the exact window the module header claims re-pinning closes. A security property implemented as "replace wholesale" quietly depends on the replace being atomic.
The second-most interesting: two of the nine were harness divergences, not product bugs. Both were cases where the fake inferred state instead of tracking it (relay support from sovereignSessions; key presence from the APNs token). That's a specific failure mode for test doubles — an inference that happens to be true today makes a real state unreachable, and the harness is what the next screen gets written against.
─────────────────────────────────────────────────
What changed
Real defects (6):
Two ways the notification key could get permanently stuck — a right-length/wrong-value scalar erroring forever, and mint_device_uuid skipping the read-back its sibling writer performs
The concurrent re-pin race above, closed with a std::sync::Mutex taken and released inside the synchronous function (never across an .await)
Migration left the destination Custos with no registration and no pinned keys until a future relaunch — both branches now re-register
An unavailable clock reported as NETWORK_ERROR, violating the rule stated at the top of the same file
Harness fidelity (2): a dedicated relaySupported state flag, and notificationKeyMinted tracked rather than inferred.
Copy (1): the changelog claimed "nothing about this can identify you to anyone in between." That's false — encryption protects the notification's content, but your server is told which device to reach and Apple handles delivery. Reworded to claim only what's true.
Declined (1): the MD041 "no top-level heading" lint on the changelog fragment — every fragment in changelog.d/ is a bare paragraph by convention.
Verification
Rust notification tests 22 → 26 (added coverage for the invalid-scalar wedge and the uuid read-back), frontend 247 → 249. pnpm check 0 errors, clippy clean, changelog/docs/ticket-ref gates pass. Frontend checks are already green on CI; the iOS and PDS lanes are running and I've got a background poll on them.